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

From: Oleg Nesterov
Date: Sun Sep 28 2014 - 17:47:21 EST

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

On 09/24, Paul E. McKenney wrote:
> On Tue, Sep 23, 2014 at 09:03:48PM +0200, Oleg Nesterov wrote:
> >
> > 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();
> 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...


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

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/