From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754360AbaI1VrS (ORCPT ); Sun, 28 Sep 2014 17:47:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26286 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753397AbaI1VrR (ORCPT ); Sun, 28 Sep 2014 17:47:17 -0400 Date: Sun, 28 Sep 2014 23:43:57 +0200 From: Oleg Nesterov To: "Paul E. McKenney" Cc: Andrew Morton , Peter Zijlstra , Rik van Riel , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/2] document ->sighand protection, rcu_read_unlock() deadlocks Message-ID: <20140928214357.GA17874@redhat.com> References: <20140922164404.GA28910@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140922164404.GA28910@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... Oleg. include/linux/rcupdate.h | 4 +++- kernel/fork.c | 5 ++++- kernel/signal.c | 12 +++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-)