Skip to content

document ->sighand protection, rcu_read_unlock() deadlocks

Oleg Nesterov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 2 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2signal: document the RCU protection of ->sighandkernel/fork.c kernel/signal.c+15 -20 replies
2/2rcu: more info about potential deadlocks with rcu_read_unlock()include/linux/rcupdate.h+3 -10 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchSteven RostedtRik van Riel
1/2R-b R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] document ->sighand protection, rcu_read_unlock() deadlocks

Paul, could you take these 2 doc patches? Assuming that you agree with the comments, of course.

Quoted 12 lines · Paul E. McKenney
Quoted 9 lines · Oleg Nesterov

Paul, will you agree if we turn it into
...
/*
* On the succesfull return we hold ->siglock. According to comment
* above rcu_read_unlock() this is against the rules, but scheduler
* locks are fine under this lock, signal_wake_up() takes them too. */
rcu_read_unlock();

Quoted 1 line

If you guys continue the guarantee of no deadlock, I am OK with this change.

Heh. Contrary to what I said (and you all were agree ;), this deadlock is actually possible, so we can not remove the deadlock-avoidance from __lock_task_sighand(). And I do not see how we can cleanup this code because preempt_disable() + spin_lock() is not -rt friendly.

I think this deserves a bit of documentation, see 2/2. Perhaps this is just me, but imo the current comment is a bit misleading.

"if the caller of rcu_read_unlock() already holds one of these locks ..." is not a problem in fact. I mean, pi_lock or rq->lock are special enough, nobody should ever call the outermost rcu_read_unlock() with these locks held. rt_mutex->wait_lock should be fine too, also because ->boost_mtx is private to rcu_boost() and rcu_read_unlock_special().

But. They can race with each other, and that is why rcu_read_unlock() under (say) ->siglock can actually lead to deadlock. And only because rt_mutex->wait_lock doesn't disable irqs. Or I am totally confused.

Perhaps we can change rtmutex.c to use raw_spin_lock_irqsave(), or do something else...

Oleg.

 include/linux/rcupdate.h |    4 +++-
 kernel/fork.c            |    5 ++++-
 kernel/signal.c          |   12 +++++++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)