Re: [PATCH] perf_events: fix cgrp stale pointer in update_cgrp_time_from_cpuctx()

From: Stephane Eranian
Date: Wed Mar 23 2011 - 08:48:15 EST


On Wed, Mar 23, 2011 at 12:36 PM, Ingo Molnar <mingo@xxxxxxx> wrote:
>
> * Stephane Eranian <eranian@xxxxxxxxxx> wrote:
>
>> - Â Â if (is_cgroup_event(event))
>> + Â Â if (is_cgroup_event(event)) {
>> Â Â Â Â Â Â Â ctx->nr_cgroups--;
>> + Â Â Â Â Â Â cpuctx = __get_cpu_context(ctx);
>> + Â Â Â Â Â Â /*
>> + Â Â Â Â Â Â Â* if there are no more cgroup events
>> + Â Â Â Â Â Â Â* then clear cgrp to avoid stale pointer
>> + Â Â Â Â Â Â Â* in update_cgrp_time_from_cpuctx()
>> + Â Â Â Â Â Â Â*/
>> + Â Â Â Â Â Â if (!ctx->nr_cgroups)
>> + Â Â Â Â Â Â Â Â Â Â cpuctx->cgrp = NULL;
>> + Â Â }
>
> The ->cgrp pointer does not exist on !CGROUPS kernels. I suspect the cleanest
> approach would be to make those two cgrp fields available unconditionally in
> struct perf_event.
>
Argh, I forgot to test !CGROUP.
I tend to agree with you on making those fields unconditional. We
don't save that
much by not doing it.

> Thanks,
>
> Â Â Â ÂIngo
>
--
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/