Re: [PATCH 0/5] ftrace: to kill a daemon

From: Steven Rostedt
Date: Sat Aug 09 2008 - 11:37:36 EST



On Sat, 9 Aug 2008, Abhishek Sagar wrote:

> On Sat, Aug 9, 2008 at 6:31 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > Dynamically modifying text that might be in the pipeline on another CPU
> > may or may not be dangerous on all archs.
>
> Kprobes leaves this mess for individual archs to handle (see
> arch_arm_kprobe). What would be nice to have is an explanation as to
> which archs are safe from this and under what conditions. Also, for
> !SMP, this boot-time patching approach and the associated build time
> paraphernalia would simply be a bloat. There we can simply have a
> daemonless ftrace which patches mcount sites synchronously. Why not
> let each arch have this hinge on CONFIG_SMP?

One of the things I tried to do was to make ftrace port easily to all
archs. David Miller ported it to Sparc64 in 20 minutes and that was mostly
compiling. Doing a kprobe fix would require much more knowledge to each
arch and more prone to errors.

>
> > The fix here is to convert the mcount calls to nops at boot up. This is
> > really ideal on all archs. This means we know ever mcount call, and we get
> > rid of the requirement that we need to run the code once before we can
> > trace it.
>
> This solution indeed would fit all archs well but for some it may be
> an overkill (or is it?...I'd like to know that :-\ ).

It is not an issue at all. The mcount list is discarded with the init
section, and the change to nops is relatively fast. We do make a list of
all entries anyway, so that we can pick and choose which functions we want
to enable tracing on.

This recording at boot up should be fine on all archs, SMP or UP and will
get rid of that daemon.

>
> Oh and as you pointed out, it would mean that we have to no longer run
> the code before starting to trace it. But why don't we do that now?
> How about calling the tracer from ftrace_record_ip? All we need to do
> is pass along the parent_ip from mcount.

I want ftrace_record_ip to be as fast as possible, and also having it call
the registered function means we need to test if it was set in the filter
too. This is too much for what record_ip does. And as I said, doing it all
on boot up would be best.

>
> > The kstop_machine is now only left at the start and stop of tracing.
>
> This a nice fix. I'm just looking to find out what the self modifying
> code problem here translates to on different archs for my own
> understanding :-)


Now, what I can do, is remove the kstop machine from UP. Hmm, I need to
check if kstop_machine code itself is smart enough to simply do a
local_irq_save; run function; local_irq_restore, if it was on UP and not
SMP.

-- Steve

--
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/