Skip to contentSkip to conversation

perf_counter tools: support annotation of live kernel modules

PATCH In review Mike Galbraith 5 participants 28 messages Jul 2, 2009 – Jul 3, 2009 perf events

lore
Share & tools
lore
#0 lore raw

cover perf_counter tools: support annotation of live kernel modules

Per $subject, this patch set only supports for the LIVE kernel. It adds support infrastructure for path discovery, load address lookup, and symbol generation of live kernel modules.

TODO includes resurrection of live annotation in perf top, and support for annotation and report generation of other than live modules. As the patch set sits, Perf top can generate symbols from live binaries, but there's no live annotation capability yet.

patch1: perf_counter tools: Make symbol loading consistently return number of loaded symbols.
patch2: perf_counter tools: Add infrastructure to support loading of kernel module symbols
patch3: perf_counter tools: connect module support infrastructure to symbol loading infrastructure
patch4: perf_counter tools: Enable kernel module symbol loading in tools

Comments and suggestions most welcome.

-Mike

#1 lore raw

PATCH 1/4 perf_counter tools: Make symbol loading consistently return number of loaded symbols

perf_counter tools: Make symbol loading consistently return number of loaded symbols.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/builtin-annotate.c |    2 +-
 tools/perf/builtin-report.c   |    2 +-
 tools/perf/builtin-top.c      |    2 +-
 tools/perf/util/symbol.c      |    9 ++++++---
 4 files changed, 9 insertions(+), 6 deletions(-)
tools/perf/builtin-annotate.c +1 -1
Index: linux-2.6/tools/perf/builtin-annotate.c
===================================================================
@@ -172,7 +172,7 @@ static int load_kernel(void)
 		return -1;
 
 	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-	if (err) {
+	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
 	} else
tools/perf/builtin-report.c +1 -1
Index: linux-2.6/tools/perf/builtin-report.c
===================================================================
@@ -189,7 +189,7 @@ static int load_kernel(void)
 		return -1;
 
 	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-	if (err) {
+	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
 	} else
tools/perf/builtin-top.c +1 -1
Index: linux-2.6/tools/perf/builtin-top.c
===================================================================
@@ -364,7 +364,7 @@ static int parse_symbols(void)
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0)
+	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
tools/perf/util/symbol.c +6 -3
Index: linux-2.6/tools/perf/util/symbol.c
===================================================================
@@ -146,6 +146,7 @@ static int dso__load_kallsyms(struct dso
 	char *line = NULL;
 	size_t n;
 	FILE *file = fopen("/proc/kallsyms", "r");
+	int count = 0;
 
 	if (file == NULL)
 		goto out_failure;
@@ -188,8 +189,10 @@ static int dso__load_kallsyms(struct dso
 
 		if (filter && filter(self, sym))
 			symbol__delete(sym, self->sym_priv_size);
-		else
+		else {
 			dso__insert_symbol(self, sym);
+			count++;
+		}
 	}
 
 	/*
@@ -212,7 +215,7 @@ static int dso__load_kallsyms(struct dso
 	free(line);
 	fclose(file);
 
-	return 0;
+	return count;
 
 out_delete_line:
 	free(line);
@@ -639,7 +642,7 @@ int dso__load_kernel(struct dso *self, c
 	if (vmlinux)
 		err = dso__load_vmlinux(self, vmlinux, filter, verbose);
 
-	if (err < 0)
+	if (err <= 0)
 		err = dso__load_kallsyms(self, filter, verbose);
 
 	return err;
#2 lore raw

[tip:perfcounters/urgent] perf_counter tools: Make symbol loading consistently return number of loaded symbols

Commit-ID:  9974f496782b7612e36a143bedda858f1cb953d4
Gitweb:     http://git.kernel.org/tip/9974f496782b7612e36a143bedda858f1cb953d4
Author:     Mike Galbraith <[email protected]>
AuthorDate: Thu, 2 Jul 2009 08:05:58 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 2 Jul 2009 08:42:20 +0200

perf_counter tools: Make symbol loading consistently return number of loaded symbols

perf_counter tools: Make symbol loading consistently return number of loaded symbols.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-annotate.c |    2 +-
 tools/perf/builtin-report.c   |    2 +-
 tools/perf/builtin-top.c      |    2 +-
 tools/perf/util/symbol.c      |    9 ++++++---
 4 files changed, 9 insertions(+), 6 deletions(-)
tools/perf/builtin-annotate.c +1 -1
index 132de8b..3becc8a 100644
@@ -172,7 +172,7 @@ static int load_kernel(void)
 		return -1;
 
 	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-	if (err) {
+	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
 	} else
tools/perf/builtin-report.c +1 -1
index be1b758..58d1612 100644
@@ -189,7 +189,7 @@ static int load_kernel(void)
 		return -1;
 
 	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-	if (err) {
+	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
 	} else
tools/perf/builtin-top.c +1 -1
index cdc74cf..97fde1d 100644
@@ -364,7 +364,7 @@ static int parse_symbols(void)
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0)
+	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
tools/perf/util/symbol.c +6 -3
index 78c2efd..c077b6a 100644
@@ -146,6 +146,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
 	char *line = NULL;
 	size_t n;
 	FILE *file = fopen("/proc/kallsyms", "r");
+	int count = 0;
 
 	if (file == NULL)
 		goto out_failure;
@@ -188,8 +189,10 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
 
 		if (filter && filter(self, sym))
 			symbol__delete(sym, self->sym_priv_size);
-		else
+		else {
 			dso__insert_symbol(self, sym);
+			count++;
+		}
 	}
 
 	/*
@@ -212,7 +215,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
 	free(line);
 	fclose(file);
 
-	return 0;
+	return count;
 
 out_delete_line:
 	free(line);
@@ -639,7 +642,7 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
 	if (vmlinux)
 		err = dso__load_vmlinux(self, vmlinux, filter, verbose);
 
-	if (err < 0)
+	if (err <= 0)
 		err = dso__load_kallsyms(self, filter, verbose);
 
 	return err;
#3 lore raw

PATCH 2/4 perf_counter tools: Add infrastructure to support loading of kernel module symbols

In reply to Mike Galbraith

perf_counter tools: Add infrastructure to support loading of kernel module symbols.

Add infrastructure for module path discovery and section load addresses.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/Makefile      |    2 
 tools/perf/util/module.c |  502 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/module.h |   53 ++++
 3 files changed, 557 insertions(+)
tools/perf/Makefile +2 -0
Index: linux-2.6/tools/perf/Makefile
===================================================================
@@ -306,6 +306,7 @@ LIB_H += util/strlist.h
 LIB_H += util/run-command.h
 LIB_H += util/sigchain.h
 LIB_H += util/symbol.h
+LIB_H += util/module.h
 LIB_H += util/color.h
 
 LIB_OBJS += util/abspath.o
@@ -329,6 +330,7 @@ LIB_OBJS += util/usage.o
 LIB_OBJS += util/wrapper.o
 LIB_OBJS += util/sigchain.o
 LIB_OBJS += util/symbol.o
+LIB_OBJS += util/module.o
 LIB_OBJS += util/color.o
 LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
tools/perf/util/module.h new file +53 -0

53 lines not on this page · raw message

tools/perf/util/module.c new file +502 -0

502 lines not on this page · raw message

#4 lore raw

[tip:perfcounters/urgent] perf_counter tools: Add infrastructure to support loading of kernel module symbols

Commit-ID:  208b4b4a59351011b7f212e273f2b7bc47a9c482
Gitweb:     http://git.kernel.org/tip/208b4b4a59351011b7f212e273f2b7bc47a9c482
Author:     Mike Galbraith <[email protected]>
AuthorDate: Thu, 2 Jul 2009 08:07:10 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 2 Jul 2009 08:42:20 +0200

perf_counter tools: Add infrastructure to support loading of kernel module symbols

Add infrastructure for module path discovery and section load addresses.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/Makefile      |    2 +
 tools/perf/util/module.c |  509 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/module.h |   53 +++++
 3 files changed, 564 insertions(+), 0 deletions(-)
tools/perf/Makefile +2 -0
index 8f7fd1b..7822b3d 100644
@@ -306,6 +306,7 @@ LIB_H += util/strlist.h
 LIB_H += util/run-command.h
 LIB_H += util/sigchain.h
 LIB_H += util/symbol.h
+LIB_H += util/module.h
 LIB_H += util/color.h
 
 LIB_OBJS += util/abspath.o
@@ -329,6 +330,7 @@ LIB_OBJS += util/usage.o
 LIB_OBJS += util/wrapper.o
 LIB_OBJS += util/sigchain.o
 LIB_OBJS += util/symbol.o
+LIB_OBJS += util/module.o
 LIB_OBJS += util/color.o
 LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
tools/perf/util/module.c new file +509 -0

509 lines not on this page · raw message

tools/perf/util/module.h new file +53 -0

53 lines not on this page · raw message

#5 lore raw

PATCH 3/4 perf_counter tools: connect module support infrastructure to symbol loading infrastructure

In reply to Mike Galbraith

perf_counter tools: connect module support infrastructure to symbol loading infrastructure.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/builtin-annotate.c |    2 
 tools/perf/builtin-report.c   |    2 
 tools/perf/builtin-top.c      |    2 
 tools/perf/util/symbol.c      |  159 +++++++++++++++++++++++++++++++++++++++---
 tools/perf/util/symbol.h      |    5 +
 5 files changed, 156 insertions(+), 14 deletions(-)
tools/perf/util/symbol.h +4 -1
Index: linux-2.6/tools/perf/util/symbol.h
===================================================================
@@ -5,6 +5,7 @@
 #include "types.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
+#include "module.h"
 
 struct symbol {
 	struct rb_node	rb_node;
@@ -13,6 +14,7 @@ struct symbol {
 	u64		obj_start;
 	u64		hist_sum;
 	u64		*hist;
+	struct module	*module;
 	void		*priv;
 	char		name[0];
 };
@@ -41,7 +43,8 @@ static inline void *dso__sym_priv(struct
 struct symbol *dso__find_symbol(struct dso *self, u64 ip);
 
 int dso__load_kernel(struct dso *self, const char *vmlinux,
-		     symbol_filter_t filter, int verbose);
+		     symbol_filter_t filter, int verbose, int modules);
+int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
 int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
tools/perf/util/symbol.c +149 -10

250 lines not on this page · raw message

tools/perf/builtin-annotate.c +1 -1
Index: linux-2.6/tools/perf/builtin-annotate.c
===================================================================
@@ -171,7 +171,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
tools/perf/builtin-report.c +1 -1
Index: linux-2.6/tools/perf/builtin-report.c
===================================================================
@@ -188,7 +188,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
tools/perf/builtin-top.c +1 -1
Index: linux-2.6/tools/perf/builtin-top.c
===================================================================
@@ -364,7 +364,7 @@ static int parse_symbols(void)
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) <= 0)
+	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1, 0) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
#6 lore raw

[tip:perfcounters/urgent] perf_counter tools: Connect module support infrastructure to symbol loading infrastructure

Commit-ID:  6cfcc53ed4f3ecb9319e73a03f34f1eddcb644dd
Gitweb:     http://git.kernel.org/tip/6cfcc53ed4f3ecb9319e73a03f34f1eddcb644dd
Author:     Mike Galbraith <[email protected]>
AuthorDate: Thu, 2 Jul 2009 08:08:36 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 2 Jul 2009 08:42:21 +0200

perf_counter tools: Connect module support infrastructure to symbol loading infrastructure

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-annotate.c |    2 +-
 tools/perf/builtin-report.c   |    2 +-
 tools/perf/builtin-top.c      |    2 +-
 tools/perf/util/symbol.c      |  159 ++++++++++++++++++++++++++++++++++++++---
 tools/perf/util/symbol.h      |    5 +-
 5 files changed, 156 insertions(+), 14 deletions(-)
tools/perf/builtin-annotate.c +1 -1
index 3becc8a..8820568 100644
@@ -171,7 +171,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
tools/perf/builtin-report.c +1 -1
index 58d1612..38d136f 100644
@@ -188,7 +188,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
tools/perf/builtin-top.c +1 -1
index 97fde1d..9bb25fc 100644
@@ -364,7 +364,7 @@ static int parse_symbols(void)
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) <= 0)
+	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1, 0) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
tools/perf/util/symbol.c +149 -10

250 lines not on this page · raw message

tools/perf/util/symbol.h +4 -1
index 65a8449..4e141a3 100644
@@ -5,6 +5,7 @@
 #include "types.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
+#include "module.h"
 
 struct symbol {
 	struct rb_node	rb_node;
@@ -13,6 +14,7 @@ struct symbol {
 	u64		obj_start;
 	u64		hist_sum;
 	u64		*hist;
+	struct module	*module;
 	void		*priv;
 	char		name[0];
 };
@@ -41,7 +43,8 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
 struct symbol *dso__find_symbol(struct dso *self, u64 ip);
 
 int dso__load_kernel(struct dso *self, const char *vmlinux,
-		     symbol_filter_t filter, int verbose);
+		     symbol_filter_t filter, int verbose, int modules);
+int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
 int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
#7 lore raw

PATCH 4/4 perf_counter tools: Enable kernel module symbol loading in tools

In reply to Mike Galbraith

perf_counter tools: Enable kernel module symbol loading in tools.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/builtin-annotate.c |   25 ++++++++++++++++++++-----
 tools/perf/builtin-report.c   |    9 ++++++++-
 tools/perf/builtin-top.c      |   12 ++++++++++--
 3 files changed, 38 insertions(+), 8 deletions(-)
tools/perf/builtin-annotate.c +20 -5
Index: linux-2.6/tools/perf/builtin-annotate.c
===================================================================
@@ -43,6 +43,10 @@ static int		dump_trace = 0;
 
 static int		verbose;
 
+static int		modules;
+
+static int		full_paths;
+
 static int		print_line;
 
 static unsigned long	page_size;
@@ -171,7 +175,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
@@ -1268,19 +1272,25 @@ static void print_summary(char *filename
 
 static void annotate_sym(struct dso *dso, struct symbol *sym)
 {
-	char *filename = dso->name;
+	char *filename = dso->name, *d_filename;
 	u64 start, end, len;
 	char command[PATH_MAX*2];
 	FILE *file;
 
 	if (!filename)
 		return;
-	if (dso == kernel_dso)
+	if (sym->module)
+		filename = sym->module->path;
+	else if (dso == kernel_dso)
 		filename = vmlinux;
 
 	start = sym->obj_start;
 	if (!start)
 		start = sym->start;
+	if (full_paths)
+		d_filename = filename;
+	else
+		d_filename = basename(filename);
 
 	end = start + sym->end - sym->start + 1;
 	len = sym->end - sym->start;
@@ -1291,13 +1301,14 @@ static void annotate_sym(struct dso *dso
 	}
 
 	printf("\n\n------------------------------------------------\n");
-	printf(" Percent |	Source code & Disassembly of %s\n", filename);
+	printf(" Percent |	Source code & Disassembly of %s\n", d_filename);
 	printf("------------------------------------------------\n");
 
 	if (verbose >= 2)
 		printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name);
 
-	sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (u64)start, (u64)end, filename);
+	sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s",
+			(u64)start, (u64)end, filename, filename);
 
 	if (verbose >= 3)
 		printf("doing: %s\n", command);
@@ -1472,8 +1483,12 @@ static const struct option options[] = {
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
+	OPT_BOOLEAN('m', "modules", &modules,
+		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
 	OPT_BOOLEAN('l', "print-line", &print_line,
 		    "print matching source lines (may be slow)"),
+	OPT_BOOLEAN('P', "full-paths", &full_paths,
+		    "Don't shorten the displayed pathnames"),
 	OPT_END()
 };
 
tools/perf/builtin-report.c +8 -1
Index: linux-2.6/tools/perf/builtin-report.c
===================================================================
@@ -46,6 +46,8 @@ static int		dump_trace = 0;
 static int		verbose;
 #define eprintf(x...)	do { if (verbose) fprintf(stderr, x); } while (0)
 
+static int		modules;
+
 static int		full_paths;
 
 static unsigned long	page_size;
@@ -188,7 +190,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
@@ -648,6 +650,9 @@ sort__sym_print(FILE *fp, struct hist_en
 		ret += fprintf(fp, "[%c] %s",
 			self->dso == kernel_dso ? 'k' :
 			self->dso == hypervisor_dso ? 'h' : '.', self->sym->name);
+
+		if (self->sym->module)
+			ret += fprintf(fp, "\t[%s]", self->sym->module->name);
 	} else {
 		ret += fprintf(fp, "%#016llx", (u64)self->ip);
 	}
@@ -1710,6 +1715,8 @@ static const struct option options[] = {
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
+	OPT_BOOLEAN('m', "modules", &modules,
+		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent"),
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
tools/perf/builtin-top.c +10 -2
Index: linux-2.6/tools/perf/builtin-top.c
===================================================================
@@ -66,6 +66,7 @@ static unsigned int		page_size;
 static unsigned int		mmap_pages			= 16;
 static int			freq				=  0;
 static int			verbose				=  0;
+static char			*vmlinux			=  NULL;
 
 static char			*sym_filter;
 static unsigned long		filter_start;
@@ -265,7 +266,10 @@ static void print_sym_table(void)
 			printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
 
 		color_fprintf(stdout, color, "%4.1f%%", pcnt);
-		printf(" - %016llx : %s\n", sym->start, sym->name);
+		printf(" - %016llx : %s", sym->start, sym->name);
+		if (sym->module)
+			printf("\t[%s]", sym->module->name);
+		printf("\n");
 	}
 }
 
@@ -359,12 +363,13 @@ static int parse_symbols(void)
 {
 	struct rb_node *node;
 	struct symbol  *sym;
+	int modules = vmlinux ? 1 : 0;
 
 	kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry));
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1, 0) <= 0)
+	if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
@@ -680,6 +685,7 @@ static const struct option options[] = {
 			    "system-wide collection from all CPUs"),
 	OPT_INTEGER('C', "CPU", &profile_cpu,
 		    "CPU to profile on"),
+	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
 	OPT_INTEGER('m', "mmap-pages", &mmap_pages,
 		    "number of mmap data pages"),
 	OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -709,6 +715,8 @@ int cmd_top(int argc, const char **argv,
 {
 	int counter;
 
+	symbol__init();
+
 	page_size = sysconf(_SC_PAGE_SIZE);
 
 	argc = parse_options(argc, argv, options, top_usage, 0);
#8 lore raw

[tip:perfcounters/urgent] perf_counter tools: Enable kernel module symbol loading in tools

Commit-ID:  429764873cf3fc3e73142872a674bb27cda589c1
Gitweb:     http://git.kernel.org/tip/429764873cf3fc3e73142872a674bb27cda589c1
Author:     Mike Galbraith <[email protected]>
AuthorDate: Thu, 2 Jul 2009 08:09:46 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 2 Jul 2009 08:42:21 +0200

perf_counter tools: Enable kernel module symbol loading in tools

Add the -m/--modules option to perf report and perf annotate, which enables live module symbol/image loading. To be used with -k/--vmlinux.

(Also give perf annotate a -P/--full-paths option.)

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-annotate.c |   25 ++++++++++++++++++++-----
 tools/perf/builtin-report.c   |    9 ++++++++-
 tools/perf/builtin-top.c      |   12 ++++++++++--
 3 files changed, 38 insertions(+), 8 deletions(-)
tools/perf/builtin-annotate.c +20 -5
index 8820568..08ea6c5 100644
@@ -43,6 +43,10 @@ static int		dump_trace = 0;
 
 static int		verbose;
 
+static int		modules;
+
+static int		full_paths;
+
 static int		print_line;
 
 static unsigned long	page_size;
@@ -171,7 +175,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
@@ -1268,19 +1272,25 @@ static void print_summary(char *filename)
 
 static void annotate_sym(struct dso *dso, struct symbol *sym)
 {
-	char *filename = dso->name;
+	char *filename = dso->name, *d_filename;
 	u64 start, end, len;
 	char command[PATH_MAX*2];
 	FILE *file;
 
 	if (!filename)
 		return;
-	if (dso == kernel_dso)
+	if (sym->module)
+		filename = sym->module->path;
+	else if (dso == kernel_dso)
 		filename = vmlinux;
 
 	start = sym->obj_start;
 	if (!start)
 		start = sym->start;
+	if (full_paths)
+		d_filename = filename;
+	else
+		d_filename = basename(filename);
 
 	end = start + sym->end - sym->start + 1;
 	len = sym->end - sym->start;
@@ -1291,13 +1301,14 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
 	}
 
 	printf("\n\n------------------------------------------------\n");
-	printf(" Percent |	Source code & Disassembly of %s\n", filename);
+	printf(" Percent |	Source code & Disassembly of %s\n", d_filename);
 	printf("------------------------------------------------\n");
 
 	if (verbose >= 2)
 		printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name);
 
-	sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (u64)start, (u64)end, filename);
+	sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s",
+			(u64)start, (u64)end, filename, filename);
 
 	if (verbose >= 3)
 		printf("doing: %s\n", command);
@@ -1472,8 +1483,12 @@ static const struct option options[] = {
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
+	OPT_BOOLEAN('m', "modules", &modules,
+		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
 	OPT_BOOLEAN('l', "print-line", &print_line,
 		    "print matching source lines (may be slow)"),
+	OPT_BOOLEAN('P', "full-paths", &full_paths,
+		    "Don't shorten the displayed pathnames"),
 	OPT_END()
 };
 
tools/perf/builtin-report.c +8 -1
index 38d136f..b44476c 100644
@@ -46,6 +46,8 @@ static int		dump_trace = 0;
 static int		verbose;
 #define eprintf(x...)	do { if (verbose) fprintf(stderr, x); } while (0)
 
+static int		modules;
+
 static int		full_paths;
 
 static unsigned long	page_size;
@@ -188,7 +190,7 @@ static int load_kernel(void)
 	if (!kernel_dso)
 		return -1;
 
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0);
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
 	if (err <= 0) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
@@ -648,6 +650,9 @@ sort__sym_print(FILE *fp, struct hist_entry *self)
 		ret += fprintf(fp, "[%c] %s",
 			self->dso == kernel_dso ? 'k' :
 			self->dso == hypervisor_dso ? 'h' : '.', self->sym->name);
+
+		if (self->sym->module)
+			ret += fprintf(fp, "\t[%s]", self->sym->module->name);
 	} else {
 		ret += fprintf(fp, "%#016llx", (u64)self->ip);
 	}
@@ -1710,6 +1715,8 @@ static const struct option options[] = {
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
+	OPT_BOOLEAN('m', "modules", &modules,
+		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent"),
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
tools/perf/builtin-top.c +10 -2
index 9bb25fc..aa044ea 100644
@@ -66,6 +66,7 @@ static unsigned int		page_size;
 static unsigned int		mmap_pages			= 16;
 static int			freq				=  0;
 static int			verbose				=  0;
+static char			*vmlinux			=  NULL;
 
 static char			*sym_filter;
 static unsigned long		filter_start;
@@ -265,7 +266,10 @@ static void print_sym_table(void)
 			printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
 
 		color_fprintf(stdout, color, "%4.1f%%", pcnt);
-		printf(" - %016llx : %s\n", sym->start, sym->name);
+		printf(" - %016llx : %s", sym->start, sym->name);
+		if (sym->module)
+			printf("\t[%s]", sym->module->name);
+		printf("\n");
 	}
 }
 
@@ -359,12 +363,13 @@ static int parse_symbols(void)
 {
 	struct rb_node *node;
 	struct symbol  *sym;
+	int modules = vmlinux ? 1 : 0;
 
 	kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry));
 	if (kernel_dso == NULL)
 		return -1;
 
-	if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1, 0) <= 0)
+	if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0)
 		goto out_delete_dso;
 
 	node = rb_first(&kernel_dso->syms);
@@ -680,6 +685,7 @@ static const struct option options[] = {
 			    "system-wide collection from all CPUs"),
 	OPT_INTEGER('C', "CPU", &profile_cpu,
 		    "CPU to profile on"),
+	OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
 	OPT_INTEGER('m', "mmap-pages", &mmap_pages,
 		    "number of mmap data pages"),
 	OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -709,6 +715,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 {
 	int counter;
 
+	symbol__init();
+
 	page_size = sysconf(_SC_PAGE_SIZE);
 
 	argc = parse_options(argc, argv, options, top_usage, 0);
#9 lore raw
In reply to Mike Galbraith
Quoted 9 lines · Mike Galbraith

Per $subject, this patch set only supports for the LIVE kernel. It adds support infrastructure for path discovery, load address lookup, and symbol generation of live kernel modules.

TODO includes resurrection of live annotation in perf top, and support for annotation and report generation of other than live modules. As the patch set sits, Perf top can generate symbols from live binaries, but there's no live annotation capability yet.

Quoted 6 lines

patch1: perf_counter tools: Make symbol loading consistently return number of loaded symbols.
patch2: perf_counter tools: Add infrastructure to support loading of kernel module symbols
patch3: perf_counter tools: connect module support infrastructure to symbol loading infrastructure
patch4: perf_counter tools: Enable kernel module symbol loading in tools

Comments and suggestions most welcome.

Looks very nice! I've applied it with a few minor stylistic fixlets and a tad more verbose changelogs.

I'm wondering about the next step: couldnt we somehow guess at the position of the vmlinux too, validate somehow that it corresponds to the kernel we are running - and then use it automatically and by default?

Plus, offline analysis would be nice as well i suspect - being able to look at profiles on a different box?

Ingo

#10 lore raw
Quoted 16 lines · Ingo Molnar
Quoted 14 lines · Mike Galbraith

Per $subject, this patch set only supports for the LIVE kernel. It adds support infrastructure for path discovery, load address lookup, and symbol generation of live kernel modules.

TODO includes resurrection of live annotation in perf top, and support for annotation and report generation of other than live modules. As the patch set sits, Perf top can generate symbols from live binaries, but there's no live annotation capability yet.

patch1: perf_counter tools: Make symbol loading consistently return number of loaded symbols.
patch2: perf_counter tools: Add infrastructure to support loading of kernel module symbols
patch3: perf_counter tools: connect module support infrastructure to symbol loading infrastructure
patch4: perf_counter tools: Enable kernel module symbol loading in tools

Quoted 4 lines
Quoted 1 line

Comments and suggestions most welcome.

Looks very nice! I've applied it with a few minor stylistic fixlets and a tad more verbose changelogs.

Thanks!

(sorry about changelogs, I did stare at them, nothing spiffy happened)

Quoted 4 lines

I'm wondering about the next step: couldnt we somehow guess at the position of the vmlinux too, validate somehow that it corresponds to the kernel we are running - and then use it automatically and by default?

I don't know of a way to discover where the image lives. Been pondering that very thing, along with idiot-proofing.

Quoted 2 lines

Plus, offline analysis would be nice as well i suspect - being able to look at profiles on a different box?

Yes, that's high on my TODO. I've been pondering a perf archive tool that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

After I resurrect (well, try) live annotation in top, I'll fiddle with offline kernel analysis.

-Mike

#11 lore raw
Quoted 19 lines · Mike Galbraith
Quoted 18 lines · Ingo Molnar
Quoted 15 lines · Mike Galbraith

Per $subject, this patch set only supports for the LIVE kernel. It adds support infrastructure for path discovery, load address lookup, and symbol generation of live kernel modules.

TODO includes resurrection of live annotation in perf top, and support for annotation and report generation of other than live modules. As the patch set sits, Perf top can generate symbols from live binaries, but there's no live annotation capability yet.

patch1: perf_counter tools: Make symbol loading consistently return number of loaded symbols.
patch2: perf_counter tools: Add infrastructure to support loading of kernel module symbols
patch3: perf_counter tools: connect module support infrastructure to symbol loading infrastructure
patch4: perf_counter tools: Enable kernel module symbol loading in tools

Comments and suggestions most welcome.

Quoted 7 lines
Quoted 2 lines

Looks very nice! I've applied it with a few minor stylistic fixlets and a tad more verbose changelogs.

Thanks!

(sorry about changelogs, I did stare at them, nothing spiffy happened)

[ We want to be verbose in changelogs generally - i.e. it's not a
problem at all to tell a boring story about what happens in the patch. To _you_ it certainly looks boring - to others it's a useful summary that sets their mind-set before looking at the patch. ]

Quoted 7 lines
Quoted 4 lines

I'm wondering about the next step: couldnt we somehow guess at the position of the vmlinux too, validate somehow that it corresponds to the kernel we are running - and then use it automatically and by default?

I don't know of a way to discover where the image lives. Been pondering that very thing, along with idiot-proofing.

There's two main usecases:

- distro kernels. Here the vmlinux and module path varies but should be discoverable with a finite list of try-and-err paths.

- 'make install modules_install' builds of kernel developers. Here the vmlinux and the source tree might be anywhere. A small trick might help: we could expose the build position of the kernel source tree via a new /proc/kernel-buildpath special file, which contains the vmlinux filename plus an MD5 sum (or CRC32) for good measure.

Note that /proc/kernel-buildpath might also help the distro case: a distro could set it thusly to have the correct position for a debuginfo rpm/deb install.

I.e. /proc/kernel-buildpath and the MD5 could solve both usecases. Other tools could make use of it too.

A second, more complex possibility would be to expose the kernel image itself plus the module images as well. This has limitations
though: debuginfo wont be embedded, and symbols are in /proc/kallsyms (which we do parse).

The advantage is that it's all readily available in memory (just not exposed), plus it would show the _real_ instructions - the post-paravirt-fixup post-ftrace-fixup and other dynamic patching results.

To expose that we'd have to create some sort of special "kernel image directory" within debugfs that has files like:

/debug/kimage/vmlinux
/debug/kimage/modules/
/debug/kimage/modules/snd_hda_intel.ko
/debug/kimage/modules/firewire_core.ko

Debugfs is quite easy to use and if we dont make it too fancy (no separate module directories for example) it would be doable without too much fuss.

It would be assembly-only annotations, without debuginfo.

Quoted 9 lines
Quoted 2 lines

Plus, offline analysis would be nice as well i suspect - being able to look at profiles on a different box?

Yes, that's high on my TODO. I've been pondering a perf archive tool that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

I wouldnt worry about size too much, at least initially.

[ If it ever becomes a big issue then we could do a separate 'perf
compress' pass which could do a 'specific'/sparse snapshot of affected binaries: i.e. pre-parse the data file, pick out all the RIPs that matter and check which binaries relate to them, and then read and pack those bits only. ]

Plus we could use Git's zlib smarts to compress the data file on the fly as well, during data capture. It's very easy to generate a gig or two of data currently.

Quoted 2 lines

After I resurrect (well, try) live annotation in top, I'll fiddle with offline kernel analysis.

Ok :-)

Btw, another thing: we are thinking about making -F 1000 (1 KHz auto-freq sampling) the default for perf top and perf record. This way we'd always gather enough data (and never too much or too little data), regardless of the intensity of the workload. Have you played with -F before, what's your general experience about it? It's particularly useful for 'rare' and highly fluctuating events like cache-misses.

Maybe 1KHz is a bit too low - Oprofile defaults to 100000 cycles interval by default which is about 10 KHz on a 1GHz box and 30 KHz on a 3GHz box. Perhaps 10 KHz is a better default?

Ingo

#12 lore raw

On Thu, 2009-07-02 at 09:42 +0200, Ingo Molnar wrote:

(squirrels suggestions away for later reference)

Quoted 11 lines

Btw, another thing: we are thinking about making -F 1000 (1 KHz auto-freq sampling) the default for perf top and perf record. This way we'd always gather enough data (and never too much or too little data), regardless of the intensity of the workload. Have you played with -F before, what's your general experience about it? It's particularly useful for 'rare' and highly fluctuating events like cache-misses.

Maybe 1KHz is a bit too low - Oprofile defaults to 100000 cycles interval by default which is about 10 KHz on a 1GHz box and 30 KHz on a 3GHz box. Perhaps 10 KHz is a better default?

My default usage is 1000Hz to keep overhead low. Works fine for me.

-Mike

#13 lore raw
Quoted 12 lines · Mike Galbraith

On Thu, 2009-07-02 at 09:42 +0200, Ingo Molnar wrote:

(squirrels suggestions away for later reference)

Quoted 8 lines

Btw, another thing: we are thinking about making -F 1000 (1 KHz auto-freq sampling) the default for perf top and perf record. This way we'd always gather enough data (and never too much or too little data), regardless of the intensity of the workload. Have you played with -F before, what's your general experience about it? It's particularly useful for 'rare' and highly fluctuating events like cache-misses.

Quoted 6 lines
Quoted 3 lines

Maybe 1KHz is a bit too low - Oprofile defaults to 100000 cycles interval by default which is about 10 KHz on a 1GHz box and 30 KHz on a 3GHz box. Perhaps 10 KHz is a better default?

My default usage is 1000Hz to keep overhead low. Works fine for me.

ah, so you use -F by default?

I still think 10 KHz would be better - especially for really short runs like 'perf record -f -g ./git gc'. Since Oprofile samples at 26 KHz by default, we must not go to a too low frequency, otherwise people might get a 'hm, the perf profiles are worse than the Oprofile ones' first impression ...

We could perhaps add a freq=1000 switch to .perfconfig - we have Git's util/config.c facility - it's just unused right now ;-)

[ Look at the Git sources about how config.c is used. ]

Ingo

#14 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 12 lines · Mike Galbraith

On Thu, 2009-07-02 at 09:42 +0200, Ingo Molnar wrote:

(squirrels suggestions away for later reference)

Quoted 8 lines

Btw, another thing: we are thinking about making -F 1000 (1 KHz auto-freq sampling) the default for perf top and perf record. This way we'd always gather enough data (and never too much or too little data), regardless of the intensity of the workload. Have you played with -F before, what's your general experience about it? It's particularly useful for 'rare' and highly fluctuating events like cache-misses.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Maybe 1KHz is a bit too low - Oprofile defaults to 100000 cycles interval by default which is about 10 KHz on a 1GHz box and 30 KHz on a 3GHz box. Perhaps 10 KHz is a better default?

My default usage is 1000Hz to keep overhead low. Works fine for me.

ah, so you use -F by default?

Yes.

Quoted 10 lines

I still think 10 KHz would be better - especially for really short runs like 'perf record -f -g ./git gc'. Since Oprofile samples at 26 KHz by default, we must not go to a too low frequency, otherwise people might get a 'hm, the perf profiles are worse than the Oprofile ones' first impression ...

We could perhaps add a freq=1000 switch to .perfconfig - we have Git's util/config.c facility - it's just unused right now ;-)

[ Look at the Git sources about how config.c is used. ]

Yeah, that's a good idea.. everyone can roll their own defaults.

For me, it doesn't matter what the default is, I always specify.

-Mike

#15 lore raw
In reply to Mike Galbraith
Quoted 1 line · Mike Galbraith

After I resurrect (well, try) live annotation in top...

Random thought wrt live top annotation: instead of resurrecting in the previous form, which could be a bit intrusive display space wise, what do you think of this idea?

Provide a kbd input snapshot trigger which builds a perf record (hard?) compatible file for the symbols being displayed. Start a background task to annotate the lot, stuffing annotate output into an output file.

Better ideas highly welcome.

-Mike

#16 lore raw
Quoted 3 lines · Mike Galbraith

Provide a kbd input snapshot trigger which builds a perf record (hard?) compatible file for the symbols being displayed. Start a background task to annotate the lot, stuffing annotate output into an output file.

(P.S. I'm thinking of dirt simple performance issue reporting method)

#17 lore raw
In reply to Mike Galbraith
Quoted 8 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith

After I resurrect (well, try) live annotation in top...

Random thought wrt live top annotation: instead of resurrecting in the previous form, which could be a bit intrusive display space wise, what do you think of this idea?

Quoted 6 lines

Provide a kbd input snapshot trigger which builds a perf record (hard?) compatible file for the symbols being displayed. Start a background task to annotate the lot, stuffing annotate output into an output file.

Better ideas highly welcome.

Hm, is there really a performance problem?

We need to calculate and cache the objdump annotation output once, but after that it should be pretty fast as we just display updated counts with the same lines over and over again. No repeated objdump runs are needed.

Ingo

#18 lore raw
Quoted 10 lines · Ingo Molnar
Quoted 8 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith

After I resurrect (well, try) live annotation in top...

Random thought wrt live top annotation: instead of resurrecting in the previous form, which could be a bit intrusive display space wise, what do you think of this idea?

Quoted 8 lines
Quoted 6 lines

Provide a kbd input snapshot trigger which builds a perf record (hard?) compatible file for the symbols being displayed. Start a background task to annotate the lot, stuffing annotate output into an output file.

Better ideas highly welcome.

Hm, is there really a performance problem?

Sort of..

Quoted 4 lines

We need to calculate and cache the objdump annotation output once, but after that it should be pretty fast as we just display updated counts with the same lines over and over again. No repeated objdump runs are needed.

But active files follow symbols, which change on the fly.

Besides, as mentioned previously, while displayed annotation was very cool, it took a lot of display space. For me, top with the ability to emit bic-disposable mini-reports would be my primary perf tools usage. I'd only use big brothers when I needed their power/detail.

-Mike

#19 lore raw
Quoted 5 lines · Mike Galbraith
Quoted 4 lines

We need to calculate and cache the objdump annotation output once, but after that it should be pretty fast as we just display updated counts with the same lines over and over again. No repeated objdump runs are needed.

Quoted 7 lines

But active files follow symbols, which change on the fly.

Besides, as mentioned previously, while displayed annotation was very cool, it took a lot of display space. For me, top with the ability to emit bic-disposable mini-reports would be my primary perf tools usage. I'd only use big brothers when I needed their power/detail.

Ok, then how about putting some sort of interactivity into perf top?

Up and down arrows would allow the walking of the histogram, and hitting enter on a symbol would show the annotated function? It would be way cool and more usable and more flexible than some side-channel for mini-reports.

PowerTop has a lot of good text interactivity code that might be reused. (assuming it's under a kernel compatible license?)

There's also the 'tig' tool - an interactive tool to walk Git trees/commits. If it's under a compatible license that would be a nice place to look for clues too - it has a very mature and well-thought-out TUI in my opinion.

Ingo

#20 lore raw
Quoted 22 lines · Ingo Molnar
Quoted 5 lines · Mike Galbraith
Quoted 4 lines

We need to calculate and cache the objdump annotation output once, but after that it should be pretty fast as we just display updated counts with the same lines over and over again. No repeated objdump runs are needed.

Quoted 7 lines

But active files follow symbols, which change on the fly.

Besides, as mentioned previously, while displayed annotation was very cool, it took a lot of display space. For me, top with the ability to emit bic-disposable mini-reports would be my primary perf tools usage. I'd only use big brothers when I needed their power/detail.

Ok, then how about putting some sort of interactivity into perf top?

Up and down arrows would allow the walking of the histogram, and hitting enter on a symbol would show the annotated function? It would be way cool and more usable and more flexible than some side-channel for mini-reports.

Quoted 7 lines

PowerTop has a lot of good text interactivity code that might be reused. (assuming it's under a kernel compatible license?)

There's also the 'tig' tool - an interactive tool to walk Git trees/commits. If it's under a compatible license that would be a nice place to look for clues too - it has a very mature and well-thought-out TUI in my opinion.

Cool. I love free samples to bend/spindle/mutilate :)

-Mike

#21 lore raw
Quoted 26 lines · Mike Galbraith
Quoted 25 lines · Ingo Molnar
Quoted 5 lines · Mike Galbraith
Quoted 4 lines

We need to calculate and cache the objdump annotation output once, but after that it should be pretty fast as we just display updated counts with the same lines over and over again. No repeated objdump runs are needed.

Quoted 7 lines

But active files follow symbols, which change on the fly.

Besides, as mentioned previously, while displayed annotation was very cool, it took a lot of display space. For me, top with the ability to emit bic-disposable mini-reports would be my primary perf tools usage. I'd only use big brothers when I needed their power/detail.

Ok, then how about putting some sort of interactivity into perf top?

Up and down arrows would allow the walking of the histogram, and hitting enter on a symbol would show the annotated function? It would be way cool and more usable and more flexible than some side-channel for mini-reports.

PowerTop has a lot of good text interactivity code that might be reused. (assuming it's under a kernel compatible license?)

Quoted 8 lines
Quoted 4 lines

There's also the 'tig' tool - an interactive tool to walk Git trees/commits. If it's under a compatible license that would be a nice place to look for clues too - it has a very mature and well-thought-out TUI in my opinion.

Cool. I love free samples to bend/spindle/mutilate :)

-Mike

The same interactivity could also apply to perf report, by dynamically expanding callchains, linking to more details with annotate, etc...

#22 lore raw
In reply to Mike Galbraith
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

#23 lore raw
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

Quoted 6 lines

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

That's a good idea.

If uname doesn't match stored record time uname, you're not live, so tools require an exportable perf.data. If you're not live and not on the same host, annotate requires binaries appended via an export tool with --sym-filter -k -u -% whatever capability.

-Mike

#24 lore raw
Quoted 17 lines · Mike Galbraith
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

Quoted 6 lines

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

Quoted 6 lines

That's a good idea.

If uname doesn't match stored record time uname, you're not live, so tools require an exportable perf.data. If you're not live and not on the same host, annotate requires binaries appended via an export tool with --sym-filter -k -u -% whatever capability.

'perf export' could be a nice shortcut to convert a local perf.data into a off-line analysable body of data.

Ingo

#25 lore raw
Quoted 21 lines · Ingo Molnar
Quoted 19 lines · Mike Galbraith
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

Quoted 6 lines

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

That's a good idea.

Quoted 8 lines
Quoted 4 lines

If uname doesn't match stored record time uname, you're not live, so tools require an exportable perf.data. If you're not live and not on the same host, annotate requires binaries appended via an export tool with --sym-filter -k -u -% whatever capability.

'perf export' could be a nice shortcut to convert a local perf.data into a off-line analysable body of data.

I think it should be in both ways.

perf export and perf import

--
JSR

http://userweb.kernel.org/~jaswinder/

#26 lore raw
In reply to Mike Galbraith
Quoted 17 lines · Mike Galbraith
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

Quoted 6 lines

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

Quoted 8 lines

That's a good idea.

If uname doesn't match stored record time uname, you're not live, so tools require an exportable perf.data. If you're not live and not on the same host, annotate requires binaries appended via an export tool with --sym-filter -k -u -% whatever capability.

-Mike

Also that would make easier the implementation of a perf compare thing. A perf compare may have several uses, including:

(1) comparing different workloads with a same executable.
(2) comparing different executable versions for a same workload
(3) (1) + (2) ?

For the (2), having self contained record files as operands would let comparisons based on symbols, pretty useful when you have to compare two different vmlinux (or whatever binary executable).

#27 lore raw
Quoted 31 lines · Frederic Weisbecker
Quoted 17 lines · Mike Galbraith
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · Mike Galbraith

I've been pondering a perf archive tool
that would package everything that's needed to do analysis on a different box. One big problem though, is that while you can easily package vmlinux and modules, what about all the userland binaries? A large perf.data and/or debug info binaries can easily make transport impractical enough.

Quoted 6 lines

I would simply extend the current file header with another section in which we do a structured storage of the data structures we currently build in perf-report. That is, the dso and symbol bits.

If we then run perf-report on a file containing such a section we read that data instead of trying to locate them the regular way.

Quoted 8 lines

That's a good idea.

If uname doesn't match stored record time uname, you're not live, so tools require an exportable perf.data. If you're not live and not on the same host, annotate requires binaries appended via an export tool with --sym-filter -k -u -% whatever capability.

-Mike

Also that would make easier the implementation of a perf compare thing. A perf compare may have several uses, including:

Quoted 7 lines

(1) comparing different workloads with a same executable.
(2) comparing different executable versions for a same workload
(3) (1) + (2) ?

For the (2), having self contained record files as operands would let comparisons based on symbols, pretty useful when you have to compare two different vmlinux (or whatever binary executable).

very good points.

Ingo