linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>, John Kacur <jkacur@redhat.com>
Subject: [PATCH RT 05/11] slab: Prevent local lock deadlock
Date: Mon, 16 Jul 2012 14:43:15 -0400	[thread overview]
Message-ID: <20120716184354.467426653@goodmis.org> (raw)
In-Reply-To: 20120716184310.223095720@goodmis.org

[-- Attachment #1: 0005-slab-Prevent-local-lock-deadlock.patch --]
[-- Type: text/plain, Size: 1998 bytes --]

From: Thomas Gleixner <tglx@linutronix.de>

On RT we avoid the cross cpu function calls and take the per cpu local
locks instead. Now the code missed that taking the local lock on the
cpu which runs the code must use the proper local lock functions and
not a simple spin_lock(). Otherwise it deadlocks later when trying to
acquire the local lock with the proper function.

Reported-and-tested-by: Chris Pringle <chris.pringle@miranda.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 mm/slab.c |   26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 15bce6b..64eb636 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -743,8 +743,26 @@ slab_on_each_cpu(void (*func)(void *arg, int this_cpu), void *arg)
 {
 	unsigned int i;
 
+	get_cpu_light();
 	for_each_online_cpu(i)
 		func(arg, i);
+	put_cpu_light();
+}
+
+static void lock_slab_on(unsigned int cpu)
+{
+	if (cpu == smp_processor_id())
+		local_lock_irq(slab_lock);
+	else
+		local_spin_lock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock);
+}
+
+static void unlock_slab_on(unsigned int cpu)
+{
+	if (cpu == smp_processor_id())
+		local_unlock_irq(slab_lock);
+	else
+		local_spin_unlock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock);
 }
 #endif
 
@@ -2692,10 +2710,10 @@ static void do_drain(void *arg, int cpu)
 {
 	LIST_HEAD(tmp);
 
-	spin_lock_irq(&per_cpu(slab_lock, cpu).lock);
+	lock_slab_on(cpu);
 	__do_drain(arg, cpu);
 	list_splice_init(&per_cpu(slab_free_list, cpu), &tmp);
-	spin_unlock_irq(&per_cpu(slab_lock, cpu).lock);
+	unlock_slab_on(cpu);
 	free_delayed(&tmp);
 }
 #endif
@@ -4163,9 +4181,9 @@ static void do_ccupdate_local(void *info)
 #else
 static void do_ccupdate_local(void *info, int cpu)
 {
-	spin_lock_irq(&per_cpu(slab_lock, cpu).lock);
+	lock_slab_on(cpu);
 	__do_ccupdate_local(info, cpu);
-	spin_unlock_irq(&per_cpu(slab_lock, cpu).lock);
+	unlock_slab_on(cpu);
 }
 #endif
 
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-16 18:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16 18:43 [PATCH RT 00/11] [ANNOUNCE] 3.4.4-rt14-rc1 stable review Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 01/11] Latency histogramms: Cope with backwards running local trace clock Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 02/11] Latency histograms: Adjust timer, if already elapsed when programmed Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 03/11] Disable RT_GROUP_SCHED in PREEMPT_RT_FULL Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 04/11] Latency histograms: Detect another yet overlooked sharedprio condition Steven Rostedt
2012-07-16 18:43 ` Steven Rostedt [this message]
2012-07-16 18:43 ` [PATCH RT 06/11] fs, jbd: pull your plug when waiting for space Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 07/11] perf: Make swevent hrtimer run in irq instead of softirq Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 08/11] cpu/rt: Rework cpu down for PREEMPT_RT Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 09/11] workqueue: Revert workqueue: Fix PF_THREAD_BOUND abuse Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 10/11] workqueue: Revert workqueue: Fix cpuhotplug trainwreck Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 11/11] Linux 3.4.4-rt14-rc1 Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120716184354.467426653@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).