From patchwork Wed Jul 20 00:18:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 2777 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 51BDA2405F for ; Wed, 20 Jul 2011 00:18:36 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 209ECA1822E for ; Wed, 20 Jul 2011 00:18:36 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3318941qwb.11 for ; Tue, 19 Jul 2011 17:18:35 -0700 (PDT) Received: by 10.229.236.10 with SMTP id ki10mr6185697qcb.274.1311121115820; Tue, 19 Jul 2011 17:18:35 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs98676qcb; Tue, 19 Jul 2011 17:18:35 -0700 (PDT) Received: by 10.68.52.196 with SMTP id v4mr10384687pbo.508.1311121113991; Tue, 19 Jul 2011 17:18:33 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com [32.97.182.139]) by mx.google.com with ESMTPS id q2si1473389pbf.32.2011.07.19.17.18.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jul 2011 17:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e9.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6JNkJtv006088; Tue, 19 Jul 2011 19:46:19 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6K0IW7U108136; Tue, 19 Jul 2011 20:18:32 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6K0IRQb015947; Tue, 19 Jul 2011 20:18:32 -0400 Received: from paulmck-ThinkPad-W500 (paulmck-ThinkPad-W500.beaverton.ibm.com [9.47.24.65]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6K0IReh015896; Tue, 19 Jul 2011 20:18:27 -0400 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id C112213F807; Tue, 19 Jul 2011 17:18:25 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, patches@linaro.org, greearb@candelatech.com, edt@aei.ca, "Paul E. McKenney" , "Paul E. McKenney" Subject: [PATCH tip/core/urgent 7/7] signal: align __lock_task_sighand() irq disabling and RCU Date: Tue, 19 Jul 2011 17:18:23 -0700 Message-Id: <1311121103-16978-7-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <20110720001738.GA16369@linux.vnet.ibm.com> References: <20110720001738.GA16369@linux.vnet.ibm.com> From: Paul E. McKenney The __lock_task_sighand() function calls rcu_read_lock() with interrupts and preemption enabled, but later calls rcu_read_unlock() with interrupts disabled. It is therefore possible that this RCU read-side critical section will be preempted and later RCU priority boosted, which means that rcu_read_unlock() will call rt_mutex_unlock() in order to deboost itself, but with interrupts disabled. This results in lockdep splats, so this commit nests the RCU read-side critical section within the interrupt-disabled region of code. This prevents the RCU read-side critical section from being preempted, and thus prevents the attempt to deboost with interrupts disabled. It is quite possible that a better long-term fix is to make rt_mutex_unlock() disable irqs when acquiring the rt_mutex structure's ->wait_lock. Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney --- kernel/signal.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index ff76786..a0eb019 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1178,18 +1178,24 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, { struct sighand_struct *sighand; - rcu_read_lock(); for (;;) { + local_irq_save(*flags); + rcu_read_lock(); sighand = rcu_dereference(tsk->sighand); - if (unlikely(sighand == NULL)) + if (unlikely(sighand == NULL)) { + rcu_read_unlock(); + local_irq_restore(*flags); break; + } - spin_lock_irqsave(&sighand->siglock, *flags); - if (likely(sighand == tsk->sighand)) + spin_lock(&sighand->siglock); + if (likely(sighand == tsk->sighand)) { + rcu_read_unlock(); break; + } + rcu_read_unlock(); spin_unlock_irqrestore(&sighand->siglock, *flags); } - rcu_read_unlock(); return sighand; }