Re: [PATCH] perf_event: fix slow and broken cgroup context switch code

From: Stephane Eranian
Date: Thu Aug 25 2011 - 11:03:15 EST


On Thu, Aug 25, 2011 at 4:42 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Thu, 2011-08-25 at 16:36 +0200, Stephane Eranian wrote:
>> On Thu, Aug 25, 2011 at 4:20 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>> > On Thu, 2011-08-25 at 15:58 +0200, Stephane Eranian wrote:
>> >> +static inline void perf_event_task_sched_out(struct task_struct
>> >> *prev,
>> >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct task_struct *next)
>> >> Â{
>> >> Â Â Â Â perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
>> >>
>> >> - Â Â Â __perf_event_task_sched_out(task, next);
>> >> + Â Â Â if (static_branch(&perf_sched_events))
>> >> + Â Â Â Â Â Â Â __perf_event_task_sched_out(prev, next);
>> >> Â}
>> >
>> > Right, so the reason we removed the static branch from there is
>> >
>> > Âlkml.kernel.org/r/20110324164436.GC1930@xxxxxxxxxxxxxxxxxxxx
>> >
>> > now I think the series 075e0b0085 to 64ce312618e should have cured that
>> > problem, and adding the static_branch() is now safe again. But there's
>> > no mention of any of this in the Changelog.
>> >
>> I realized I did not talk about the static_branch() change after I had
>> clicked on
>> Send. But to me, this looks natural to have the static branch in the ctxsw out
>> routine. This has to be symmetrical with ctxsw in . The static branch is about
>> avoiding perf ctxsw when there is no need for it, i.e., no per-thread
>> nor per-cgroup
>> events.
>
> Yeah, that argument is what got us into trouble initially :) But I think
> its ok now, we'll see if stuff explodes or not..
>
I just ran that crash test you pointed out and so far so good. Don't know if
the crash was systematic, though.
--
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/