ftrace performance impact with different configuration

Steven Rostedt rostedt at
Fri Dec 30 17:25:41 EST 2011

On Fri, 2011-12-30 at 14:07 +0100, Philippe Rétornaz wrote:

> Sorry about being a bit naive, but why it is not possible to do it in two 
> steps ?
> call stop_machine to put the jmp which skip the call to mcount
> Then wait until all tasks hits schedule() (synchronize_sched() ?)

Here's the problem. With a preemptible kernel, hitting schedule() does
not mean that you can guarantee that all tasks have not been

	nop (use to be push lr)
	------------> interrupt
			end of interrupt

	[ another processes is now running ]
	call stop_machine()
	put in push lr
	call stop_machine()
	put in call to mcount

	everything seems to be running fine.

	the low priority task gets scheduled again...

				schedule() finishes
			preempt_schedule() finishes
			back at tail of return_from_intr in entry_64.S
	call mcount
			pop lr (which was never pushed)
			jmp lr

Now we jump back to some random stuff and the stack is corrupted.

There's no way to safely modify two instructions that depend on each
other in a preemptible kernel, with the exception of waiting for all
CPUs to hit idle (which may never happen on a busy system). And even
that may be racy.

-- Steve

> Then modify both instructions to put in place the two nops since we know that 
> nobody is calling mcount.

More information about the linux-arm-kernel mailing list