Re: [PATCH 1/3] perf: add context field to perf_event

Peter Zijlstra
2011-07-12T09:31:24Z

On Tue, 2011-07-12 at 12:27 +0300, Avi Kivity wrote:
> On 07/12/2011 12:18 PM, Peter Zijlstra wrote:
> > >
> > > The guarantee is that the task was sleeping just before the function is
> > > called. Of course it's woken up to run the function.
> > >
> > > The idea is that you run the function in a known safe point to avoid
> > > extra synchronization.
> > >
> >
> > I'd much rather we didn't wake the task and let it sleep, that's usually
> > a very safe place for tasks to be. All you'd need is a guarantee it
> > won't be woken up while you're doing your thing.
>
> But it means that 'current' is not set to the right value. If the
> function depends on it, then it will misbehave. And in fact
> preempt_notifier_register(), which is the function we want to call here,
> does depend on current.
>
> Of course we need to find more users for this, but I have a feeling this
> will be generally useful. The alternative is to keep adding bits to
> thread_info::flags.

Using TIF_bits sounds like a much better solution for this, wakeups are
really rather expensive and its best to avoid extra if at all possible.