linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* qrwlock && read-after-read
@ 2015-08-04 13:00 Oleg Nesterov
  2015-08-04 13:10 ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Oleg Nesterov @ 2015-08-04 13:00 UTC (permalink / raw)
  To: Arnd Bergmann, Ingo Molnar, Linus Torvalds, Paul E.McKenney,
	Peter Zijlstra, Waiman Long
  Cc: linux-kernel

I am working on the (off-topic) bug report which motivated me to
look at locking/qrwlock.c and it seems to me there is a problem
with the queued rwlocks.

Unless I am totally confused read-after-read is no longer valid,
write_lock() stops the new readers. And lockdep doesn't know this,
read_lock()->rwlock_acquire_read() doesn't match the reality. The
code doing

	read_lock(X);
	read_lock(X);

can deadlock if another CPU does write_lock(X) in between. This
was fine before rwlock_t was changed to use qrwlock.

A nested read_lock() in interrupt should be fine though, and this
is because queue_read_lock_slowpath() "ignores" _QW_WAITING if
in_interrupt().

This means that rwlock_t has the really strange semantics imho,
and again, it is not lockdep-friendly.

What do you think we can/should do? Or did I misread this code?

Oleg.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-05 13:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 13:00 qrwlock && read-after-read Oleg Nesterov
2015-08-04 13:10 ` Peter Zijlstra
2015-08-04 13:40   ` Oleg Nesterov
2015-08-04 17:32     ` Peter Zijlstra
2015-08-04 13:51   ` Linus Torvalds
2015-08-05 13:08     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).