Re: [PATCH] perf_events: improve x86 event scheduling

From: Stephane Eranian
Date: Sun Jan 17 2010 - 16:53:58 EST


hi,

Will repost a new version of the patch with these changes.

On Sun, Jan 17, 2010 at 5:19 PM, Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
> On Sun, Jan 17, 2010 at 03:42:16PM +0100, Stephane Eranian wrote:
>> Frederic,
>>
>>
>> Here is what I have now in the x86 code.
>>
>> As for your comment on disabling the x86 event, we don't
>> need to do this because it is not actually activated yet when
>> we return from hw_perf_group_sched_in(). Activation occurs
>> really in hw_perf_enable().
>
>
> Ah, indeed.
>
>
>>
>>
>> static int x86_event_sched_in(struct perf_event *event,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â struct perf_cpu_context *cpuctx, int cpu)
>> {
>> Â Â Â Â int ret = 0;
>>
>> Â Â Â Â event->state = PERF_EVENT_STATE_ACTIVE;
>> Â Â Â Â event->oncpu = cpu;
>> Â Â Â Â event->tstamp_running += event->ctx->time - event->tstamp_stopped;
>>
>> Â Â Â Â if (is_software_event(event))
>> Â Â Â Â Â Â Â Â ret = event->pmu->enable(event);
>>
>> Â Â Â Â if (!ret && !is_software_event(event))
>> Â Â Â Â Â Â Â Â cpuctx->active_oncpu++;
>>
>> Â Â Â Â if (!ret && event->attr.exclusive)
>> Â Â Â Â Â Â Â Â cpuctx->exclusive = 1;
>>
>> Â Â Â Â return ret;
>> }
>>
>> static void x86_event_sched_out(struct perf_event *event,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct perf_cpu_context *cpuctx, int cpu)
>> {
>> Â Â Â Â event->state = PERF_EVENT_STATE_INACTIVE;
>> Â Â Â Â event->oncpu = -1;
>>
>> Â Â Â Â event->tstamp_running -= event->ctx->time - event->tstamp_stopped;
>>
>> Â Â Â Â if (is_software_event(event))
>> Â Â Â Â Â Â Â Â event->pmu->disable(event);
>>
>> Â Â Â Â if (!is_software_event(event))
>> Â Â Â Â Â Â Â Â cpuctx->active_oncpu--;
>>
>> Â Â Â Â if (event->attr.exclusive || !cpuctx->active_oncpu)
>> Â Â Â Â Â Â Â Â cpuctx->exclusive = 0;
>> }
>
>
>
> Yeah looks good.
>
> Thanks.
>
>



--
Stephane Eranian | EMEA Software Engineering
Google France | 38 avenue de l'OpÃra | 75002 Paris
Tel : +33 (0) 1 42 68 53 00
This email may be confidential or privileged. If you received this
communication by mistake, please
don't forward it to anyone else, please erase all copies and
attachments, and please let me know that
it went to the wrong person. Thanks
--
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/