Re: [PATCH 2/2] x86: Make the x86-64 stacktrace code safely callablefrom scheduler

From: Ingo Molnar
Date: Thu May 12 2011 - 17:28:21 EST



* Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:

> Avoid potential scheduler recursion and deadlock from the
> stacktrace code by avoiding rescheduling when we re-enable
> preemption.
>
> This robustifies some scheduler trace events like sched switch
> when they are used to produce callchains in perf or ftrace.

> - put_cpu();
> +
> + /* We want stacktrace to be computable anywhere, even in the scheduler */
> + preempt_enable_no_resched();

So what happens if a callchain profiling happens to be interrupted by a hardirq
and the interrupt reschedules the current task? We'll miss the reschedule,
right?

preempt_enable_no_resched() is not a magic 'solve scheduler recursions' bullet
- it's to be used only if something else will guarantee the preemption check!
But nothing guarantees it here AFAICS.

A better fix would be to use local_irq_save()/restore().

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/