linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question on task_blocks_on_rt_mutex()
@ 2020-08-31 22:49 Paul E. McKenney
  2020-08-31 23:21 ` Paul E. McKenney
  0 siblings, 1 reply; 12+ messages in thread
From: Paul E. McKenney @ 2020-08-31 22:49 UTC (permalink / raw)
  To: peterz, mingo, will; +Cc: linux-kernel

Hello!

The task_blocks_on_rt_mutex() function uses rt_mutex_owner() to
take a snapshot of the lock owner right up front.  At this point,
the ->wait_lock is held, which at first glance prevents the owner
from leaving.  Except that if there are not yet any waiters (that is,
the low-order bit of ->owner is zero), rt_mutex_fastunlock() might
locklessly clear the ->owner field.  And in that case, it looks like
task_blocks_on_rt_mutex() will blithely continue using the ex-owner's
task_struct structure, without anything that I can see that prevents
the ex-owner from exiting.

What am I missing here?

The reason that I am looking into this is that locktorture scenario LOCK05
hangs, and does so leaving the torture_rtmutex.waiters field equal to 0x1.
This is of course a legal transitional state, but I would not expect it
to persist for more than three minutes.  Yet it often does.

This leads me to believe that there is a way for an unlock to fail to wake
up a task concurrently acquiring the lock.  This seems to be repaired
by later lock acquisitions, and in fact setting the locktorture.stutter
module parameter to zero avoids the hang.  Except that I first found the
above apparently unprotected access to what was recently the owner task.

Thoughts?

							Thanx, Paul

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

end of thread, other threads:[~2020-09-06  4:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 22:49 Question on task_blocks_on_rt_mutex() Paul E. McKenney
2020-08-31 23:21 ` Paul E. McKenney
2020-09-01 17:49   ` Paul E. McKenney
2020-09-01 23:58     ` Paul E. McKenney
2020-09-02  1:51       ` Davidlohr Bueso
2020-09-02 15:54         ` Paul E. McKenney
2020-09-03 20:06           ` Paul E. McKenney
2020-09-04 17:24             ` Davidlohr Bueso
2020-09-04 19:56               ` Paul E. McKenney
2020-09-05 21:24             ` Joel Fernandes
2020-09-05 21:45               ` Joel Fernandes
2020-09-06  4:14                 ` Paul E. McKenney

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).