From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 4/3] perf_counter: Correct PERF_SAMPLE_RAW output
Date: Mon, 10 Aug 2009 11:48:16 +0200 [thread overview]
Message-ID: <20090810094815.GB5508@nowhere> (raw)
In-Reply-To: <1249896447.17467.74.camel@twins>
On Mon, Aug 10, 2009 at 11:27:27AM +0200, Peter Zijlstra wrote:
> Subject: perf_counter: Correct PERF_SAMPLE_RAW output
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Date: Mon Aug 10 11:16:52 CEST 2009
>
> PERF_SAMPLE_* output switches should unconditionally output the
> correct format, as they are the only way to unambiguously parse the
> PERF_EVENT_SAMPLE data.
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
I economized this part because I thought ftrace events could
be parsed the same way we parse binary events through debugfs.
The size of an ftrace event can be deduced from its format.
But I must confess that would require a pre-parsing of dynamic
strings.
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> include/linux/perf_counter.h | 2 ++
> include/trace/ftrace.h | 3 ++-
> kernel/perf_counter.c | 30 ++++++++++++++++++++++++------
> 3 files changed, 28 insertions(+), 7 deletions(-)
>
> Index: linux-2.6/include/linux/perf_counter.h
> ===================================================================
> --- linux-2.6.orig/include/linux/perf_counter.h
> +++ linux-2.6/include/linux/perf_counter.h
> @@ -369,6 +369,8 @@ enum perf_event_type {
> *
> * { u64 nr,
> * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN
> + * { u32 size;
> + * char data[size];}&& PERF_SAMPLE_RAW
> * };
> */
> PERF_EVENT_SAMPLE = 9,
> Index: linux-2.6/include/trace/ftrace.h
> ===================================================================
> --- linux-2.6.orig/include/trace/ftrace.h
> +++ linux-2.6/include/trace/ftrace.h
> @@ -687,7 +687,8 @@ static void ftrace_profile_##call(proto)
> pc = preempt_count(); \
> \
> __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
> - __entry_size = ALIGN(__data_size + sizeof(*entry), sizeof(u64));\
> + __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
> + sizeof(u64)); \
> \
> do { \
> char raw_data[__entry_size]; \
> Index: linux-2.6/kernel/perf_counter.c
> ===================================================================
> --- linux-2.6.orig/kernel/perf_counter.c
> +++ linux-2.6/kernel/perf_counter.c
> @@ -2647,7 +2647,6 @@ void perf_counter_output(struct perf_cou
> u64 counter;
> } group_entry;
> struct perf_callchain_entry *callchain = NULL;
> - struct perf_raw_record *raw = NULL;
> int callchain_size = 0;
> u64 time;
> struct {
> @@ -2717,9 +2716,15 @@ void perf_counter_output(struct perf_cou
> }
>
> if (sample_type & PERF_SAMPLE_RAW) {
> - raw = data->raw;
> - if (raw)
> - header.size += raw->size;
> + int size = sizeof(u32);
> +
> + if (data->raw)
> + size += data->raw->size;
> + else
> + size += sizeof(u32);
> +
> + WARN_ON_ONCE(size & (sizeof(u64)-1));
> + header.size += size;
> }
>
> ret = perf_output_begin(&handle, counter, header.size, nmi, 1);
> @@ -2785,8 +2790,21 @@ void perf_counter_output(struct perf_cou
> }
> }
>
> - if ((sample_type & PERF_SAMPLE_RAW) && raw)
> - perf_output_copy(&handle, raw->data, raw->size);
> + if (sample_type & PERF_SAMPLE_RAW) {
> + if (data->raw) {
> + perf_output_put(&handle, data->raw->size);
> + perf_output_copy(&handle, data->raw->data, data->raw->size);
> + } else {
> + struct {
> + u32 size;
> + u32 data;
> + } raw = {
> + .size = sizeof(u32),
> + .data = 0,
> + };
> + perf_output_put(&handle, raw);
> + }
> + }
>
> perf_output_end(&handle);
> }
>
next prev parent reply other threads:[~2009-08-10 9:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 2:26 [PATCH 1/4] perf tools: callchain: Warn only once in empty node detection Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 1/3] perfcounter: Initialize tracepoint record before any use Frederic Weisbecker
2009-08-08 2:30 ` Frederic Weisbecker
2009-08-10 9:27 ` [PATCH 4/3] perf_counter: Correct PERF_SAMPLE_RAW output Peter Zijlstra
2009-08-10 9:36 ` [tip:perfcounters/urgent] " tip-bot for Peter Zijlstra
2009-08-10 9:48 ` Frederic Weisbecker [this message]
2009-08-10 12:57 ` [PATCH 4/3] " Frederic Weisbecker
2009-08-10 13:06 ` Peter Zijlstra
2009-08-10 14:11 ` [PATCH 6/3] perfcounter: Substract the buffer size field from the event record size Frederic Weisbecker
2009-08-10 14:13 ` Peter Zijlstra
2009-08-10 14:21 ` [tip:perfcounters/urgent] perf_counter: Subtract " tip-bot for Frederic Weisbecker
2009-08-10 9:27 ` [PATCH 5/3] perf_counter: Require CAP_SYS_ADMIN for raw tracepoint data Peter Zijlstra
2009-08-10 9:36 ` [tip:perfcounters/urgent] " tip-bot for Peter Zijlstra
2009-08-08 2:26 ` [PATCH 2/4] perf tools: callchain: Ignore empty callchains Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 2/3] perfcounter: Generalize the tracepoint sampling to generic sampling Frederic Weisbecker
2009-08-08 11:52 ` [tip:perfcounters/core] perf_counter: Fix tracepoint sampling to be part of " tip-bot for Frederic Weisbecker
2009-08-09 11:10 ` tip-bot for Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 3/4] perf tools: callchain: Default display callchain from report if recorded with -g Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 3/3] perfcounter: Align ftrace events raw samples to 8 bytes Frederic Weisbecker
2009-08-08 11:52 ` [tip:perfcounters/core] perf_counter: Fix ftrace events raw samples to be aligned " tip-bot for Frederic Weisbecker
2009-08-10 7:13 ` [PATCH 3/3] perfcounter: Align ftrace events raw samples " Peter Zijlstra
2009-08-10 7:32 ` Frederic Weisbecker
2009-08-10 14:38 ` [PATCH 7/3] perfcounter: Zeroe dead bytes from ftrace raw samples size alignment Frederic Weisbecker
2009-08-10 18:01 ` [tip:perfcounters/urgent] perf_counter: Zero " tip-bot for Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 4/4] perf tools: callchain: Display amount of ignored chains in fractal mode Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090810094815.GB5508@nowhere \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox