* [PATCH] perf_events: fix ordering bug in perf_output_sample()
@ 2010-03-18 12:42 Stephane Eranian
2010-03-18 18:33 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2010-03-18 12:42 UTC (permalink / raw)
To: linux-kernel
Cc: peterz, mingo, paulus, davem, fweisbec, robert.richter,
perfmon2-devel, eranian, eranian
In order to parse a sample correctly based on the information
requested via sample_type, the kernel needs to save each component
in a known order. There is no type value saved with each component.
The current convention is that each component is saved according to
the order in enum perf_event_sample_format. But perf_output_sample()
was not completely following this convention, thereby making samples
impossible to parse without internal kernel knowledge.
This patch puts things in the right order.
Signed-off-by: Stephane Eranian <eranian@google.com>
--
perf_event.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 455393e..b35df1d 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -3167,18 +3167,6 @@ void perf_output_sample(struct perf_output_handle *handle,
if (sample_type & PERF_SAMPLE_ADDR)
perf_output_put(handle, data->addr);
- if (sample_type & PERF_SAMPLE_ID)
- perf_output_put(handle, data->id);
-
- if (sample_type & PERF_SAMPLE_STREAM_ID)
- perf_output_put(handle, data->stream_id);
-
- if (sample_type & PERF_SAMPLE_CPU)
- perf_output_put(handle, data->cpu_entry);
-
- if (sample_type & PERF_SAMPLE_PERIOD)
- perf_output_put(handle, data->period);
-
if (sample_type & PERF_SAMPLE_READ)
perf_output_read(handle, event);
@@ -3198,6 +3186,18 @@ void perf_output_sample(struct perf_output_handle *handle,
}
}
+ if (sample_type & PERF_SAMPLE_ID)
+ perf_output_put(handle, data->id);
+
+ if (sample_type & PERF_SAMPLE_CPU)
+ perf_output_put(handle, data->cpu_entry);
+
+ if (sample_type & PERF_SAMPLE_STREAM_ID)
+ perf_output_put(handle, data->stream_id);
+
+ if (sample_type & PERF_SAMPLE_PERIOD)
+ perf_output_put(handle, data->period);
+
if (sample_type & PERF_SAMPLE_RAW) {
if (data->raw) {
perf_output_put(handle, data->raw->size);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] perf_events: fix ordering bug in perf_output_sample()
2010-03-18 12:42 [PATCH] perf_events: fix ordering bug in perf_output_sample() Stephane Eranian
@ 2010-03-18 18:33 ` Peter Zijlstra
2010-03-18 21:29 ` Stephane Eranian
0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2010-03-18 18:33 UTC (permalink / raw)
To: eranian
Cc: linux-kernel, mingo, paulus, davem, fweisbec, robert.richter,
perfmon2-devel, eranian
On Thu, 2010-03-18 at 14:42 +0200, Stephane Eranian wrote:
> In order to parse a sample correctly based on the information
> requested via sample_type, the kernel needs to save each component
> in a known order. There is no type value saved with each component.
> The current convention is that each component is saved according to
> the order in enum perf_event_sample_format. But perf_output_sample()
> was not completely following this convention, thereby making samples
> impossible to parse without internal kernel knowledge.
>
> This patch puts things in the right order.
NAK, not so actually, its in the order specified in the
PERF_RECORD_SAMPLE comment.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf_events: fix ordering bug in perf_output_sample()
2010-03-18 18:33 ` Peter Zijlstra
@ 2010-03-18 21:29 ` Stephane Eranian
2010-03-19 0:14 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2010-03-18 21:29 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, mingo, paulus, davem, fweisbec, robert.richter,
perfmon2-devel, eranian
On Thu, Mar 18, 2010 at 7:33 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, 2010-03-18 at 14:42 +0200, Stephane Eranian wrote:
>> In order to parse a sample correctly based on the information
>> requested via sample_type, the kernel needs to save each component
>> in a known order. There is no type value saved with each component.
>> The current convention is that each component is saved according to
>> the order in enum perf_event_sample_format. But perf_output_sample()
>> was not completely following this convention, thereby making samples
>> impossible to parse without internal kernel knowledge.
>>
>> This patch puts things in the right order.
>
> NAK, not so actually, its in the order specified in the
> PERF_RECORD_SAMPLE comment.
>
And why is that order different than the one in the enum?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf_events: fix ordering bug in perf_output_sample()
2010-03-18 21:29 ` Stephane Eranian
@ 2010-03-19 0:14 ` Peter Zijlstra
0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2010-03-19 0:14 UTC (permalink / raw)
To: Stephane Eranian
Cc: linux-kernel, mingo, paulus, davem, fweisbec, robert.richter,
perfmon2-devel, eranian
On Thu, 2010-03-18 at 22:29 +0100, Stephane Eranian wrote:
> On Thu, Mar 18, 2010 at 7:33 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, 2010-03-18 at 14:42 +0200, Stephane Eranian wrote:
> >> In order to parse a sample correctly based on the information
> >> requested via sample_type, the kernel needs to save each component
> >> in a known order. There is no type value saved with each component.
> >> The current convention is that each component is saved according to
> >> the order in enum perf_event_sample_format. But perf_output_sample()
> >> was not completely following this convention, thereby making samples
> >> impossible to parse without internal kernel knowledge.
> >>
> >> This patch puts things in the right order.
> >
> > NAK, not so actually, its in the order specified in the
> > PERF_RECORD_SAMPLE comment.
> >
> And why is that order different than the one in the enum?
Because I tried to keep the simple elements before the complex ones, but
in any case its too late to change any ordering there now, as its ABI.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-19 0:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 12:42 [PATCH] perf_events: fix ordering bug in perf_output_sample() Stephane Eranian
2010-03-18 18:33 ` Peter Zijlstra
2010-03-18 21:29 ` Stephane Eranian
2010-03-19 0:14 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox