2012-02-21 17:36:00

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 0/3] perf/core fixes and improvements

The following changes since commit 09bda4432a8a4d4db2b2b94697abc8d732a9ff73:

Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core (2012-02-17 12:55:07 +0100)

are available in the git repository at:


git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf-core-for-mingo

for you to fetch changes up to 6b1bee9035d430c4b4f586df6df4b3f840e89b5b:

perf tools: fix broken perf record -a mode (2012-02-21 15:05:43 -0200)

----------------------------------------------------------------
Important fix from Stephane for system wide monitoring, problem
introduced recently in the pid list patches.

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

----------------------------------------------------------------
Danny Kukawka (1):
perf tools: Remove duplicated string.h includes

Stefan Hajnoczi (1):
perf tools: Allow expressions in __print_symbolic() fields

Stephane Eranian (1):
perf tools: fix broken perf record -a mode

tools/perf/util/probe-event.c | 1 -
tools/perf/util/thread_map.c | 2 +-
tools/perf/util/trace-event-parse.c | 12 ++++++++++++
3 files changed, 13 insertions(+), 2 deletions(-)


2012-02-21 17:35:44

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/3] perf tools: Allow expressions in __print_symbolic() fields

From: Stefan Hajnoczi <[email protected]>

The __print_symbolic() function takes a sequence of key-value pairs for
pretty-printing a constant. The new kvm:kvm_exit print fmt uses the
expression:

__print_symbolic(..., { 0x040 + 1, "DB excp" }, ...)

Currently only atoms are supported and this print fmt fails to parse.
This patch adds support for expressions instead of just atoms so that
0x040 + 1 is parsed successfully. Also add arg_num_eval() support for
the '+' operator.

Acked-by: Steven Rostedt <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/trace-event-parse.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index e0a4f65..a4088ce 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1423,6 +1423,11 @@ static long long arg_num_eval(struct print_arg *arg)
die("unknown op '%s'", arg->op.op);
}
break;
+ case '+':
+ left = arg_num_eval(arg->op.left);
+ right = arg_num_eval(arg->op.right);
+ val = left + right;
+ break;
default:
die("unknown op '%s'", arg->op.op);
}
@@ -1483,6 +1488,13 @@ process_fields(struct event *event, struct print_flag_sym **list, char **tok)

free_token(token);
type = process_arg(event, arg, &token);
+
+ if (type == EVENT_OP)
+ type = process_op(event, arg, &token);
+
+ if (type == EVENT_ERROR)
+ goto out_free;
+
if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;

--
1.7.9.123.g65da0

2012-02-21 17:35:49

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/3] perf tools: fix broken perf record -a mode

From: Stephane Eranian <[email protected]>

The following commit:
b52956c perf tools: Allow multiple threads or processes in record, stat, top

introduced a bug in the thread_map code which caused perf record -a to
not setup system-wide monitoring properly.

$ taskset -c 1 noploop 1000 &
$ perf record -a -C 1 sleep 10
$ perf report -D | tail -20
cycles stats:
TOTAL events: 4413
MMAP events: 4025
COMM events: 340
SAMPLE events: 48

Here I was expecting about 10,000 samples and not 48.

In system-wide mode, the PID passed to perf_event_open() must be -1 and
it was 0. That caused the kernel to setup a per-process event on PID:0.
Consequently, the number of samples captured does not correspond to the
requested measurement.

The following one-liner fixes the problem for me with or without -C.

I would also suggest to change the malloc() to something that matches
the struct definition. thread_map->map[] is declared as int map[] and
not pid_t map[]. If map[] can only contain pids, then change the struct
definition.

Acked-by: David Ahern <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/20120221145424.GA6757@quad
Signed-off-by: Stephane Eranian <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/thread_map.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index e15983c..84d9bd78 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -229,7 +229,7 @@ static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
if (!tid_str) {
threads = malloc(sizeof(*threads) + sizeof(pid_t));
if (threads != NULL) {
- threads->map[1] = -1;
+ threads->map[0] = -1;
threads->nr = 1;
}
return threads;
--
1.7.9.123.g65da0

2012-02-21 17:35:57

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/3] perf tools: Remove duplicated string.h includes

From: Danny Kukawka <[email protected]>

tools/perf/util/probe-event.c included 'string.h' twice, remove the
duplicate.

Acked-by: Masami Hiramatsu <[email protected]>
Cc: Danny Kukawka <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jovi Zhang <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Danny Kukawka <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/probe-event.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index c1a513e..8379252 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -34,7 +34,6 @@

#include "util.h"
#include "event.h"
-#include "string.h"
#include "strlist.h"
#include "debug.h"
#include "cache.h"
--
1.7.9.123.g65da0

2012-02-22 10:12:50

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 0/3] perf/core fixes and improvements


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> The following changes since commit 09bda4432a8a4d4db2b2b94697abc8d732a9ff73:
>
> Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core (2012-02-17 12:55:07 +0100)
>
> are available in the git repository at:
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf-core-for-mingo
>
> for you to fetch changes up to 6b1bee9035d430c4b4f586df6df4b3f840e89b5b:
>
> perf tools: fix broken perf record -a mode (2012-02-21 15:05:43 -0200)
>
> ----------------------------------------------------------------
> Important fix from Stephane for system wide monitoring, problem
> introduced recently in the pid list patches.
>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
>
> ----------------------------------------------------------------
> Danny Kukawka (1):
> perf tools: Remove duplicated string.h includes
>
> Stefan Hajnoczi (1):
> perf tools: Allow expressions in __print_symbolic() fields
>
> Stephane Eranian (1):
> perf tools: fix broken perf record -a mode
>
> tools/perf/util/probe-event.c | 1 -
> tools/perf/util/thread_map.c | 2 +-
> tools/perf/util/trace-event-parse.c | 12 ++++++++++++
> 3 files changed, 13 insertions(+), 2 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo