Re: [PATCH V5 09/12] perf: make events stream always parsable

From: Adrian Hunter
Date: Fri Jul 12 2013 - 02:36:00 EST


On 11/07/13 18:43, David Ahern wrote:
> On 7/11/13 7:12 AM, Adrian Hunter wrote:
>> The event stream is not always parsable because the format of a sample
>> is dependent on the sample_type of the selected event. When there
>> is more than one selected event and the sample_types are not the
>> same then parsing becomes problematic. A sample can be matched to its
>> selected event using the ID that is allocated when the event is opened.
>> Unfortunately, to get the ID from the sample means first parsing it.
>
> Here's an alternative suggestion -- one that does not involve changing the
> kernel API or requiring a common denominator in sample_type options.

The kernel API is designed to be extensible. Extending it in a way that is
perhaps unexpected but nevertheless backward compatible, is an appropriate
solution.

>
> perf handles event streams through an mmap which can be directly tied to an
> evsel (a single event) when the mmap is created. ie., when events are read
> we know exactly which evsel they correspond to. (See
> perf_evlist__mmap_per_cpu and perf_evlist__mmap_per_thread and add struct
> perf_evsel *evsel entry to struct perf_mmap).
>
> Commands like perf-record can inject a user event into the stream and hence
> the data file every time the evsel changes while walking all of the mmap's
> reading events -- very similar to the way finished round is done. The event
> would only contain a perf_event_header which is 8 bytes so this does not add
> a lot to a data file. As an optimization the evsel event could only be
> injected if the sample_types differ.
>
> Live commands would just use the evsel connected to the mmap -- no lookups
> needed which would simplify things a bit processing the events.
>
> In short, the information to associate event streams to an event (evsel) is
> currently available -- it's just being discarded in the many layers.
>
> I'll try to whip up some code that implements this in the next few days.
>
> David
>
>
>

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