All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] perf record: Save build-id of DSO in callchains
@ 2015-03-23  1:18 Namhyung Kim
  2015-03-23  7:22 ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2015-03-23  1:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Frederic Weisbecker, Stephane Eranian

Currently the build-id only recorded for sampled location, but in
order to correctly view/annotate callchains it might need the
build-id's of callchains too.  I guess this choice was due to a
performance impact on the post-processing at perf record time.

Add a new option --buildid-callchain to record this info.

$ perf record -o xxx -g -- perf > /dev/null
$ perf buildid-list -i xxx
6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so

$ perf record -o yyy -g --buildid-callchain -- perf > /dev/null
$ perf buildid-list -i yyy
6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
4235ae90856f98d2746529648a3339ebfa6ede43 /home/namhyung/project/linux/tools/perf/perf
fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so
9ac81172d5ff96f40d984fe7c10073a98f1a6b2e /usr/lib/libc-2.21.so
864583bb881db1d260660a30a51b3f5022cd538b /usr/lib/libnuma.so.1.0.0

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-record.c |  2 ++
 tools/perf/util/build-id.c  | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5a2ff510b75b..a43b1d96714b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -841,6 +841,8 @@ struct option __record_options[] = {
 		    "Sample machine registers on interrupt"),
 	OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
 		    "Record running/enabled time of read (:S) events"),
+	OPT_BOOLEAN(0, "buildid-callchain", &symbol_conf.use_callchain,
+		    "Record build-id of DSOs in callchain"),
 	OPT_END()
 };
 
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index f7fb2587df69..401357f3425a 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -17,6 +17,7 @@
 #include "tool.h"
 #include "header.h"
 #include "vdso.h"
+#include "callchain.h"
 
 
 static bool no_buildid_cache;
@@ -24,13 +25,15 @@ static bool no_buildid_cache;
 int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
 			   union perf_event *event,
 			   struct perf_sample *sample,
-			   struct perf_evsel *evsel __maybe_unused,
+			   struct perf_evsel *evsel,
 			   struct machine *machine)
 {
 	struct addr_location al;
 	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 	struct thread *thread = machine__findnew_thread(machine, sample->pid,
 							sample->tid);
+	int err;
+	struct callchain_cursor_node *node;
 
 	if (thread == NULL) {
 		pr_err("problem processing %d event, skipping it.\n",
@@ -43,6 +46,25 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
 	if (al.map != NULL)
 		al.map->dso->hit = 1;
 
+	if (!symbol_conf.use_callchain)
+		return 0;
+
+	err = sample__resolve_callchain(sample, NULL, evsel, &al,
+					PERF_MAX_STACK_DEPTH);
+	if (err)
+		return err;
+
+	callchain_cursor_commit(&callchain_cursor);
+	node = callchain_cursor_current(&callchain_cursor);
+
+	while (node) {
+		if (node->map)
+			node->map->dso->hit = 1;
+
+		callchain_cursor_advance(&callchain_cursor);
+		node = callchain_cursor_current(&callchain_cursor);
+	}
+
 	return 0;
 }
 
-- 
2.3.3


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

* Re: [RFC/PATCH] perf record: Save build-id of DSO in callchains
  2015-03-23  1:18 [RFC/PATCH] perf record: Save build-id of DSO in callchains Namhyung Kim
@ 2015-03-23  7:22 ` Ingo Molnar
  2015-03-23  8:18   ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2015-03-23  7:22 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Jiri Olsa, LKML,
	David Ahern, Frederic Weisbecker, Stephane Eranian


* Namhyung Kim <namhyung@kernel.org> wrote:

> Currently the build-id only recorded for sampled location, but in
> order to correctly view/annotate callchains it might need the
> build-id's of callchains too.  I guess this choice was due to a
> performance impact on the post-processing at perf record time.
> 
> Add a new option --buildid-callchain to record this info.
> 
> $ perf record -o xxx -g -- perf > /dev/null
> $ perf buildid-list -i xxx
> 6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
> fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so
> 
> $ perf record -o yyy -g --buildid-callchain -- perf > /dev/null
> $ perf buildid-list -i yyy
> 6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
> 4235ae90856f98d2746529648a3339ebfa6ede43 /home/namhyung/project/linux/tools/perf/perf
> fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so
> 9ac81172d5ff96f40d984fe7c10073a98f1a6b2e /usr/lib/libc-2.21.so
> 864583bb881db1d260660a30a51b3f5022cd538b /usr/lib/libnuma.so.1.0.0

Just curious, could you try to measure the performance impact of this 
change?

Also, unless the performance (or file size) effect is horrible, I 
think this flag should be implicitly set by -g.

99.999% of users won't know about this flag, and will see broken 
annotations!

Thanks,

	Ingo

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

* Re: [RFC/PATCH] perf record: Save build-id of DSO in callchains
  2015-03-23  7:22 ` Ingo Molnar
@ 2015-03-23  8:18   ` Namhyung Kim
  2015-03-23 13:44     ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2015-03-23  8:18 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Jiri Olsa, LKML,
	David Ahern, Frederic Weisbecker, Stephane Eranian

Hi Ingo,

On Mon, Mar 23, 2015 at 08:22:14AM +0100, Ingo Molnar wrote:
> 
> * Namhyung Kim <namhyung@kernel.org> wrote:
> 
> > Currently the build-id only recorded for sampled location, but in
> > order to correctly view/annotate callchains it might need the
> > build-id's of callchains too.  I guess this choice was due to a
> > performance impact on the post-processing at perf record time.
> > 
> > Add a new option --buildid-callchain to record this info.
> > 
> > $ perf record -o xxx -g -- perf > /dev/null
> > $ perf buildid-list -i xxx
> > 6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
> > fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so
> > 
> > $ perf record -o yyy -g --buildid-callchain -- perf > /dev/null
> > $ perf buildid-list -i yyy
> > 6ebcee76c4b04895598b4df86ec445c49fc137a2 /lib/modules/3.18.6-1-ARCH/build/vmlinux
> > 4235ae90856f98d2746529648a3339ebfa6ede43 /home/namhyung/project/linux/tools/perf/perf
> > fc0759b71584d2513b04f1b530965a61b5e499e2 /usr/lib/ld-2.21.so
> > 9ac81172d5ff96f40d984fe7c10073a98f1a6b2e /usr/lib/libc-2.21.so
> > 864583bb881db1d260660a30a51b3f5022cd538b /usr/lib/libnuma.so.1.0.0
> 
> Just curious, could you try to measure the performance impact of this 
> change?

  $ time perf record --call-graph dwarf -o kbuild.xxx -a -- sleep 30
  [ perf record: Woken up 34674 times to write data ]
  [ perf record: Captured and wrote 9538.729 MB kbuild.xxx (1211997 samples) ]

  real   0m32.244s
  user   0m1.097s
  sys    0m8.997s

  $ time perf record --call-graph dwarf -o kbuild.yyy --buildid-callchain -a -- sleep 30
  [ perf record: Woken up 40902 times to write data ]
  [ perf record: Captured and wrote 11208.500 MB kbuild.yyy (1433922 samples) ]

  real   2m21.695s
  user   1m33.127s
  sys    0m22.077s

> 
> Also, unless the performance (or file size) effect is horrible, I 
> think this flag should be implicitly set by -g.

Agreed.  But unfortunately, it seems horrible. ;-p

> 
> 99.999% of users won't know about this flag, and will see broken 
> annotations!

Well, most of them will see correct one unless the binary is changed
in the meantime. :)

Thanks,
Namhyung

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

* Re: [RFC/PATCH] perf record: Save build-id of DSO in callchains
  2015-03-23  8:18   ` Namhyung Kim
@ 2015-03-23 13:44     ` David Ahern
  2015-03-23 16:28       ` Arnaldo Carvalho de Melo
  2015-03-23 23:30       ` Namhyung Kim
  0 siblings, 2 replies; 6+ messages in thread
From: David Ahern @ 2015-03-23 13:44 UTC (permalink / raw)
  To: Namhyung Kim, Ingo Molnar
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Jiri Olsa, LKML,
	Frederic Weisbecker, Stephane Eranian

On 3/23/15 2:18 AM, Namhyung Kim wrote:
>> Just curious, could you try to measure the performance impact of this
>> change?
>
>    $ time perf record --call-graph dwarf -o kbuild.xxx -a -- sleep 30
>    [ perf record: Woken up 34674 times to write data ]
>    [ perf record: Captured and wrote 9538.729 MB kbuild.xxx (1211997 samples) ]
>
>    real   0m32.244s
>    user   0m1.097s
>    sys    0m8.997s
>
>    $ time perf record --call-graph dwarf -o kbuild.yyy --buildid-callchain -a -- sleep 30
>    [ perf record: Woken up 40902 times to write data ]
>    [ perf record: Captured and wrote 11208.500 MB kbuild.yyy (1433922 samples) ]
>
>    real   2m21.695s
>    user   1m33.127s
>    sys    0m22.077s
>

How many CPUs and processes?

David


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

* Re: [RFC/PATCH] perf record: Save build-id of DSO in callchains
  2015-03-23 13:44     ` David Ahern
@ 2015-03-23 16:28       ` Arnaldo Carvalho de Melo
  2015-03-23 23:30       ` Namhyung Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-23 16:28 UTC (permalink / raw)
  To: David Ahern
  Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML,
	Frederic Weisbecker, Stephane Eranian

Em Mon, Mar 23, 2015 at 07:44:37AM -0600, David Ahern escreveu:
> On 3/23/15 2:18 AM, Namhyung Kim wrote:
> >>Just curious, could you try to measure the performance impact of this
> >>change?
> >
> >   $ time perf record --call-graph dwarf -o kbuild.xxx -a -- sleep 30
> >   [ perf record: Woken up 34674 times to write data ]
> >   [ perf record: Captured and wrote 9538.729 MB kbuild.xxx (1211997 samples) ]
> >
> >   real   0m32.244s
> >   user   0m1.097s
> >   sys    0m8.997s
> >
> >   $ time perf record --call-graph dwarf -o kbuild.yyy --buildid-callchain -a -- sleep 30
> >   [ perf record: Woken up 40902 times to write data ]
> >   [ perf record: Captured and wrote 11208.500 MB kbuild.yyy (1433922 samples) ]
> >
> >   real   2m21.695s
> >   user   1m33.127s
> >   sys    0m22.077s
> >
> 
> How many CPUs and processes?

I think I'll add those statistics to the default 'perf record' output
when build-id processing is done...

- Arnaldo

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

* Re: [RFC/PATCH] perf record: Save build-id of DSO in callchains
  2015-03-23 13:44     ` David Ahern
  2015-03-23 16:28       ` Arnaldo Carvalho de Melo
@ 2015-03-23 23:30       ` Namhyung Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2015-03-23 23:30 UTC (permalink / raw)
  To: David Ahern
  Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Peter Zijlstra, Jiri Olsa,
	LKML, Frederic Weisbecker, Stephane Eranian

Hi David,

On Mon, Mar 23, 2015 at 07:44:37AM -0600, David Ahern wrote:
> On 3/23/15 2:18 AM, Namhyung Kim wrote:
> >>Just curious, could you try to measure the performance impact of this
> >>change?
> >
> >   $ time perf record --call-graph dwarf -o kbuild.xxx -a -- sleep 30
> >   [ perf record: Woken up 34674 times to write data ]
> >   [ perf record: Captured and wrote 9538.729 MB kbuild.xxx (1211997 samples) ]
> >
> >   real   0m32.244s
> >   user   0m1.097s
> >   sys    0m8.997s
> >
> >   $ time perf record --call-graph dwarf -o kbuild.yyy --buildid-callchain -a -- sleep 30
> >   [ perf record: Woken up 40902 times to write data ]
> >   [ perf record: Captured and wrote 11208.500 MB kbuild.yyy (1433922 samples) ]
> >
> >   real   2m21.695s
> >   user   1m33.127s
> >   sys    0m22.077s
> >
> 
> How many CPUs and processes?

I was running kbuild with allyesconfig on 12-cpu box.

Thanks,
Namhyung

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

end of thread, other threads:[~2015-03-23 23:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23  1:18 [RFC/PATCH] perf record: Save build-id of DSO in callchains Namhyung Kim
2015-03-23  7:22 ` Ingo Molnar
2015-03-23  8:18   ` Namhyung Kim
2015-03-23 13:44     ` David Ahern
2015-03-23 16:28       ` Arnaldo Carvalho de Melo
2015-03-23 23:30       ` Namhyung Kim

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.