Skip to content

Commit e9dd685

Browse files
rostedtIngo Molnar
authored andcommitted
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>
1 parent 6acbfb9 commit e9dd685

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/sched/fair.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,18 +1707,19 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags,
17071707
void task_numa_free(struct task_struct *p)
17081708
{
17091709
struct numa_group *grp = p->numa_group;
1710-
int i;
17111710
void *numa_faults = p->numa_faults_memory;
1711+
unsigned long flags;
1712+
int i;
17121713

17131714
if (grp) {
1714-
spin_lock_irq(&grp->lock);
1715+
spin_lock_irqsave(&grp->lock, flags);
17151716
for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++)
17161717
grp->faults[i] -= p->numa_faults_memory[i];
17171718
grp->total_faults -= p->total_numa_faults;
17181719

17191720
list_del(&p->numa_entry);
17201721
grp->nr_tasks--;
1721-
spin_unlock_irq(&grp->lock);
1722+
spin_unlock_irqrestore(&grp->lock, flags);
17221723
rcu_assign_pointer(p->numa_group, NULL);
17231724
put_numa_group(grp);
17241725
}

0 commit comments

Comments
 (0)