Re: [PATCH 3/3] ftrace: add ability to only trace swapper tasks

From: Steven Rostedt
Date: Thu Dec 04 2008 - 09:57:55 EST



On Thu, 4 Dec 2008, Eric W. Biederman wrote:

> Steven Rostedt <rostedt@xxxxxxxxxxx> writes:
> >
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index 10b1d7c..eb57dc1 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -49,6 +49,7 @@ static int last_ftrace_enabled;
> >
> > /* set when tracing only a pid */
> > struct pid *ftrace_pid_trace;
> > +static struct pid * const ftrace_swapper_pid = (struct pid *)1;
>
> The initializer should be spelled &init_struct_pid instead of (struct pid *)1;
>
> Except for the special case of finding this unhashed pid, by making the
> attach_pid(p, PIDTYPE_PID, pid) unconditional in copy_process, you can
> make the rest of the special cases go away.

Not that easy. It turns out that all idle tasks share the init_struct_pid,
and if you add the attach_pid() outside the if statement, you only change
the owner of the init_struct_pid to the last CPU to come on line.

I tried to allocate the pid, but by doing that it seems that the alloc_pid
code will assign a number other than 0. The changes needed to fork.c to
make this work is quickly going beyond a trivial fix, where I do not want
to become a pid container developer in order to implement it.

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