All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH perf 2/2] perf: trace-event-parse: support printing short fields
  2011-03-10 22:55 David Sharp
@ 2011-03-10 22:55 ` David Sharp
  0 siblings, 0 replies; 8+ messages in thread
From: David Sharp @ 2011-03-10 22:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: David Sharp, Steven Rostedt, Ingo Molnar, Stephane Eranian

Handle "%hd" etc. in pretty_print()

Signed-off-by: David Sharp <dhsharp@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/trace-event-parse.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 67fe01a..0cf4366 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -2534,6 +2534,9 @@ static void pretty_print(void *data, int size, struct event *event)
 			case '%':
 				printf("%%");
 				break;
+			case 'h':
+				ls--;
+				goto cont_process;
 			case 'l':
 				ls++;
 				goto cont_process;
@@ -2589,6 +2592,12 @@ static void pretty_print(void *data, int size, struct event *event)
 					}
 				}
 				switch (ls) {
+				case -2:
+					printf(format, (char)val);
+					break;
+				case -1:
+					printf(format, (short)val);
+					break;
 				case 0:
 					printf(format, (int)val);
 					break;
-- 
1.7.3.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats
@ 2011-03-21 22:34 David Sharp
  2011-03-21 22:34 ` [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!=' David Sharp
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Sharp @ 2011-03-21 22:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: mrubin, David Sharp, Arnaldo Carvalho de Melo,
	Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Stephane Eranian

These patches correspond to similar patches recently applied to trace-cmd

[ Re-sending with more Cc's ]

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Stephane Eranian <eranian@google.com>


David Sharp (2):
  perf: trace-event-parse: support additional operators: '!', '~',  and
    '!='
  perf: trace-event-parse: support printing short fields

 tools/perf/util/trace-event-parse.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

-- 
1.7.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~',  and '!='
  2011-03-21 22:34 [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
@ 2011-03-21 22:34 ` David Sharp
  2011-03-21 22:34 ` [PATCH perf 2/2] perf: trace-event-parse: support printing short fields David Sharp
  2011-04-07  2:01 ` [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
  2 siblings, 0 replies; 8+ messages in thread
From: David Sharp @ 2011-03-21 22:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: mrubin, David Sharp, Arnaldo Carvalho de Melo,
	Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Stephane Eranian

Add support for the unary operators '!' and '~', and support '!=' so that
it is differentiated from '!'.

Signed-off-by: David Sharp <dhsharp@google.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/trace-event-parse.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 73a0222..67fe01a 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1107,6 +1107,9 @@ static int get_op_prio(char *op)
 {
 	if (!op[1]) {
 		switch (op[0]) {
+		case '~':
+		case '!':
+			return 4;
 		case '*':
 		case '/':
 		case '%':
@@ -1184,6 +1187,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok)
 			return EVENT_ERROR;
 		}
 		switch (token[0]) {
+		case '~':
 		case '!':
 		case '+':
 		case '-':
@@ -2109,6 +2113,21 @@ static unsigned long long eval_num_arg(void *data, int size,
 		left = eval_num_arg(data, size, event, arg->op.left);
 		right = eval_num_arg(data, size, event, arg->op.right);
 		switch (arg->op.op[0]) {
+		case '!':
+			switch (arg->op.op[1]) {
+			case 0:
+				val = !right;
+				break;
+			case '=':
+				val = left != right;
+				break;
+			default:
+				die("unknown op '%s'", arg->op.op);
+			}
+			break;
+		case '~':
+			val = ~right;
+			break;
 		case '|':
 			if (arg->op.op[1])
 				val = left || right;
-- 
1.7.3.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH perf 2/2] perf: trace-event-parse: support printing short fields
  2011-03-21 22:34 [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
  2011-03-21 22:34 ` [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!=' David Sharp
@ 2011-03-21 22:34 ` David Sharp
  2011-04-07  2:01 ` [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
  2 siblings, 0 replies; 8+ messages in thread
From: David Sharp @ 2011-03-21 22:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: mrubin, David Sharp, Arnaldo Carvalho de Melo,
	Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Stephane Eranian

Handle "%hd" etc. in pretty_print()

Signed-off-by: David Sharp <dhsharp@google.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/trace-event-parse.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 67fe01a..0cf4366 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -2534,6 +2534,9 @@ static void pretty_print(void *data, int size, struct event *event)
 			case '%':
 				printf("%%");
 				break;
+			case 'h':
+				ls--;
+				goto cont_process;
 			case 'l':
 				ls++;
 				goto cont_process;
@@ -2589,6 +2592,12 @@ static void pretty_print(void *data, int size, struct event *event)
 					}
 				}
 				switch (ls) {
+				case -2:
+					printf(format, (char)val);
+					break;
+				case -1:
+					printf(format, (short)val);
+					break;
 				case 0:
 					printf(format, (int)val);
 					break;
-- 
1.7.3.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats
  2011-03-21 22:34 [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
  2011-03-21 22:34 ` [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!=' David Sharp
  2011-03-21 22:34 ` [PATCH perf 2/2] perf: trace-event-parse: support printing short fields David Sharp
@ 2011-04-07  2:01 ` David Sharp
  2011-04-07 14:26   ` Frederic Weisbecker
  2 siblings, 1 reply; 8+ messages in thread
From: David Sharp @ 2011-04-07  2:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: mrubin, David Sharp, Arnaldo Carvalho de Melo,
	Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Stephane Eranian

Hi, any feedback on these patches? I think it's important that perf
and trace-cmd don't drift in the syntax they accept.

d#

On Mon, Mar 21, 2011 at 3:34 PM, David Sharp <dhsharp@google.com> wrote:
> These patches correspond to similar patches recently applied to trace-cmd
>
> [ Re-sending with more Cc's ]
>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Stephane Eranian <eranian@google.com>
>
>
> David Sharp (2):
>  perf: trace-event-parse: support additional operators: '!', '~',  and
>    '!='
>  perf: trace-event-parse: support printing short fields
>
>  tools/perf/util/trace-event-parse.c |   28 ++++++++++++++++++++++++++++
>  1 files changed, 28 insertions(+), 0 deletions(-)
>
> --
> 1.7.3.1
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats
  2011-04-07  2:01 ` [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
@ 2011-04-07 14:26   ` Frederic Weisbecker
  2011-04-07 20:25     ` David Sharp
  0 siblings, 1 reply; 8+ messages in thread
From: Frederic Weisbecker @ 2011-04-07 14:26 UTC (permalink / raw)
  To: David Sharp
  Cc: linux-kernel, mrubin, Arnaldo Carvalho de Melo, Steven Rostedt,
	Ingo Molnar, Stephane Eranian

On Wed, Apr 06, 2011 at 07:01:40PM -0700, David Sharp wrote:
> Hi, any feedback on these patches? I think it's important that perf
> and trace-cmd don't drift in the syntax they accept.
> 
> d#

Sorry, I forgot these.
 
> On Mon, Mar 21, 2011 at 3:34 PM, David Sharp <dhsharp@google.com> wrote:
> > These patches correspond to similar patches recently applied to trace-cmd
> >
> > [ Re-sending with more Cc's ]
> >
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Ingo Molnar <mingo@elte.hu>
> > Cc: Stephane Eranian <eranian@google.com>
> >
> >
> > David Sharp (2):
> >  perf: trace-event-parse: support additional operators: '!', '~',  and
> >    '!='
> >  perf: trace-event-parse: support printing short fields

So we now have trace events that use these new operations? Which ones?
A quick grep on "TP_printk" and "!" doesn't give me any result, probably
because TP_printk is often multiline.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats
  2011-04-07 14:26   ` Frederic Weisbecker
@ 2011-04-07 20:25     ` David Sharp
  2011-04-07 21:57       ` Frederic Weisbecker
  0 siblings, 1 reply; 8+ messages in thread
From: David Sharp @ 2011-04-07 20:25 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: linux-kernel, mrubin, Arnaldo Carvalho de Melo, Steven Rostedt,
	Ingo Molnar, Stephane Eranian

On Thu, Apr 7, 2011 at 7:26 AM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> On Wed, Apr 06, 2011 at 07:01:40PM -0700, David Sharp wrote:
>> Hi, any feedback on these patches? I think it's important that perf
>> and trace-cmd don't drift in the syntax they accept.
>>
>> d#
>
> Sorry, I forgot these.
>
>> On Mon, Mar 21, 2011 at 3:34 PM, David Sharp <dhsharp@google.com> wrote:
>> > These patches correspond to similar patches recently applied to trace-cmd
>> >
>> > [ Re-sending with more Cc's ]
>> >
>> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
>> > Cc: Steven Rostedt <rostedt@goodmis.org>
>> > Cc: Ingo Molnar <mingo@elte.hu>
>> > Cc: Stephane Eranian <eranian@google.com>
>> >
>> >
>> > David Sharp (2):
>> >  perf: trace-event-parse: support additional operators: '!', '~',  and
>> >    '!='
>> >  perf: trace-event-parse: support printing short fields
>
> So we now have trace events that use these new operations? Which ones?
> A quick grep on "TP_printk" and "!" doesn't give me any result, probably
> because TP_printk is often multiline.
>

We (google) have some events that use '~' and '!', and I threw in '!='
mostly because it needed to be differentiated from '!' during
tokenizing.

We set the MSB of the syscall number in raw_syscalls events to
indicate a compat syscall, and use '~' and '!' (and '&' and '>>') to
extract the bit. eg, for sys_exit:
print fmt: "NR %ld = %ld isCompat: %d", REC->id & (~0UL>>1), REC->ret,
!!(REC->id & ~(~0UL>>1))
Patches for this will be forthcoming, but, you know: time.

If our internally-added events are not sufficient reason, I think it
still makes sense to support as much of the C expression syntax as
reasonable. Leaving holes in the syntax mostly just causes frustration
when these operators would be useful. And since they do work with the
in-kernel output (which has the whole compiler to leverage), use of
unsupported operators can go unnoticed for quite a while.

Thanks,
d#

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats
  2011-04-07 20:25     ` David Sharp
@ 2011-04-07 21:57       ` Frederic Weisbecker
  0 siblings, 0 replies; 8+ messages in thread
From: Frederic Weisbecker @ 2011-04-07 21:57 UTC (permalink / raw)
  To: David Sharp
  Cc: linux-kernel, mrubin, Arnaldo Carvalho de Melo, Steven Rostedt,
	Ingo Molnar, Stephane Eranian

On Thu, Apr 07, 2011 at 01:25:04PM -0700, David Sharp wrote:
> On Thu, Apr 7, 2011 at 7:26 AM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Wed, Apr 06, 2011 at 07:01:40PM -0700, David Sharp wrote:
> >> Hi, any feedback on these patches? I think it's important that perf
> >> and trace-cmd don't drift in the syntax they accept.
> >>
> >> d#
> >
> > Sorry, I forgot these.
> >
> >> On Mon, Mar 21, 2011 at 3:34 PM, David Sharp <dhsharp@google.com> wrote:
> >> > These patches correspond to similar patches recently applied to trace-cmd
> >> >
> >> > [ Re-sending with more Cc's ]
> >> >
> >> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> >> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> >> > Cc: Steven Rostedt <rostedt@goodmis.org>
> >> > Cc: Ingo Molnar <mingo@elte.hu>
> >> > Cc: Stephane Eranian <eranian@google.com>
> >> >
> >> >
> >> > David Sharp (2):
> >> >  perf: trace-event-parse: support additional operators: '!', '~',  and
> >> >    '!='
> >> >  perf: trace-event-parse: support printing short fields
> >
> > So we now have trace events that use these new operations? Which ones?
> > A quick grep on "TP_printk" and "!" doesn't give me any result, probably
> > because TP_printk is often multiline.
> >
> 
> We (google) have some events that use '~' and '!', and I threw in '!='
> mostly because it needed to be differentiated from '!' during
> tokenizing.
> 
> We set the MSB of the syscall number in raw_syscalls events to
> indicate a compat syscall, and use '~' and '!' (and '&' and '>>') to
> extract the bit. eg, for sys_exit:
> print fmt: "NR %ld = %ld isCompat: %d", REC->id & (~0UL>>1), REC->ret,
> !!(REC->id & ~(~0UL>>1))
> Patches for this will be forthcoming, but, you know: time.

Please consider the compat syscall tracing patches from Jason Baron
and Ian Munsie:

http://lkml.org/lkml/2010/6/23/69

They were pretty clean IIRC. Someone just need to rebase them, clean
up some last things and repost.

> 
> If our internally-added events are not sufficient reason, I think it
> still makes sense to support as much of the C expression syntax as
> reasonable. Leaving holes in the syntax mostly just causes frustration
> when these operators would be useful. And since they do work with the
> in-kernel output (which has the whole compiler to leverage), use of
> unsupported operators can go unnoticed for quite a while.

Hmm, ok.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-07 21:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-21 22:34 [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
2011-03-21 22:34 ` [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!=' David Sharp
2011-03-21 22:34 ` [PATCH perf 2/2] perf: trace-event-parse: support printing short fields David Sharp
2011-04-07  2:01 ` [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
2011-04-07 14:26   ` Frederic Weisbecker
2011-04-07 20:25     ` David Sharp
2011-04-07 21:57       ` Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2011-03-10 22:55 David Sharp
2011-03-10 22:55 ` [PATCH perf 2/2] perf: trace-event-parse: support printing short fields David Sharp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.