Skip to contentSkip to conversation

perf tools: Factorize common code

GIT PULL Superseded Frederic Weisbecker 4 participants 17 messages Aug 12, 2009 perf events

lore
Share & tools
lore
#0 lore raw

Ingo,

This set factorizes the common definition of structs, functions, variables inside perf tools to make it easier for perf trace to be created.

I guess this patchset only factorizes 10 % of what could be done, the largest part is the intersection between perf report and perf annotate. It's a lot of work.

I guess I will do the rest in separate patchsets while writing perf trace.

Thanks,
Frederic.

The following changes since commit 9f8666971185b86615a074bcac67c90fdf8af8bc:
Brice Goglin (1):
perf report: Add raw displaying of per-thread counters

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git ..BRANCH.NOT.VERIFIED..

Frederic Weisbecker (3):
perf tools: Factorize high level dso helpers
perf tools: Factorize the event structure definitions in a single file perf tools: Factorize the map helpers

 tools/perf/Makefile           |    2 +
 tools/perf/builtin-annotate.c |  209 +-------------------------------
 tools/perf/builtin-record.c   |   20 +---
 tools/perf/builtin-report.c   |  274 +----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |   24 ----
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/event.h       |   84 +++++++++++++
 tools/perf/util/map.c         |   97 +++++++++++++++
 tools/perf/util/symbol.c      |   97 +++++++++++++++
 tools/perf/util/symbol.h      |   12 ++
 tools/perf/util/util.h        |    1 +
 14 files changed, 303 insertions(+), 521 deletions(-)
 create mode 100644 tools/perf/util/event.h
 create mode 100644 tools/perf/util/map.c
#1 lore raw

PATCH 1/3 perf tools: Factorize high level dso helpers

Factorize multiple definitions of high level dso helpers into the symbol source file.

The side effect is a general export of the verbose and eprintf debugging helpers into a new file dedicated to debugging purposes.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   96 ----------------------------------------
 tools/perf/builtin-record.c   |    1 -
 tools/perf/builtin-report.c   |   97 -----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |    4 --
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/symbol.c      |   97 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |   11 +++++
 10 files changed, 111 insertions(+), 199 deletions(-)
tools/perf/Makefile +1 -0
index de7beac..2aee21b 100644
@@ -339,6 +339,7 @@ LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
+LIB_OBJS += util/debug.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +0 -96

114 lines not on this page · raw message

tools/perf/builtin-record.c +0 -1
index 0345aad..afae387 100644
@@ -40,7 +40,6 @@ static int			inherit				= 1;
 static int			force				= 0;
 static int			append_file			= 0;
 static int			call_graph			= 0;
-static int			verbose				= 0;
 static int			inherit_stat			= 0;
 static int			no_samples			= 0;
 static int			sample_address			= 0;
tools/perf/builtin-report.c +0 -97

116 lines not on this page · raw message

tools/perf/builtin-stat.c +0 -1
index b4b06c7..4b9dd4a 100644
@@ -63,7 +63,6 @@ static struct perf_counter_attr default_attrs[] = {
 #define MAX_RUN			100
 
 static int			system_wide			=  0;
-static int			verbose				=  0;
 static unsigned int		nr_cpus				=  0;
 static int			run_idx				=  0;
 
tools/perf/builtin-top.c +0 -4
index 7de28ce..0aa5673 100644
@@ -68,8 +68,6 @@ static int			group				=  0;
 static unsigned int		page_size;
 static unsigned int		mmap_pages			= 16;
 static int			freq				=  0;
-static int			verbose				=  0;
-static char			*vmlinux			=  NULL;
 
 static int			delay_secs			=  2;
 static int			zero;
@@ -338,8 +336,6 @@ static void show_details(struct sym_entry *syme)
 		printf("%d lines not displayed, maybe increase display entries [e]\n", more);
 }
 
-struct dso			*kernel_dso;
-
 /*
  * Symbols will be added here in record_ip and will get out
  * after decayed.
tools/perf/builtin.h +1 -0
index 51d1682..3a63e41 100644
@@ -22,5 +22,6 @@ extern int cmd_stat(int argc, const char **argv, const char *prefix);
 extern int cmd_top(int argc, const char **argv, const char *prefix);
 extern int cmd_version(int argc, const char **argv, const char *prefix);
 extern int cmd_list(int argc, const char **argv, const char *prefix);
+extern int cmd_trace(int argc, const char **argv, const char *prefix);
 
 #endif
tools/perf/perf.h +1 -0
index e5148e2..f550921 100644
@@ -48,6 +48,7 @@
 
 #include "../../include/linux/perf_counter.h"
 #include "util/types.h"
+#include "util/debug.h"
 
 /*
  * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all
tools/perf/util/symbol.c +97 -0

103 lines not on this page · raw message

tools/perf/util/symbol.h +11 -0
index 1e003ec..f3490fc 100644
@@ -48,9 +48,20 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
 		     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);
+struct dso *dsos__findnew(const char *name);
+void dsos__fprintf(FILE *fp);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
 char dso__symtab_origin(const struct dso *self);
 
+int load_kernel(void);
+
 void symbol__init(void);
+
+extern struct list_head dsos;
+extern struct dso *kernel_dso;
+extern struct dso *vdso;
+extern struct dso *hypervisor_dso;
+extern char *vmlinux;
+extern int   modules;
 #endif /* _PERF_SYMBOL_ */
Signature · 1 line
1.6.2.3
#2 lore raw

Re: [PATCH 1/3] perf tools: Factorize high level dso helpers

Quoted 29 lines · Frederic Weisbecker

Factorize multiple definitions of high level dso helpers into the symbol source file.

The side effect is a general export of the verbose and eprintf debugging helpers into a new file dedicated to debugging purposes.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   96 ----------------------------------------
 tools/perf/builtin-record.c   |    1 -
 tools/perf/builtin-report.c   |   97 -----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |    4 --
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/symbol.c      |   97 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |   11 +++++
 10 files changed, 111 insertions(+), 199 deletions(-)
tools/perf/Makefile +0 -0
index de7beac..2aee21b 100644

tools/perf/Makefile LIB_OBJS += util/pager.o · line 342

Quoted 4 lines
tools/perf/Makefile +1 -0
@@ -339,6 +339,7 @@ LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
+LIB_OBJS += util/debug.o

Damn, did I forgot to git-add util/debug.c ?

How could I fix this? Another pull request?

Frederic.

Quoted 452 lines
tools/perf/Makefile +0 -0
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +0 -96
index 1dba568..1a79299 100644
@@ -26,7 +26,6 @@
 #define SHOW_HV		4
 
 static char		const *input_name = "perf.data";
-static char		*vmlinux = "vmlinux";
 
 static char		default_sort_order[] = "comm,symbol";
 static char		*sort_order = default_sort_order;
@@ -37,9 +36,6 @@ static int		show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
 static int		dump_trace = 0;
 #define dprintf(x...)	do { if (dump_trace) printf(x); } while (0)
 
-static int		verbose;
-
-static int		modules;
 
 static int		full_paths;
 
@@ -89,98 +85,6 @@ struct sym_ext {
 	char		*path;
 };
 
-static LIST_HEAD(dsos);
-static struct dso *kernel_dso;
-static struct dso *vdso;
-
-
-static void dsos__add(struct dso *dso)
-{
-	list_add_tail(&dso->node, &dsos);
-}
-
-static struct dso *dsos__find(const char *name)
-{
-	struct dso *pos;
-
-	list_for_each_entry(pos, &dsos, node)
-		if (strcmp(pos->name, name) == 0)
-			return pos;
-	return NULL;
-}
-
-static struct dso *dsos__findnew(const char *name)
-{
-	struct dso *dso = dsos__find(name);
-	int nr;
-
-	if (dso)
-		return dso;
-
-	dso = dso__new(name, 0);
-	if (!dso)
-		goto out_delete_dso;
-
-	nr = dso__load(dso, NULL, verbose);
-	if (nr < 0) {
-		if (verbose)
-			fprintf(stderr, "Failed to open: %s\n", name);
-		goto out_delete_dso;
-	}
-	if (!nr && verbose) {
-		fprintf(stderr,
-		"No symbols found in: %s, maybe install a debug package?\n",
-				name);
-	}
-
-	dsos__add(dso);
-
-	return dso;
-
-out_delete_dso:
-	dso__delete(dso);
-	return NULL;
-}
-
-static void dsos__fprintf(FILE *fp)
-{
-	struct dso *pos;
-
-	list_for_each_entry(pos, &dsos, node)
-		dso__fprintf(pos, fp);
-}
-
-static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
-{
-	return dso__find_symbol(dso, ip);
-}
-
-static int load_kernel(void)
-{
-	int err;
-
-	kernel_dso = dso__new("[kernel]", 0);
-	if (!kernel_dso)
-		return -1;
-
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
-	if (err <= 0) {
-		dso__delete(kernel_dso);
-		kernel_dso = NULL;
-	} else
-		dsos__add(kernel_dso);
-
-	vdso = dso__new("[vdso]", 0);
-	if (!vdso)
-		return -1;
-
-	vdso->find_symbol = vdso__find_symbol;
-
-	dsos__add(vdso);
-
-	return err;
-}
-
 struct map {
 	struct list_head node;
 	u64	 start;
tools/perf/builtin-record.c +0 -1
index 0345aad..afae387 100644
@@ -40,7 +40,6 @@ static int			inherit				= 1;
 static int			force				= 0;
 static int			append_file			= 0;
 static int			call_graph			= 0;
-static int			verbose				= 0;
 static int			inherit_stat			= 0;
 static int			no_samples			= 0;
 static int			sample_address			= 0;
tools/perf/builtin-report.c +0 -97
index 2357c66..827eab2 100644
@@ -30,7 +30,6 @@
 #define SHOW_HV		4
 
 static char		const *input_name = "perf.data";
-static char		*vmlinux = NULL;
 
 static char		default_sort_order[] = "comm,dso,symbol";
 static char		*sort_order = default_sort_order;
@@ -46,11 +45,6 @@ static int		dump_trace = 0;
 #define dprintf(x...)	do { if (dump_trace) printf(x); } while (0)
 #define cdprintf(x...)	do { if (dump_trace) color_fprintf(stdout, color, x); } while (0)
 
-static int		verbose;
-#define eprintf(x...)	do { if (verbose) fprintf(stderr, x); } while (0)
-
-static int		modules;
-
 static int		full_paths;
 static int		show_nr_samples;
 
@@ -161,98 +155,7 @@ static int repsep_fprintf(FILE *fp, const char *fmt, ...)
 	return n;
 }
 
-static LIST_HEAD(dsos);
-static struct dso *kernel_dso;
-static struct dso *vdso;
-static struct dso *hypervisor_dso;
-
-static void dsos__add(struct dso *dso)
-{
-	list_add_tail(&dso->node, &dsos);
-}
-
-static struct dso *dsos__find(const char *name)
-{
-	struct dso *pos;
-
-	list_for_each_entry(pos, &dsos, node)
-		if (strcmp(pos->name, name) == 0)
-			return pos;
-	return NULL;
-}
-
-static struct dso *dsos__findnew(const char *name)
-{
-	struct dso *dso = dsos__find(name);
-	int nr;
-
-	if (dso)
-		return dso;
-
-	dso = dso__new(name, 0);
-	if (!dso)
-		goto out_delete_dso;
-
-	nr = dso__load(dso, NULL, verbose);
-	if (nr < 0) {
-		eprintf("Failed to open: %s\n", name);
-		goto out_delete_dso;
-	}
-	if (!nr)
-		eprintf("No symbols found in: %s, maybe install a debug package?\n", name);
-
-	dsos__add(dso);
-
-	return dso;
-
-out_delete_dso:
-	dso__delete(dso);
-	return NULL;
-}
-
-static void dsos__fprintf(FILE *fp)
-{
-	struct dso *pos;
-
-	list_for_each_entry(pos, &dsos, node)
-		dso__fprintf(pos, fp);
-}
-
-static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
-{
-	return dso__find_symbol(dso, ip);
-}
-
-static int load_kernel(void)
-{
-	int err;
-
-	kernel_dso = dso__new("[kernel]", 0);
-	if (!kernel_dso)
-		return -1;
-
-	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
-	if (err <= 0) {
-		dso__delete(kernel_dso);
-		kernel_dso = NULL;
-	} else
-		dsos__add(kernel_dso);
-
-	vdso = dso__new("[vdso]", 0);
-	if (!vdso)
-		return -1;
 
-	vdso->find_symbol = vdso__find_symbol;
-
-	dsos__add(vdso);
-
-	hypervisor_dso = dso__new("[hypervisor]", 0);
-	if (!hypervisor_dso)
-		return -1;
-	dsos__add(hypervisor_dso);
-
-	return err;
-}
 
 static char __cwd[PATH_MAX];
 static char *cwd = __cwd;
tools/perf/builtin-stat.c +0 -1
index b4b06c7..4b9dd4a 100644
@@ -63,7 +63,6 @@ static struct perf_counter_attr default_attrs[] = {
 #define MAX_RUN			100
 
 static int			system_wide			=  0;
-static int			verbose				=  0;
 static unsigned int		nr_cpus				=  0;
 static int			run_idx				=  0;
 
tools/perf/builtin-top.c +0 -4
index 7de28ce..0aa5673 100644
@@ -68,8 +68,6 @@ static int			group				=  0;
 static unsigned int		page_size;
 static unsigned int		mmap_pages			= 16;
 static int			freq				=  0;
-static int			verbose				=  0;
-static char			*vmlinux			=  NULL;
 
 static int			delay_secs			=  2;
 static int			zero;
@@ -338,8 +336,6 @@ static void show_details(struct sym_entry *syme)
 		printf("%d lines not displayed, maybe increase display entries [e]\n", more);
 }
 
-struct dso			*kernel_dso;
-
 /*
  * Symbols will be added here in record_ip and will get out
  * after decayed.
tools/perf/builtin.h +1 -0
index 51d1682..3a63e41 100644
@@ -22,5 +22,6 @@ extern int cmd_stat(int argc, const char **argv, const char *prefix);
 extern int cmd_top(int argc, const char **argv, const char *prefix);
 extern int cmd_version(int argc, const char **argv, const char *prefix);
 extern int cmd_list(int argc, const char **argv, const char *prefix);
+extern int cmd_trace(int argc, const char **argv, const char *prefix);
 
 #endif
tools/perf/perf.h +1 -0
index e5148e2..f550921 100644
@@ -48,6 +48,7 @@
 
 #include "../../include/linux/perf_counter.h"
 #include "util/types.h"
+#include "util/debug.h"
 
 /*
  * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all
tools/perf/util/symbol.c +97 -0
index f1dcede..e9b13b4 100644
@@ -937,6 +937,103 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
 	return err;
 }
 
+LIST_HEAD(dsos);
+struct dso	*kernel_dso;
+struct dso	*vdso;
+struct dso	*hypervisor_dso;
+
+char		*vmlinux = "vmlinux";
+int		modules;
+
+static void dsos__add(struct dso *dso)
+{
+	list_add_tail(&dso->node, &dsos);
+}
+
+static struct dso *dsos__find(const char *name)
+{
+	struct dso *pos;
+
+	list_for_each_entry(pos, &dsos, node)
+		if (strcmp(pos->name, name) == 0)
+			return pos;
+	return NULL;
+}
+
+struct dso *dsos__findnew(const char *name)
+{
+	struct dso *dso = dsos__find(name);
+	int nr;
+
+	if (dso)
+		return dso;
+
+	dso = dso__new(name, 0);
+	if (!dso)
+		goto out_delete_dso;
+
+	nr = dso__load(dso, NULL, verbose);
+	if (nr < 0) {
+		eprintf("Failed to open: %s\n", name);
+		goto out_delete_dso;
+	}
+	if (!nr)
+		eprintf("No symbols found in: %s, maybe install a debug package?\n", name);
+
+	dsos__add(dso);
+
+	return dso;
+
+out_delete_dso:
+	dso__delete(dso);
+	return NULL;
+}
+
+void dsos__fprintf(FILE *fp)
+{
+	struct dso *pos;
+
+	list_for_each_entry(pos, &dsos, node)
+		dso__fprintf(pos, fp);
+}
+
+static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
+{
+	return dso__find_symbol(dso, ip);
+}
+
+int load_kernel(void)
+{
+	int err;
+
+	kernel_dso = dso__new("[kernel]", 0);
+	if (!kernel_dso)
+		return -1;
+
+	err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
+	if (err <= 0) {
+		dso__delete(kernel_dso);
+		kernel_dso = NULL;
+	} else
+		dsos__add(kernel_dso);
+
+	vdso = dso__new("[vdso]", 0);
+	if (!vdso)
+		return -1;
+
+	vdso->find_symbol = vdso__find_symbol;
+
+	dsos__add(vdso);
+
+	hypervisor_dso = dso__new("[hypervisor]", 0);
+	if (!hypervisor_dso)
+		return -1;
+	dsos__add(hypervisor_dso);
+
+	return err;
+}
+
+
 void symbol__init(void)
 {
 	elf_version(EV_CURRENT);
tools/perf/util/symbol.h +11 -0
index 1e003ec..f3490fc 100644
@@ -48,9 +48,20 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
 		     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);
+struct dso *dsos__findnew(const char *name);
+void dsos__fprintf(FILE *fp);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
 char dso__symtab_origin(const struct dso *self);
 
+int load_kernel(void);
+
 void symbol__init(void);
+
+extern struct list_head dsos;
+extern struct dso *kernel_dso;
+extern struct dso *vdso;
+extern struct dso *hypervisor_dso;
+extern char *vmlinux;
+extern int   modules;
 #endif /* _PERF_SYMBOL_ */
Signature · 1 line
1.6.2.3
#3 lore raw

Re: [PATCH 1/3] perf tools: Factorize high level dso helpers

Quoted 38 lines · Frederic Weisbecker
Quoted 29 lines · Frederic Weisbecker

Factorize multiple definitions of high level dso helpers into the symbol source file.

The side effect is a general export of the verbose and eprintf debugging helpers into a new file dedicated to debugging purposes.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   96 ----------------------------------------
 tools/perf/builtin-record.c   |    1 -
 tools/perf/builtin-report.c   |   97 -----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |    4 --
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/symbol.c      |   97 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |   11 +++++
 10 files changed, 111 insertions(+), 199 deletions(-)
tools/perf/Makefile +0 -0
index de7beac..2aee21b 100644

tools/perf/Makefile LIB_OBJS += util/pager.o · line 342

Quoted 4 lines
tools/perf/Makefile +1 -0
@@ -339,6 +339,7 @@ LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
+LIB_OBJS += util/debug.o

Damn, did I forgot to git-add util/debug.c ?

Quoted 1 line

How could I fix this? Another pull request?

yeah. I've zapped those commits from perfcounters/core.

Ingo

#4 lore raw
Quoted 3 lines · Ingo Molnar

yeah. I've zapped those commits from perfcounters/core.

Ingo

Ok, sorry about that.
I've rebuilt a clean tree. It should be fine now.

Thanks.

The following changes since commit 9f8666971185b86615a074bcac67c90fdf8af8bc:
Brice Goglin (1):
perf report: Add raw displaying of per-thread counters

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git \
perfcounters/core

Frederic Weisbecker (3):
perf tools: Factorize high level dso helpers
perf tools: Factorize the event structure definitions in a single file perf tools: Factorize the map helpers

 tools/perf/Makefile           |    2 +
 tools/perf/builtin-annotate.c |  209 +-------------------------------
 tools/perf/builtin-record.c   |   20 +---
 tools/perf/builtin-report.c   |  274 +----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |   24 ----
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/debug.c       |   22 ++++
 tools/perf/util/debug.h       |    5 +
 tools/perf/util/event.h       |   84 +++++++++++++
 tools/perf/util/map.c         |   97 +++++++++++++++
 tools/perf/util/symbol.c      |   97 +++++++++++++++
 tools/perf/util/symbol.h      |   12 ++
 tools/perf/util/util.h        |    1 +
 16 files changed, 330 insertions(+), 521 deletions(-)
 create mode 100644 tools/perf/util/debug.c
 create mode 100644 tools/perf/util/debug.h
 create mode 100644 tools/perf/util/event.h
 create mode 100644 tools/perf/util/map.c
#5 lore raw
Quoted 7 lines · Frederic Weisbecker
Quoted 3 lines · Ingo Molnar

yeah. I've zapped those commits from perfcounters/core.

Ingo

Ok, sorry about that.
I've rebuilt a clean tree. It should be fine now.

btw., you can always check whether there's any missing git-add, via:

  git ls-files --others

And the safest way to commit is to use 'git commit -a' - that will auto-include new files. (but the tree has to be clean for that)

Quoted 30 lines

Thanks.

The following changes since commit 9f8666971185b86615a074bcac67c90fdf8af8bc:
Brice Goglin (1):
perf report: Add raw displaying of per-thread counters

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git \
perfcounters/core

Frederic Weisbecker (3):
perf tools: Factorize high level dso helpers
perf tools: Factorize the event structure definitions in a single file perf tools: Factorize the map helpers

 tools/perf/Makefile           |    2 +
 tools/perf/builtin-annotate.c |  209 +-------------------------------
 tools/perf/builtin-record.c   |   20 +---
 tools/perf/builtin-report.c   |  274 +----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |   24 ----
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/debug.c       |   22 ++++
 tools/perf/util/debug.h       |    5 +
 tools/perf/util/event.h       |   84 +++++++++++++
 tools/perf/util/map.c         |   97 +++++++++++++++
Quoted 8 lines
 tools/perf/util/symbol.c      |   97 +++++++++++++++
 tools/perf/util/symbol.h      |   12 ++
 tools/perf/util/util.h        |    1 +
 16 files changed, 330 insertions(+), 521 deletions(-)
 create mode 100644 tools/perf/util/debug.c
 create mode 100644 tools/perf/util/debug.h
 create mode 100644 tools/perf/util/event.h
 create mode 100644 tools/perf/util/map.c

Re-pulled it - it works fine here too - thanks!

Ingo

#6 lore raw
Quoted 8 lines · Ingo Molnar
Quoted 5 lines · Frederic Weisbecker
Quoted 3 lines · Ingo Molnar

yeah. I've zapped those commits from perfcounters/core.

Ingo

Quoted 7 lines
Quoted 2 lines

Ok, sorry about that.
I've rebuilt a clean tree. It should be fine now.

btw., you can always check whether there's any missing git-add, via:

  git ls-files --others

Ah nice tip.

Quoted 3 lines

And the safest way to commit is to use 'git commit -a' - that will auto-include new files. (but the tree has to be clean for that)

Well, I always have junks in my directories. .rej/.orig files, or more especially scripts and tests in the case of the tools/perf directory. So it's hard to check everything this way.

Note that most of the time I use git-commit -a, but it doesn't include untracked files AFAICS.

Quoted 39 lines
Quoted 30 lines

Thanks.

The following changes since commit 9f8666971185b86615a074bcac67c90fdf8af8bc:
Brice Goglin (1):
perf report: Add raw displaying of per-thread counters

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git \
perfcounters/core

Frederic Weisbecker (3):
perf tools: Factorize high level dso helpers
perf tools: Factorize the event structure definitions in a single file perf tools: Factorize the map helpers

 tools/perf/Makefile           |    2 +
 tools/perf/builtin-annotate.c |  209 +-------------------------------
 tools/perf/builtin-record.c   |   20 +---
 tools/perf/builtin-report.c   |  274 +----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |   24 ----
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/debug.c       |   22 ++++
 tools/perf/util/debug.h       |    5 +
 tools/perf/util/event.h       |   84 +++++++++++++
 tools/perf/util/map.c         |   97 +++++++++++++++
Quoted 8 lines
 tools/perf/util/symbol.c      |   97 +++++++++++++++
 tools/perf/util/symbol.h      |   12 ++
 tools/perf/util/util.h        |    1 +
 16 files changed, 330 insertions(+), 521 deletions(-)
 create mode 100644 tools/perf/util/debug.c
 create mode 100644 tools/perf/util/debug.h
 create mode 100644 tools/perf/util/event.h
 create mode 100644 tools/perf/util/map.c
Quoted 3 lines

Re-pulled it - it works fine here too - thanks!

Ingo

Cool, thanks.

#7 lore raw
In reply to Frederic Weisbecker

Em Wed, Aug 12, 2009 at 12:48:29PM +0200, Frederic Weisbecker escreveu:

Quoted 9 lines · Ingo Molnar
Quoted 3 lines

yeah. I've zapped those commits from perfcounters/core.

Ingo

Ok, sorry about that.
I've rebuilt a clean tree. It should be fine now.

Thanks.

Thanks a lot for doing this work, I intended to do that but got sidetracked with symbol resolving neverending corner cases 8)

- Arnaldo

#8 lore raw
Quoted 6 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2009 at 12:48:29PM +0200, Frederic Weisbecker escreveu:

Quoted 5 lines · Ingo Molnar
Quoted 3 lines

yeah. I've zapped those commits from perfcounters/core.

Ingo

Quoted 7 lines
Quoted 4 lines

Ok, sorry about that.
I've rebuilt a clean tree. It should be fine now.

Thanks.

Thanks a lot for doing this work, I intended to do that but got sidetracked with symbol resolving neverending corner cases 8)

:)

Also, there's still quite a bit of code left to be factorized out of builtin-annotate.c and builtin-report.c.

Ingo

#9 lore raw

PATCH v2 1/3 perf tools: Factorize high level dso helpers

In reply to Ingo Molnar

Factorize multiple definitions of high level dso helpers into the symbol source file.

The side effect is a general export of the verbose and eprintf debugging helpers into a new file dedicated to debugging purposes.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   96 ----------------------------------------
 tools/perf/builtin-record.c   |    1 -
 tools/perf/builtin-report.c   |   97 -----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |    4 --
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/debug.c       |   22 +++++++++
 tools/perf/util/debug.h       |    5 ++
 tools/perf/util/symbol.c      |   97 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |   11 +++++
 12 files changed, 138 insertions(+), 199 deletions(-)
 create mode 100644 tools/perf/util/debug.c
 create mode 100644 tools/perf/util/debug.h
tools/perf/Makefile +1 -0
index de7beac..2aee21b 100644
@@ -339,6 +339,7 @@ LIB_OBJS += util/pager.o
 LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
+LIB_OBJS += util/debug.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +0 -96

114 lines not on this page · raw message

tools/perf/builtin-record.c +0 -1
index 0345aad..afae387 100644
@@ -40,7 +40,6 @@ static int			inherit				= 1;
 static int			force				= 0;
 static int			append_file			= 0;
 static int			call_graph			= 0;
-static int			verbose				= 0;
 static int			inherit_stat			= 0;
 static int			no_samples			= 0;
 static int			sample_address			= 0;
tools/perf/builtin-report.c +0 -97

116 lines not on this page · raw message

tools/perf/builtin-stat.c +0 -1
index b4b06c7..4b9dd4a 100644
@@ -63,7 +63,6 @@ static struct perf_counter_attr default_attrs[] = {
 #define MAX_RUN			100
 
 static int			system_wide			=  0;
-static int			verbose				=  0;
 static unsigned int		nr_cpus				=  0;
 static int			run_idx				=  0;
 
tools/perf/builtin-top.c +0 -4
index 7de28ce..0aa5673 100644
@@ -68,8 +68,6 @@ static int			group				=  0;
 static unsigned int		page_size;
 static unsigned int		mmap_pages			= 16;
 static int			freq				=  0;
-static int			verbose				=  0;
-static char			*vmlinux			=  NULL;
 
 static int			delay_secs			=  2;
 static int			zero;
@@ -338,8 +336,6 @@ static void show_details(struct sym_entry *syme)
 		printf("%d lines not displayed, maybe increase display entries [e]\n", more);
 }
 
-struct dso			*kernel_dso;
-
 /*
  * Symbols will be added here in record_ip and will get out
  * after decayed.
tools/perf/builtin.h +1 -0
index 51d1682..3a63e41 100644
@@ -22,5 +22,6 @@ extern int cmd_stat(int argc, const char **argv, const char *prefix);
 extern int cmd_top(int argc, const char **argv, const char *prefix);
 extern int cmd_version(int argc, const char **argv, const char *prefix);
 extern int cmd_list(int argc, const char **argv, const char *prefix);
+extern int cmd_trace(int argc, const char **argv, const char *prefix);
 
 #endif
tools/perf/perf.h +1 -0
index e5148e2..f550921 100644
@@ -48,6 +48,7 @@
 
 #include "../../include/linux/perf_counter.h"
 #include "util/types.h"
+#include "util/debug.h"
 
 /*
  * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all
tools/perf/util/debug.c new file +22 -0
new file mode 100644
index 0000000..7cb8464
@@ -0,0 +1,22 @@
+/* For general debugging purposes */
+
+#include "../perf.h"
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+int verbose = 0;
+
+int eprintf(const char *fmt, ...)
+{
+	va_list args;
+	int ret = 0;
+
+	if (verbose) {
+		va_start(args, fmt);
+		ret = vfprintf(stderr, fmt, args);
+		va_end(args);
+	}
+
+	return ret;
+}
tools/perf/util/debug.h new file +5 -0
new file mode 100644
index 0000000..2ae9090
@@ -0,0 +1,5 @@
+/* For debugging general purposes */
+
+extern int verbose;
+
+int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
tools/perf/util/symbol.c +97 -0

103 lines not on this page · raw message

tools/perf/util/symbol.h +11 -0
index 1e003ec..f3490fc 100644
@@ -48,9 +48,20 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
 		     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);
+struct dso *dsos__findnew(const char *name);
+void dsos__fprintf(FILE *fp);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
 char dso__symtab_origin(const struct dso *self);
 
+int load_kernel(void);
+
 void symbol__init(void);
+
+extern struct list_head dsos;
+extern struct dso *kernel_dso;
+extern struct dso *vdso;
+extern struct dso *hypervisor_dso;
+extern char *vmlinux;
+extern int   modules;
 #endif /* _PERF_SYMBOL_ */
Signature · 1 line
1.6.2.3
#10 lore raw

PATCH v2 2/3 perf tools: Factorize the event structure definitions in a single file

In reply to Ingo Molnar

Factorize the multiple definition of the events structures into a single util/event.h file.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/builtin-annotate.c |   34 -------------------------
 tools/perf/builtin-record.c   |   18 -------------
 tools/perf/builtin-report.c   |   53 ----------------------------------------
 tools/perf/builtin-top.c      |   20 ---------------
 tools/perf/util/event.h       |   54 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h        |    2 +
 6 files changed, 56 insertions(+), 125 deletions(-)
 create mode 100644 tools/perf/util/event.h
tools/perf/builtin-annotate.c +0 -34
index 1a79299..fee663a 100644
@@ -44,40 +44,6 @@ static int		print_line;
 static unsigned long	page_size;
 static unsigned long	mmap_window = 32;
 
-struct ip_event {
-	struct perf_event_header header;
-	u64 ip;
-	u32 pid, tid;
-};
-
-struct mmap_event {
-	struct perf_event_header header;
-	u32 pid, tid;
-	u64 start;
-	u64 len;
-	u64 pgoff;
-	char filename[PATH_MAX];
-};
-
-struct comm_event {
-	struct perf_event_header header;
-	u32 pid, tid;
-	char comm[16];
-};
-
-struct fork_event {
-	struct perf_event_header header;
-	u32 pid, ppid;
-};
-
-typedef union event_union {
-	struct perf_event_header	header;
-	struct ip_event			ip;
-	struct mmap_event		mmap;
-	struct comm_event		comm;
-	struct fork_event		fork;
-} event_t;
-
 
 struct sym_ext {
 	struct rb_node	node;
tools/perf/builtin-record.c +0 -18
index afae387..718b8f7 100644
@@ -59,24 +59,6 @@ static int			file_new = 1;
 
 struct perf_header		*header;
 
-struct mmap_event {
-	struct perf_event_header	header;
-	u32				pid;
-	u32				tid;
-	u64				start;
-	u64				len;
-	u64				pgoff;
-	char				filename[PATH_MAX];
-};
-
-struct comm_event {
-	struct perf_event_header	header;
-	u32				pid;
-	u32				tid;
-	char				comm[16];
-};
-
-
 struct mmap_data {
 	int			counter;
 	void			*base;
tools/perf/builtin-report.c +0 -53

59 lines not on this page · raw message

tools/perf/builtin-top.c +0 -20
index 0aa5673..9a6dbbf 100644
@@ -933,26 +933,6 @@ static void mmap_read_counter(struct mmap_data *md)
 	last_read = this_read;
 
 	for (; old != head;) {
-		struct ip_event {
-			struct perf_event_header header;
-			u64 ip;
-			u32 pid, target_pid;
-		};
-		struct mmap_event {
-			struct perf_event_header header;
-			u32 pid, target_pid;
-			u64 start;
-			u64 len;
-			u64 pgoff;
-			char filename[PATH_MAX];
-		};
-
-		typedef union event_union {
-			struct perf_event_header header;
-			struct ip_event ip;
-			struct mmap_event mmap;
-		} event_t;
-
 		event_t *event = (event_t *)&data[old & md->mask];
 
 		event_t event_copy;
tools/perf/util/event.h new file +54 -0

54 lines not on this page · raw message

tools/perf/util/util.h +2 -0
index 68fe157..be4b52c 100644
@@ -83,6 +83,8 @@
 #include <inttypes.h>
 #include "../../../include/linux/magic.h"
 
+#include "event.h"
+
 #ifndef NO_ICONV
 #include <iconv.h>
 #endif
Signature · 1 line
1.6.2.3
#11 lore raw

PATCH v2 3/3 perf tools: Factorize the map helpers

In reply to Ingo Molnar

Factorize the dso mapping helpers into a single purpose common file "util/map.c"

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   79 +--------------------------
 tools/perf/builtin-record.c   |    1 +
 tools/perf/builtin-report.c   |  124 ++---------------------------------------
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/event.h       |   30 ++++++++++
 tools/perf/util/map.c         |   97 ++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |    1 +
 tools/perf/util/util.h        |    1 -
 9 files changed, 137 insertions(+), 198 deletions(-)
 create mode 100644 tools/perf/util/map.c
tools/perf/Makefile +1 -0
index 2aee21b..cb9033d 100644
@@ -340,6 +340,7 @@ LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
 LIB_OBJS += util/debug.o
+LIB_OBJS += util/map.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +1 -78

91 lines not on this page · raw message

tools/perf/builtin-record.c +1 -0
index 718b8f7..106c6ab 100644
@@ -15,6 +15,7 @@
 #include "util/string.h"
 
 #include "util/header.h"
+#include "util/event.h"
 
 #include <unistd.h>
 #include <sched.h>
tools/perf/builtin-report.c +5 -119

142 lines not on this page · raw message

tools/perf/util/callchain.h +1 -0
index a926ae4..43cf3ea 100644
@@ -4,6 +4,7 @@
 #include "../perf.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
+#include "util.h"
 #include "symbol.h"
 
 enum chain_mode {
tools/perf/util/event.h +30 -0
index 91e2fe5..d26dc88 100644
@@ -1,4 +1,8 @@
+#ifndef __PERF_EVENT_H
+#define __PERF_EVENT_H
 #include "../perf.h"
+#include "util.h"
+#include <linux/list.h>
 
 struct ip_event {
 	struct perf_event_header header;
@@ -52,3 +56,29 @@ typedef union event_union {
 	struct lost_event		lost;
 	struct read_event		read;
 } event_t;
+
+struct map {
+	struct list_head	node;
+	u64			start;
+	u64			end;
+	u64			pgoff;
+	u64			(*map_ip)(struct map *, u64);
+	struct dso		*dso;
+};
+
+static inline u64 map__map_ip(struct map *map, u64 ip)
+{
+	return ip - map->start + map->pgoff;
+}
+
+static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
+{
+	return ip;
+}
+
+struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
+struct map *map__clone(struct map *self);
+int map__overlap(struct map *l, struct map *r);
+size_t map__fprintf(struct map *self, FILE *fp);
+
+#endif
tools/perf/util/map.c new file +97 -0

97 lines not on this page · raw message

tools/perf/util/symbol.h +1 -0
index f3490fc..50f7235 100644
@@ -6,6 +6,7 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include "module.h"
+#include "event.h"
 
 struct symbol {
 	struct rb_node	rb_node;
tools/perf/util/util.h +0 -1
index be4b52c..d61a6f0 100644
@@ -83,7 +83,6 @@
 #include <inttypes.h>
 #include "../../../include/linux/magic.h"
 
-#include "event.h"
 
 #ifndef NO_ICONV
 #include <iconv.h>
Signature · 1 line
1.6.2.3
#12 lore raw

PATCH 2/3 perf tools: Factorize the event structure definitions in a single file

In reply to Frederic Weisbecker

Factorize the multiple definition of the events structures into a single util/event.h file.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/builtin-annotate.c |   34 -------------------------
 tools/perf/builtin-record.c   |   18 -------------
 tools/perf/builtin-report.c   |   53 ----------------------------------------
 tools/perf/builtin-top.c      |   20 ---------------
 tools/perf/util/event.h       |   54 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h        |    2 +
 6 files changed, 56 insertions(+), 125 deletions(-)
 create mode 100644 tools/perf/util/event.h
tools/perf/builtin-annotate.c +0 -34
index 1a79299..fee663a 100644
@@ -44,40 +44,6 @@ static int		print_line;
 static unsigned long	page_size;
 static unsigned long	mmap_window = 32;
 
-struct ip_event {
-	struct perf_event_header header;
-	u64 ip;
-	u32 pid, tid;
-};
-
-struct mmap_event {
-	struct perf_event_header header;
-	u32 pid, tid;
-	u64 start;
-	u64 len;
-	u64 pgoff;
-	char filename[PATH_MAX];
-};
-
-struct comm_event {
-	struct perf_event_header header;
-	u32 pid, tid;
-	char comm[16];
-};
-
-struct fork_event {
-	struct perf_event_header header;
-	u32 pid, ppid;
-};
-
-typedef union event_union {
-	struct perf_event_header	header;
-	struct ip_event			ip;
-	struct mmap_event		mmap;
-	struct comm_event		comm;
-	struct fork_event		fork;
-} event_t;
-
 
 struct sym_ext {
 	struct rb_node	node;
tools/perf/builtin-record.c +0 -18
index afae387..718b8f7 100644
@@ -59,24 +59,6 @@ static int			file_new = 1;
 
 struct perf_header		*header;
 
-struct mmap_event {
-	struct perf_event_header	header;
-	u32				pid;
-	u32				tid;
-	u64				start;
-	u64				len;
-	u64				pgoff;
-	char				filename[PATH_MAX];
-};
-
-struct comm_event {
-	struct perf_event_header	header;
-	u32				pid;
-	u32				tid;
-	char				comm[16];
-};
-
-
 struct mmap_data {
 	int			counter;
 	void			*base;
tools/perf/builtin-report.c +0 -53

59 lines not on this page · raw message

tools/perf/builtin-top.c +0 -20
index 0aa5673..9a6dbbf 100644
@@ -933,26 +933,6 @@ static void mmap_read_counter(struct mmap_data *md)
 	last_read = this_read;
 
 	for (; old != head;) {
-		struct ip_event {
-			struct perf_event_header header;
-			u64 ip;
-			u32 pid, target_pid;
-		};
-		struct mmap_event {
-			struct perf_event_header header;
-			u32 pid, target_pid;
-			u64 start;
-			u64 len;
-			u64 pgoff;
-			char filename[PATH_MAX];
-		};
-
-		typedef union event_union {
-			struct perf_event_header header;
-			struct ip_event ip;
-			struct mmap_event mmap;
-		} event_t;
-
 		event_t *event = (event_t *)&data[old & md->mask];
 
 		event_t event_copy;
tools/perf/util/event.h new file +54 -0

54 lines not on this page · raw message

tools/perf/util/util.h +2 -0
index 68fe157..be4b52c 100644
@@ -83,6 +83,8 @@
 #include <inttypes.h>
 #include "../../../include/linux/magic.h"
 
+#include "event.h"
+
 #ifndef NO_ICONV
 #include <iconv.h>
 #endif
Signature · 1 line
1.6.2.3
#13 lore raw

PATCH 3/3 perf tools: Factorize the map helpers

In reply to Frederic Weisbecker

Factorize the dso mapping helpers into a single purpose common file "util/map.c"

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Brice Goglin <[email protected]>
---
 tools/perf/Makefile           |    1 +
 tools/perf/builtin-annotate.c |   79 +--------------------------
 tools/perf/builtin-record.c   |    1 +
 tools/perf/builtin-report.c   |  124 ++---------------------------------------
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/event.h       |   30 ++++++++++
 tools/perf/util/map.c         |   97 ++++++++++++++++++++++++++++++++
 tools/perf/util/symbol.h      |    1 +
 tools/perf/util/util.h        |    1 -
 9 files changed, 137 insertions(+), 198 deletions(-)
 create mode 100644 tools/perf/util/map.c
tools/perf/Makefile +1 -0
index 2aee21b..f4d868c 100644
@@ -340,6 +340,7 @@ LIB_OBJS += util/header.o
 LIB_OBJS += util/callchain.o
 LIB_OBJS += util/values.o
 LIB_OBJS += util/debug.o
+LIB_OBJS += util/event.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-annotate.c +1 -78

91 lines not on this page · raw message

tools/perf/builtin-record.c +1 -0
index 718b8f7..106c6ab 100644
@@ -15,6 +15,7 @@
 #include "util/string.h"
 
 #include "util/header.h"
+#include "util/event.h"
 
 #include <unistd.h>
 #include <sched.h>
tools/perf/builtin-report.c +5 -119

142 lines not on this page · raw message

tools/perf/util/callchain.h +1 -0
index a926ae4..43cf3ea 100644
@@ -4,6 +4,7 @@
 #include "../perf.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
+#include "util.h"
 #include "symbol.h"
 
 enum chain_mode {
tools/perf/util/event.h +30 -0
index 91e2fe5..d26dc88 100644
@@ -1,4 +1,8 @@
+#ifndef __PERF_EVENT_H
+#define __PERF_EVENT_H
 #include "../perf.h"
+#include "util.h"
+#include <linux/list.h>
 
 struct ip_event {
 	struct perf_event_header header;
@@ -52,3 +56,29 @@ typedef union event_union {
 	struct lost_event		lost;
 	struct read_event		read;
 } event_t;
+
+struct map {
+	struct list_head	node;
+	u64			start;
+	u64			end;
+	u64			pgoff;
+	u64			(*map_ip)(struct map *, u64);
+	struct dso		*dso;
+};
+
+static inline u64 map__map_ip(struct map *map, u64 ip)
+{
+	return ip - map->start + map->pgoff;
+}
+
+static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
+{
+	return ip;
+}
+
+struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
+struct map *map__clone(struct map *self);
+int map__overlap(struct map *l, struct map *r);
+size_t map__fprintf(struct map *self, FILE *fp);
+
+#endif
tools/perf/util/map.c new file +97 -0

97 lines not on this page · raw message

tools/perf/util/symbol.h +1 -0
index f3490fc..50f7235 100644
@@ -6,6 +6,7 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include "module.h"
+#include "event.h"
 
 struct symbol {
 	struct rb_node	rb_node;
tools/perf/util/util.h +0 -1
index be4b52c..d61a6f0 100644
@@ -83,7 +83,6 @@
 #include <inttypes.h>
 #include "../../../include/linux/magic.h"
 
-#include "event.h"
 
 #ifndef NO_ICONV
 #include <iconv.h>
Signature · 1 line
1.6.2.3
#14 lore raw
In reply to Frederic Weisbecker
Quoted 17 lines · Frederic Weisbecker

Ingo,

This set factorizes the common definition of structs, functions, variables inside perf tools to make it easier for perf trace to be created.

I guess this patchset only factorizes 10 % of what could be done, the largest part is the intersection between perf report and perf annotate. It's a lot of work.

I guess I will do the rest in separate patchsets while writing perf trace.

Thanks,
Frederic.

Quoted 7 lines

The following changes since commit 9f8666971185b86615a074bcac67c90fdf8af8bc:
Brice Goglin (1):
perf report: Add raw displaying of per-thread counters

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git ..BRANCH.NOT.VERIFIED..

s/BRANCH.NOT.VERIFIED/"perfcounters/core"

Quoted 23 lines

Frederic Weisbecker (3):
perf tools: Factorize high level dso helpers
perf tools: Factorize the event structure definitions in a single file perf tools: Factorize the map helpers

 tools/perf/Makefile           |    2 +
 tools/perf/builtin-annotate.c |  209 +-------------------------------
 tools/perf/builtin-record.c   |   20 +---
 tools/perf/builtin-report.c   |  274 +----------------------------------------
 tools/perf/builtin-stat.c     |    1 -
 tools/perf/builtin-top.c      |   24 ----
 tools/perf/builtin.h          |    1 +
 tools/perf/perf.h             |    1 +
 tools/perf/util/callchain.h   |    1 +
 tools/perf/util/event.h       |   84 +++++++++++++
 tools/perf/util/map.c         |   97 +++++++++++++++
 tools/perf/util/symbol.c      |   97 +++++++++++++++
 tools/perf/util/symbol.h      |   12 ++
 tools/perf/util/util.h        |    1 +
 14 files changed, 303 insertions(+), 521 deletions(-)
 create mode 100644 tools/perf/util/event.h
 create mode 100644 tools/perf/util/map.c
#15 lore raw
In reply to Frederic Weisbecker
Quoted 6 lines · Frederic Weisbecker

Ingo,

This set factorizes the common definition of structs, functions, variables inside perf tools to make it easier for perf trace to be created.

Quoted 6 lines

I guess this patchset only factorizes 10 % of what could be done, the largest part is the intersection between perf report and perf annotate. It's a lot of work.

I guess I will do the rest in separate patchsets while writing perf trace.

Pulled, thanks Frederic!

Ingo

maintainer
#16 lore raw
In reply to Frederic Weisbecker
Quoted 6 lines · Frederic Weisbecker

Ingo,

This set factorizes the common definition of structs, functions, variables inside perf tools to make it easier for perf trace to be created.

Quoted 6 lines

I guess this patchset only factorizes 10 % of what could be done, the largest part is the intersection between perf report and perf annotate. It's a lot of work.

I guess I will do the rest in separate patchsets while writing perf trace.

Awesome, much needed cleanups.

Thanks