Commit e9dd685ce81815811fb4da72e6ab10a694ac8468
Committed by
Ingo Molnar
1 parent
6acbfb9697
Exists in
ti-lsk-linux-4.1.y
and in
12 other branches
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>
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
kernel/sched/fair.c
... | ... | @@ -1707,18 +1707,19 @@ |
1707 | 1707 | void task_numa_free(struct task_struct *p) |
1708 | 1708 | { |
1709 | 1709 | struct numa_group *grp = p->numa_group; |
1710 | - int i; | |
1711 | 1710 | void *numa_faults = p->numa_faults_memory; |
1711 | + unsigned long flags; | |
1712 | + int i; | |
1712 | 1713 | |
1713 | 1714 | if (grp) { |
1714 | - spin_lock_irq(&grp->lock); | |
1715 | + spin_lock_irqsave(&grp->lock, flags); | |
1715 | 1716 | for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++) |
1716 | 1717 | grp->faults[i] -= p->numa_faults_memory[i]; |
1717 | 1718 | grp->total_faults -= p->total_numa_faults; |
1718 | 1719 | |
1719 | 1720 | list_del(&p->numa_entry); |
1720 | 1721 | grp->nr_tasks--; |
1721 | - spin_unlock_irq(&grp->lock); | |
1722 | + spin_unlock_irqrestore(&grp->lock, flags); | |
1722 | 1723 | rcu_assign_pointer(p->numa_group, NULL); |
1723 | 1724 | put_numa_group(grp); |
1724 | 1725 | } |