Skip to contentSkip to conversation

Ftraced always polls once a minute even when no tracer is active

DISCUSSION Theodore Ts'o 2 participants 2 messages Jul 19, 2008

lore
Share & tools
lore
#0 lore raw

I noticed with powertop that ftraced waks up once a second, even if no tracer is active. Is there a reason why the kernel thread can't be suspended in that case?

Thanks, regards,

- Ted

#1 lore raw
Quoted 4 lines · Theodore Ts'o

I noticed with powertop that ftraced waks up once a second, even if no tracer is active. Is there a reason why the kernel thread can't be suspended in that case?

That's for the dynamic tracer. It is actually stopped when a tracer is active ;-)

CONFIG_FTRACE enables the "-pg" option in the kernel compile that enables the mcount profiler. This adds a call to a function called "mcount" at the start of every function. With a simple "ret" from mcount, this still adds up to a 18% overhead.

What the dynamic ftrace does is to have the mcount function call a "register_ip" function, that adds the caller into a hash table if it is not already there.

Once a second the "ftraced" kernel thread wakes up and checks to see if there are any new functions that have been called and recorded. If there has been, it calls kstop_machine and changes the call to mcount into a nop. This keeps the system to a 0% overhead (well, probably not 0% but it is not measurable ;-).

I should add code to stop the kthread when the system is low. I notice that the thread still wakes up but goes to sleep even when ftraced_enabled is zero.

I'm currently traveling and I'm trying to finish up the ftrace tutorial for OLS. I'll have to look more into this when I get back.

Thanks,

-- Steve