From: Javi Merino <javi.merino@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Dave P Martin <Dave.Martin@arm.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v4 1/3] tracing: Add array printing helpers
Date: Wed, 28 Jan 2015 11:26:09 +0000 [thread overview]
Message-ID: <20150128112609.GA2938@e104805> (raw)
In-Reply-To: <20150127223557.407f3a13@gandalf.local.home>
On Wed, Jan 28, 2015 at 03:35:57AM +0000, Steven Rostedt wrote:
> On Mon, 26 Jan 2015 12:11:49 +0000
> Javi Merino <javi.merino@arm.com> wrote:
>
> > From: Dave Martin <Dave.Martin@arm.com>
> >
> > If a trace event contains an array, there is currently no standard
> > way to format this for text output. Drivers are currently hacking
> > around this by a) local hacks that use the trace_seq functionailty
> > directly, or b) just not printing that information. For fixed size
> > arrays, formatting of the elements can be open-coded, but this gets
> > cumbersome for arrays of non-trivial size.
> >
> > These approaches result in non-standard content of the event format
> > description delivered to userspace, so userland tools needs to be
> > taught to understand and parse each array printing method
> > individually.
> >
> > This patch implements common __print_<type>_array() helpers that
> > tracepoint implementations can use instead of reinventing them. A
> > simple C-style syntax is used to delimit the array and its elements
> > {like,this}.
> >
> > So that the helpers can be used with large static arrays as well as
> > dynamic arrays, they take a pointer and element count: they can be
> > used with __get_dynamic_array() for use with dynamic arrays.
> >
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> > Signed-off-by: Javi Merino <javi.merino@arm.com>
> > ---
> > include/linux/ftrace_event.h | 4 ++++
> > include/trace/ftrace.h | 9 +++++++++
> > kernel/trace/trace_output.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 57 insertions(+)
> >
> > diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
> > index 0bebb5c348b8..5aa4a9269547 100644
> > --- a/include/linux/ftrace_event.h
> > +++ b/include/linux/ftrace_event.h
> > @@ -44,6 +44,10 @@ const char *ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
> > const char *ftrace_print_hex_seq(struct trace_seq *p,
> > const unsigned char *buf, int len);
> >
> > +const char *ftrace_print_array_seq(struct trace_seq *p,
> > + const void *buf, int buf_len,
> > + size_t el_size);
> > +
> > struct trace_iterator;
> > struct trace_event;
> >
> > diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
> > index 139b5067345b..36afd0ed3458 100644
> > --- a/include/trace/ftrace.h
> > +++ b/include/trace/ftrace.h
> > @@ -263,6 +263,14 @@
> > #undef __print_hex
> > #define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len)
> >
> > +#undef __print_array
> > +#define __print_array(array, count, el_size) \
> > + ({ \
> > + BUILD_BUG_ON(el_size != 8 && el_size != 16 && \
> > + el_size != 32 && el_size != 64); \
>
> I tried testing this patch by writing a print_array myself, and I kept
> hitting this BUILD_BUG_ON, and was wondering WTF? Then it dawned on me.
>
> el_size should not be based on bits, it should be based on bytes. I
> passed in "sizeof()" which doesn't work with bits.
>
> Please update to "el_size < 1 || el_size > 8".
>
> and adjust the rest accordingly.
Done, I'm testing it now. I'll send a v5 later today.
Cheers,
Javi
next prev parent reply other threads:[~2015-01-28 20:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-26 12:11 [PATCH v4 0/3] Add array printing helpers to ftrace Javi Merino
2015-01-26 12:11 ` [PATCH v4 1/3] tracing: Add array printing helpers Javi Merino
2015-01-28 3:35 ` Steven Rostedt
2015-01-28 11:26 ` Javi Merino [this message]
2015-01-28 12:24 ` Javi Merino
2015-01-28 12:38 ` Steven Rostedt
2015-01-26 12:11 ` [PATCH v4 2/3] tools lib traceevent: factor out allocating and processing args Javi Merino
2015-01-26 12:11 ` [PATCH v4 3/3] tools lib traceevent: Add support for __print_array() Javi Merino
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=20150128112609.GA2938@e104805 \
--to=javi.merino@arm.com \
--cc=Dave.Martin@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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