lkml.org 
[lkml]   [2017]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Q: lockdep_assert_held_read() after downgrade_write()
On Tue, Jan 31, 2017 at 09:23:08AM -0500, Waiman Long wrote:
> On 01/31/2017 06:25 AM, Peter Zijlstra wrote:
> > @@ -40,8 +40,10 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem)
> > * do a write to the rwsem cacheline when it is really necessary
> > * to minimize cacheline contention.
> > */
> > - if (sem->owner != RWSEM_READER_OWNED)
> > + if (sem->owner != RWSEM_READER_OWNED) {
> > + WARN_ON_ONCE(sem->owner != current);
> > WRITE_ONCE(sem->owner, RWSEM_READER_OWNED);
> > + }
> > }
> >
> > static inline bool rwsem_owner_is_writer(struct task_struct *owner)
>
> I don't think you can do a WARN_ON_ONCE() check for sem->owner !=
> current here. If the rwsem starts from an unlock state, sem->owner will
> be NULL and an incorrect warning message will be printed.

Argh, I only looked at the downgrade_write() user and forgot to look if
it was used elsewhere.

\
 
 \ /
  Last update: 2017-01-31 15:27    [W:0.052 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site