Re: [RFC][PATCH] perf_events: added new start/stop PMU callbacks

From: Stephane Eranian
Date: Mon Feb 08 2010 - 12:21:54 EST


On Mon, Feb 8, 2010 at 5:30 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Mon, 2010-02-08 at 17:06 +0200, Stephane Eranian wrote:
>> Â Â Â In certain situations, the kernel may need to stop and start the
>> Â Â Â same event rapidly. The current PMU callbacks do not distinguish
>> Â Â Â between stop and release Â(i.e., stop + free the resource). Thus,
>> Â Â Â a counter may be released, then it will be immediately re-acquired.
>> Â Â Â Event scheduling will again take place with no guarantee to assign
>> Â Â Â the same counter. On some processors, this may event yield to failure
>> Â Â Â to assign the event back due to competion between cores.
>>
>> Â Â Â This patch is adding a new pair of callback to stop and restart a
>> Â Â Â counter without actually release the underlying counter resource.
>> Â Â Â On stop, the counter is stopped, its values saved and that's it.
>> Â Â Â On start, the value is reloaded and counter is restarted (on x86,
>> Â Â Â actual restart is delayed until perf_enable()).
>>
>> Â Â Â Note this patch does not provide support for non-X86 PMU. This needs
>> Â Â Â to be added.
>>
>> Â Â Â Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
>> --
>
> I think we can do this much easier by adding a list_head to
> hw_perf_event and make event_list into a proper list, then we can remove
> that funny loop on remove and instead move the event to a remove_list
> when there's a put_event_constraint() method and iterate that list on
> hw_perf_enable().

Not sure why it's easier. It saves memory for sure, but that problem
is independent of the issue I was trying to address.

>
> But before we do that, I think we need to look at the /* hardware */
> part of struct hw_perf_event, and make that arch specific, we've been
> growing that a lot lately and I don't think !x86 uses any of that.
>
It is clear it will need to grow much more to host non-counting features.
I have played with that myself a few weeks back. So, yes the saved state
needs to be arch specific.
--
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/