Re: [PATCH V5 03/13] perf: Allow pmu to choose cpu on which toinstall event

From: Stephane Eranian
Date: Tue Jun 12 2012 - 06:17:30 EST


On Tue, Jun 12, 2012 at 7:37 AM, Yan, Zheng <zheng.z.yan@xxxxxxxxx> wrote:
> From: "Yan, Zheng" <zheng.z.yan@xxxxxxxxx>
>
> Allow the pmu->event_init callback to change event->cpu, so pmu can
> choose cpu on which to install event.
>
So now, the user can say perf record -e xxxx -C 1 -a and then get nothing
out of perf report -C1 because under the cover the kernel has swapped
it for another CPU?

> Signed-off-by: Zheng Yan <zheng.z.yan@xxxxxxxxx>
> ---
> Âkernel/events/core.c | Â Â8 ++++----
> Â1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index d71a2d6..2c05027 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6302,7 +6302,7 @@ SYSCALL_DEFINE5(perf_event_open,
> Â Â Â Â/*
> Â Â Â Â * Get the target context (task or percpu):
> Â Â Â Â */
> - Â Â Â ctx = find_get_context(pmu, task, cpu);
> + Â Â Â ctx = find_get_context(pmu, task, event->cpu);
> Â Â Â Âif (IS_ERR(ctx)) {
> Â Â Â Â Â Â Â Âerr = PTR_ERR(ctx);
> Â Â Â Â Â Â Â Âgoto err_alloc;
> @@ -6375,16 +6375,16 @@ SYSCALL_DEFINE5(perf_event_open,
> Â Â Â Âmutex_lock(&ctx->mutex);
>
> Â Â Â Âif (move_group) {
> - Â Â Â Â Â Â Â perf_install_in_context(ctx, group_leader, cpu);
> + Â Â Â Â Â Â Â perf_install_in_context(ctx, group_leader, event->cpu);
> Â Â Â Â Â Â Â Âget_ctx(ctx);
> Â Â Â Â Â Â Â Âlist_for_each_entry(sibling, &group_leader->sibling_list,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âgroup_entry) {
> - Â Â Â Â Â Â Â Â Â Â Â perf_install_in_context(ctx, sibling, cpu);
> + Â Â Â Â Â Â Â Â Â Â Â perf_install_in_context(ctx, sibling, event->cpu);
> Â Â Â Â Â Â Â Â Â Â Â Âget_ctx(ctx);
> Â Â Â Â Â Â Â Â}
> Â Â Â Â}
>
> - Â Â Â perf_install_in_context(ctx, event, cpu);
> + Â Â Â perf_install_in_context(ctx, event, event->cpu);
> Â Â Â Â++ctx->generation;
> Â Â Â Âperf_unpin_context(ctx);
> Â Â Â Âmutex_unlock(&ctx->mutex);
> --
> 1.7.10.2
>
--
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/