public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Steven Rostedt <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	eric.dumazet@gmail.com, torvalds@linux-foundation.org,
	peterz@infradead.org, umgwanakikbuti@gmail.com,
	rostedt@goodmis.org, tglx@linutronix.de
Subject: [tip:sched/urgent] sched/numa: Fix use of spin_{un}lock_irq() when interrupts are disabled
Date: Thu, 5 Jun 2014 07:33:25 -0700	[thread overview]
Message-ID: <tip-e9dd685ce81815811fb4da72e6ab10a694ac8468@git.kernel.org> (raw)
In-Reply-To: <20140527182541.GH11096@twins.programming.kicks-ass.net>

Commit-ID:  e9dd685ce81815811fb4da72e6ab10a694ac8468
Gitweb:     http://git.kernel.org/tip/e9dd685ce81815811fb4da72e6ab10a694ac8468
Author:     Steven Rostedt <rostedt@goodmis.org>
AuthorDate: Tue, 27 May 2014 17:02:04 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Jun 2014 11:07:41 +0200

sched/numa: Fix use of spin_{un}lock_irq() when interrupts are disabled

As Peter Zijlstra told me, we have the following path:

do_exit()
  exit_itimers()
    itimer_delete()
      spin_lock_irqsave(&timer->it_lock, &flags);
      timer_delete_hook(timer);
        kc->timer_del(timer) := posix_cpu_timer_del()
          put_task_struct()
            __put_task_struct()
              task_numa_free()
                spin_lock(&grp->lock);

Which means that task_numa_free() can be called with interrupts
disabled, which means that we should not be using spin_lock_irq() but
spin_lock_irqsave() instead. Otherwise we are enabling interrupts while
holding an interrupt unsafe lock!

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner<tglx@linutronix.de>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140527182541.GH11096@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/fair.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0fdb96d..b4768c0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1707,18 +1707,19 @@ no_join:
 void task_numa_free(struct task_struct *p)
 {
 	struct numa_group *grp = p->numa_group;
-	int i;
 	void *numa_faults = p->numa_faults_memory;
+	unsigned long flags;
+	int i;
 
 	if (grp) {
-		spin_lock_irq(&grp->lock);
+		spin_lock_irqsave(&grp->lock, flags);
 		for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++)
 			grp->faults[i] -= p->numa_faults_memory[i];
 		grp->total_faults -= p->total_numa_faults;
 
 		list_del(&p->numa_entry);
 		grp->nr_tasks--;
-		spin_unlock_irq(&grp->lock);
+		spin_unlock_irqrestore(&grp->lock, flags);
 		rcu_assign_pointer(p->numa_group, NULL);
 		put_numa_group(grp);
 	}

      parent reply	other threads:[~2014-06-05 14:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09 18:12 [ANNOUNCE] 3.14.3-rt5 Sebastian Andrzej Siewior
2014-05-09 22:54 ` Pavel Vasilyev
2014-05-13 15:33   ` Sebastian Andrzej Siewior
2014-05-10  4:15 ` Mike Galbraith
2014-05-13 15:40   ` Sebastian Andrzej Siewior
2014-05-14  3:10     ` Mike Galbraith
2014-05-16 13:53     ` [patch] rt/sched: fix resursion when CONTEXT_TRACKING and PREEMPT_LAZY are enabled Mike Galbraith
2014-05-25  8:16       ` [patch v2] " Mike Galbraith
2014-05-13 13:30 ` [ANNOUNCE] 3.14.3-rt5 Juri Lelli
2015-02-16 11:29   ` Sebastian Andrzej Siewior
2015-02-16 12:34     ` Juri Lelli
     [not found] ` <1400297819.9493.11.camel@marge.simpson.net>
2014-05-27 18:18   ` [PATCH 3.14-rt] sched/numa: Fix task_numa_free() lockdep splat Steven Rostedt
2014-05-27 18:25     ` Peter Zijlstra
2014-05-27 18:52       ` Steven Rostedt
2014-05-27 18:53         ` Steven Rostedt
2014-06-05 14:33       ` tip-bot for Steven Rostedt [this message]

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=tip-e9dd685ce81815811fb4da72e6ab10a694ac8468@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=eric.dumazet@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=umgwanakikbuti@gmail.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