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

From: Peter Zijlstra
Date: Wed Nov 23 2011 - 06:40:06 EST


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.

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