public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Galbraith <umgwanakikbuti@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>, John Kacur <jkacur@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <williams@redhat.com>
Subject: 3.14.23-rt20 - sched/numa: Fix task_numa_free() lockdep splat
Date: Sun, 02 Nov 2014 08:30:51 +0100	[thread overview]
Message-ID: <1414913451.5380.111.camel@marge.simpson.net> (raw)
In-Reply-To: <1414910967.5380.81.camel@marge.simpson.net>

>From 60e69eed85bb7b5198ef70643b5895c26ad76ef7 Mon Sep 17 00:00:00 2001
From: Mike Galbraith <bitbucket@online.de>
Date: Mon, 7 Apr 2014 10:55:15 +0200
Subject: sched/numa: Fix task_numa_free() lockdep splat

Sasha reported that lockdep claims that the following commit:
made numa_group.lock interrupt unsafe:

  156654f491dd ("sched/numa: Move task_numa_free() to __put_task_struct()")

While I don't see how that could be, given the commit in question moved
task_numa_free() from one irq enabled region to another, the below does
make both gripes and lockups upon gripe with numa=fake=4 go away.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Fixes: 156654f491dd ("sched/numa: Move task_numa_free() to __put_task_struct()")
Signed-off-by: Mike Galbraith <bitbucket@online.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: torvalds@linux-foundation.org
Cc: mgorman@suse.com
Cc: akpm@linux-foundation.org
Cc: Dave Jones <davej@redhat.com>
Link: http://lkml.kernel.org/r/1396860915.5170.5.camel@marge.simpson.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>

---
 kernel/sched/fair.c  |   13 +++++++------
 kernel/sched/sched.h |    9 +++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1371,7 +1371,7 @@ static void task_numa_placement(struct t
 	/* If the task is part of a group prevent parallel updates to group stats */
 	if (p->numa_group) {
 		group_lock = &p->numa_group->lock;
-		spin_lock(group_lock);
+		spin_lock_irq(group_lock);
 	}
 
 	/* Find the node with the highest number of faults */
@@ -1432,7 +1432,7 @@ static void task_numa_placement(struct t
 			}
 		}
 
-		spin_unlock(group_lock);
+		spin_unlock_irq(group_lock);
 	}
 
 	/* Preferred node as the node with the most faults */
@@ -1532,7 +1532,8 @@ static void task_numa_group(struct task_
 	if (!join)
 		return;
 
-	double_lock(&my_grp->lock, &grp->lock);
+	BUG_ON(irqs_disabled());
+	double_lock_irq(&my_grp->lock, &grp->lock);
 
 	for (i = 0; i < 2*nr_node_ids; i++) {
 		my_grp->faults[i] -= p->numa_faults[i];
@@ -1546,7 +1547,7 @@ static void task_numa_group(struct task_
 	grp->nr_tasks++;
 
 	spin_unlock(&my_grp->lock);
-	spin_unlock(&grp->lock);
+	spin_unlock_irq(&grp->lock);
 
 	rcu_assign_pointer(p->numa_group, grp);
 
@@ -1565,14 +1566,14 @@ void task_numa_free(struct task_struct *
 	void *numa_faults = p->numa_faults;
 
 	if (grp) {
-		spin_lock(&grp->lock);
+		spin_lock_irq(&grp->lock);
 		for (i = 0; i < 2*nr_node_ids; i++)
 			grp->faults[i] -= p->numa_faults[i];
 		grp->total_faults -= p->total_numa_faults;
 
 		list_del(&p->numa_entry);
 		grp->nr_tasks--;
-		spin_unlock(&grp->lock);
+		spin_unlock_irq(&grp->lock);
 		rcu_assign_pointer(p->numa_group, NULL);
 		put_numa_group(grp);
 	}
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1402,6 +1402,15 @@ static inline void double_lock(spinlock_
 	spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
 }
 
+static inline void double_lock_irq(spinlock_t *l1, spinlock_t *l2)
+{
+	if (l1 > l2)
+		swap(l1, l2);
+
+	spin_lock_irq(l1);
+	spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
+}
+
 static inline void double_raw_lock(raw_spinlock_t *l1, raw_spinlock_t *l2)
 {
 	if (l1 > l2)







  parent reply	other threads:[~2014-11-02  7:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31 21:03 [ANNOUNCE] 3.14.23-rt20 Steven Rostedt
2014-11-02  7:30 ` Mike Galbraith
     [not found]   ` <CADLDEKvFvw7Aa98tVtM3z5JV8oocKqAdV4PqOMoZH2mXZ6x2jg@mail.gmail.com>
2014-11-05 14:04     ` Juerg Haefliger
2014-11-05 14:27     ` Steven Rostedt
2014-11-05 14:43       ` Juerg Haefliger
2014-11-05 15:00         ` Steven Rostedt
2014-11-05 15:35           ` Harry van Haaren
2014-11-05 15:44           ` Mike Galbraith
2014-11-05 16:07             ` Thomas Gleixner
2014-11-05 16:07       ` Thomas Gleixner
2014-11-05 22:29         ` Thomas Gleixner
2014-11-05 22:48           ` Steven Rostedt
2014-11-05 23:11             ` Thomas Gleixner
     [not found] ` <1414910967.5380.81.camel@marge.simpson.net>
2014-11-02  7:30   ` Mike Galbraith [this message]
2014-11-02  7:31   ` 3.14.23-rt20 - wwmutex: fix __ww_mutex_lock_interruptible lockdep annotation Mike Galbraith
2014-11-02  7:31   ` 3.14.23-rt20 - mm,memcg: make refill_stock()/consume_stock() use get_cpu_light() Mike Galbraith
2014-11-02  7:31   ` 3.14.23-rt20 - fs,btrfs: fix rt deadlock on extent_buffer->lock Mike Galbraith
2015-02-17 11:56     ` Sebastian Andrzej Siewior
2015-02-17 12:23       ` Mike Galbraith
2015-02-18 10:47       ` Mike Galbraith
2014-11-02  7:31   ` 3.14.23-rt20 - aio: fix rcu garbage collection might_sleep() splat Mike Galbraith
2015-02-17 12:53     ` Sebastian Andrzej Siewior
2015-02-17 14:01       ` Mike Galbraith
2014-11-02  7:31   ` 3.14.23-rt20 - x86, UV: raw_spinlock conversion Mike Galbraith
2015-02-17 13:02     ` Sebastian Andrzej Siewior
2015-02-17 14:11       ` Mike Galbraith
2014-11-02  7:31   ` 3.14.23-rt20 - softirq: resurrect softirq threads Mike Galbraith
2015-02-17 13:05     ` Sebastian Andrzej Siewior
2015-02-17 14:00       ` Mike Galbraith

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=1414913451.5380.111.camel@marge.simpson.net \
    --to=umgwanakikbuti@gmail.com \
    --cc=C.Emde@osadl.org \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /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