Add patch to fix lock inversion introduced in 3.0.7

This commit is contained in:
Josh Boyer 2011-10-18 15:47:52 -04:00
parent 7be21bba89
commit a7fc75d2d8
2 changed files with 154 additions and 1 deletions

View File

@ -0,0 +1,148 @@
Path: news.gmane.org!not-for-mail
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Newsgroups: gmane.linux.kernel
Subject: Re: Linux 3.1-rc9
Date: Tue, 18 Oct 2011 11:05:13 +0200
Lines: 84
Approved: news@gmane.org
Message-ID: <1318928713.21167.4.camel@twins>
References: <CA+55aFxPNszU5UHFrDDYnshLEMupaviFwhgEsgmPkqpmuWNZ8A@mail.gmail.com>
<20111007070842.GA27555@hostway.ca> <20111007174848.GA11011@hostway.ca>
<1318010515.398.8.camel@twins> <20111008005035.GC22843@hostway.ca>
<1318060551.8395.0.camel@twins> <20111012213555.GC24461@hostway.ca>
<20111013232521.GA5654@hostway.ca>
<CA+55aFxxfsFMgqA7kYKukvkCX6Z9HrKOtP-22w5Mc21iQj4c=Q@mail.gmail.com>
<1318847658.6594.40.camel@twins>
<CA+55aFxaGKEyhXdHXNxvPrPQ-SGSpbXdfoeXrxfjPx3VXsgvtg@mail.gmail.com>
<1318874090.4172.84.camel@twins>
<CA+55aFwCBy=4YK6amE=H-BYu9-boj4Po2Zkgf4V261mCx0DC4A@mail.gmail.com>
<1318879396.4172.92.camel@twins> <alpine.LFD.2.02.1110172237030.3240@ionos>
<alpine.LFD.2.02.1110181037120.3240@ionos>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8BIT
X-Trace: dough.gmane.org 1318928749 2484 80.91.229.12 (18 Oct 2011 09:05:49 GMT)
X-Complaints-To: usenet@dough.gmane.org
NNTP-Posting-Date: Tue, 18 Oct 2011 09:05:49 +0000 (UTC)
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Simon Kirby <sim@hostway.ca>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Dave Jones <davej@redhat.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Ingo Molnar <mingo@elte.hu>
To: Thomas Gleixner <tglx@linutronix.de>
Original-X-From: linux-kernel-owner@vger.kernel.org Tue Oct 18 11:05:43 2011
Return-path: <linux-kernel-owner@vger.kernel.org>
Envelope-to: glk-linux-kernel-3@lo.gmane.org
Original-Received: from vger.kernel.org ([209.132.180.67])
by lo.gmane.org with esmtp (Exim 4.69)
(envelope-from <linux-kernel-owner@vger.kernel.org>)
id 1RG5cB-0003K9-2n
for glk-linux-kernel-3@lo.gmane.org; Tue, 18 Oct 2011 11:05:39 +0200
Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1757183Ab1JRJFc (ORCPT <rfc822;glk-linux-kernel-3@m.gmane.org>);
Tue, 18 Oct 2011 05:05:32 -0400
Original-Received: from casper.infradead.org ([85.118.1.10]:40399 "EHLO
casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1753880Ab1JRJFa convert rfc822-to-8bit (ORCPT
<rfc822;linux-kernel@vger.kernel.org>);
Tue, 18 Oct 2011 05:05:30 -0400
Original-Received: from j77219.upc-j.chello.nl ([24.132.77.219] helo=twins)
by casper.infradead.org with esmtpsa (Exim 4.76 #1 (Red Hat Linux))
id 1RG5bu-0008Qu-O5; Tue, 18 Oct 2011 09:05:22 +0000
Original-Received: by twins (Postfix, from userid 1000)
id 69952813C82C; Tue, 18 Oct 2011 11:05:13 +0200 (CEST)
In-Reply-To: <alpine.LFD.2.02.1110181037120.3240@ionos>
X-Mailer: Evolution 3.0.3-
Original-Sender: linux-kernel-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org
Xref: news.gmane.org gmane.linux.kernel:1204676
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1204676>
On Tue, 2011-10-18 at 10:39 +0200, Thomas Gleixner wrote:
> On Mon, 17 Oct 2011, Thomas Gleixner wrote:
> > That said, I really need some sleep before I can make a final
> > judgement on that horror. The call paths are such an intermingled mess
> > that it's not funny anymore. I do that tomorrow morning first thing.
>
> The patch is safe and the exit race just existed in my confused tired
> brain. Peter, can you please provide a changelog. That wants a cc
> stable as well, because that deadlock causing commit hit 3.0.7 :(
---
Subject: cputimer: Cure lock inversion
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Mon Oct 17 11:50:30 CEST 2011
There's a lock inversion between the cputimer->lock and rq->lock; notably
the two callchains involved are:
update_rlimit_cpu()
sighand->siglock
set_process_cpu_timer()
cpu_timer_sample_group()
thread_group_cputimer()
cputimer->lock
thread_group_cputime()
task_sched_runtime()
->pi_lock
rq->lock
scheduler_tick()
rq->lock
task_tick_fair()
update_curr()
account_group_exec()
cputimer->lock
Where the first one is enabling a CLOCK_PROCESS_CPUTIME_ID timer, and
the second one is keeping up-to-date.
This problem was introduced by e8abccb7193 ("posix-cpu-timers: Cure
SMP accounting oddities").
Cure the problem by removing the cputimer->lock and rq->lock nesting,
this leaves concurrent enablers doing duplicate work, but the time
wasted should be on the same order otherwise wasted spinning on the
lock and the greater-than assignment filter should ensure we preserve
monotonicity.
Reported-by: Dave Jones <davej@redhat.com>
Reported-by: Simon Kirby <sim@hostway.ca>
Cc: stable@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/posix-cpu-timers.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: linux-2.6/kernel/posix-cpu-timers.c
===================================================================
--- linux-2.6.orig/kernel/posix-cpu-timers.c
+++ linux-2.6/kernel/posix-cpu-timers.c
@@ -274,9 +274,7 @@ void thread_group_cputimer(struct task_s
struct task_cputime sum;
unsigned long flags;
- spin_lock_irqsave(&cputimer->lock, flags);
if (!cputimer->running) {
- cputimer->running = 1;
/*
* The POSIX timer interface allows for absolute time expiry
* values through the TIMER_ABSTIME flag, therefore we have
@@ -284,8 +282,11 @@ void thread_group_cputimer(struct task_s
* it.
*/
thread_group_cputime(tsk, &sum);
+ spin_lock_irqsave(&cputimer->lock, flags);
+ cputimer->running = 1;
update_gt_cputime(&cputimer->cputime, &sum);
- }
+ } else
+ spin_lock_irqsave(&cputimer->lock, flags);
*times = cputimer->cputime;
spin_unlock_irqrestore(&cputimer->lock, flags);
}

View File

@ -42,7 +42,7 @@ Summary: The Linux kernel
# When changing real_sublevel below, reset this by hand to 1
# (or to 0 and then use rpmdev-bumpspec).
#
%global baserelease 0
%global baserelease 1
%global fedora_build %{baserelease}
# real_sublevel is the 3.x kernel version we're starting with
@ -649,6 +649,7 @@ Patch12016: disable-i8042-check-on-apple-mac.patch
Patch12023: ums-realtek-driver-uses-stack-memory-for-DMA.patch
Patch12024: usb-add-quirk-for-logitech-webcams.patch
Patch12025: crypto-register-cryptd-first.patch
Patch12026: cputimer-Cure-lock-inversion.patch
# Runtime power management
Patch12203: linux-2.6-usb-pci-autosuspend.patch
@ -1240,6 +1241,7 @@ ApplyPatch add-appleir-usb-driver.patch
ApplyPatch ums-realtek-driver-uses-stack-memory-for-DMA.patch
ApplyPatch usb-add-quirk-for-logitech-webcams.patch
ApplyPatch crypto-register-cryptd-first.patch
ApplyPatch cputimer-Cure-lock-inversion.patch
# rhbz#605888
ApplyPatch dmar-disable-when-ricoh-multifunction.patch
@ -1908,6 +1910,9 @@ fi
# and build.
%changelog
* Tue Oct 18 2011 Josh Boyer <jwboyer@redhat.com>
- Add patch to fix lock inversion introduced in 3.0.7
* Mon Oct 17 2011 Josh Boyer <jwboyer@redhat.com> 2.6.40.7-0
- Linux 3.0.7 stable release
- Add two patches to fix stalls in khugepaged (rhbz 735946)