RE: [PATCH v2 5/5] perf: Enable applicable siblings when groupleader is enable-on-exec

From: Zhu, DengCheng
Date: Wed Nov 23 2011 - 07:41:45 EST




å 2011å11æ23æææäïPeter Zijlstra <a.p.zijlstra@xxxxxxxxx> åéï
> On Wed, 2011-11-23 at 11:38 +0800, Deng-Cheng Zhu wrote:
>
>> + Â Â list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
>> + Â Â Â Â Â Â ret = event_enable_on_exec(event, ctx);
>> + Â Â Â Â Â Â if (ret)
>> + Â Â Â Â Â Â Â Â Â Â enabled = 1;
>> + Â Â }
>> +
>> Â Â Â list_for_each_entry(event, &ctx->pinned_groups, group_entry) {
>> Â Â Â Â Â Â Â ret = event_enable_on_exec(event, ctx);
>> Â Â Â Â Â Â Â if (ret)
>
> This isn't correct either, in this case you should then remove the other
> two iterations of pinned/flexible group lists.
>
> Also your use of list_for_each_entry_rcu() is incorrect, either you then
> should also use rcu_read_lock(), or its not needed and not use the _rcu
> list primitive at all.
>
> Now since event_list is modified under ctx->lock, and we hold that lock
> no fancy stuff is needed and we can do without.

Ah, yes you are right. Thanks. Your following patch looks good except
that event_entry should be used for ctx event_list, rather than group_entry.
Tomorrow I'll test it and get back to you.


Deng-Cheng

> ---
> Subject: perf: Fix enable_on_exec for sibling events
> From: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Date: Tue Nov 22 11:25:43 CET 2011
>
> Deng-Cheng Zhu reported that sibling events that were created disabled
> with enable_on_exec would never get enabled. Iterate all events instead
> of the group lists.
>
> Reported-by: Deng-Cheng Zhu <dczhu@xxxxxxxx>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Link: http://lkml.kernel.org/n/tip-299rxrpmmle8hp3spyxfo202@xxxxxxxxxxxxxx
> ---
> Âkernel/events/core.c | Â Â8 +-------
> Â1 file changed, 1 insertion(+), 7 deletions(-)
>
> Index: linux-2.6/kernel/events/core.c
> ===================================================================
> --- linux-2.6.orig/kernel/events/core.c
> +++ linux-2.6/kernel/events/core.c
> @@ -2494,13 +2494,7 @@ static void perf_event_enable_on_exec(st
> Â Â Â Âraw_spin_lock(&ctx->lock);
> Â Â Â Âtask_ctx_sched_out(ctx);
>
> - Â Â Â list_for_each_entry(event, &ctx->pinned_groups, group_entry) {
> - Â Â Â Â Â Â Â ret = event_enable_on_exec(event, ctx);
> - Â Â Â Â Â Â Â if (ret)
> - Â Â Â Â Â Â Â Â Â Â Â enabled = 1;
> - Â Â Â }
> -
> - Â Â Â list_for_each_entry(event, &ctx->flexible_groups, group_entry) {
> + Â Â Â list_for_each_entry(event, &ctx->event_list, group_entry) {
> Â Â Â Â Â Â Â Âret = event_enable_on_exec(event, ctx);
> Â Â Â Â Â Â Â Âif (ret)
> Â Â Â Â Â Â Â Â Â Â Â Âenabled = 1;
>
> --
> 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/
>èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—