Re: [PATCH] perf_counter: cleanup for __perf_event_sched_in()

From: Paul Mackerras
Date: Tue Sep 22 2009 - 23:33:17 EST


Xiao Guangrong writes:

> I only find three places in __perf_event_sched_in/out, could you tell me
> where is the fourth place?

My mistake, it is just those three. I saw the list_for_each_entry_rcu
followed by if (event != event->group_leader) in perf_event_init_task
and missed the fact that it is iterating parent_ctx->event_list rather
than parent_ctx->group_list. But as you point out:

> I also noticed that all group leader is the top level of ctx->group_list,
> if I not missed, the perf_event_init_task() function can be optimized,
> like this:
>
> int perf_event_init_task(struct task_struct *child)
> {
> ......
> /* We can only look at parent_ctx->group_list to get group leader */
> list_for_each_entry_rcu(event, &parent_ctx->event_list, event_entry) {
> if (event != event->group_leader)
> continue;
> ......
> }
> ......
> }

we would in fact be better off using group_list rather than event_list
anyway. That should be safe since we hold parent_ctx->mutex.

> I'll fix those if you are not mind :-)

Please do. :)

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