Skip to contentSkip to conversation

perf tools: Unify perf.data mapping and events handling

PATCH Superseded Frederic Weisbecker 1 participant 3 messages Oct 7, 2009 – Oct 8, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Unify perf.data mapping and events handling

This librarizes the perf.data file mapping and handling in various perf tools, roughly reducing the amount of code and fixing the places that mmap from beginning of the file whereas we want to mmap from the beginning of the data, leading to page faults because the mmap window is too small since the trace info are written in the file too.

TODO:

- Convert perf timechart too
- Fix strange huge number of total samples reported in perf report

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 tools/perf/Makefile         |    2 +
 tools/perf/builtin-report.c |  211 +++++++------------------------------------
 tools/perf/builtin-sched.c  |  140 ++++++-----------------------
 tools/perf/builtin-trace.c  |  129 ++++-----------------------
 4 files changed, 81 insertions(+), 401 deletions(-)
tools/perf/Makefile +2 -0
index 5a42996..495eb6d 100644
@@ -342,6 +342,7 @@ LIB_H += util/values.h
 LIB_H += util/sort.h
 LIB_H += util/hist.h
 LIB_H += util/thread.h
+LIB_H += util/data_map.h
 
 LIB_OBJS += util/abspath.o
 LIB_OBJS += util/alias.o
@@ -378,6 +379,7 @@ LIB_OBJS += util/trace-event-info.o
 LIB_OBJS += util/svghelper.o
 LIB_OBJS += util/sort.o
 LIB_OBJS += util/hist.o
+LIB_OBJS += util/data_map.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-report.c +34 -177

285 lines not on this page · raw message

tools/perf/builtin-sched.c +27 -113

184 lines not on this page · raw message

tools/perf/builtin-trace.c +18 -111

167 lines not on this page · raw message

Signature · 1 line
1.6.2.3
#1 lore raw

PATCH v2 1/1 perf tools: Unify perf.data mapping and events handling

Quoted 16 lines · Frederic Weisbecker

This librarizes the perf.data file mapping and handling in various perf tools, roughly reducing the amount of code and fixing the places that mmap from beginning of the file whereas we want to mmap from the beginning of the data, leading to page faults because the mmap window is too small since the trace info are written in the file too.

TODO:

- Convert perf timechart too
- Fix strange huge number of total samples reported in perf report

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Quoted 6 lines
---
 tools/perf/Makefile         |    2 +
 tools/perf/builtin-report.c |  211 +++++++------------------------------------
 tools/perf/builtin-sched.c  |  140 ++++++-----------------------
 tools/perf/builtin-trace.c  |  129 ++++-----------------------
 4 files changed, 81 insertions(+), 401 deletions(-)

Sorry.
I'm really unable to post a correct first version of a patch :-(

---

Quoted 1 line

From 92b73f8ff51de5434588c84384312a26ac9f291a Mon Sep 17 00:00:00 2001

From: Frederic Weisbecker <[email protected]>
Date: Wed, 7 Oct 2009 12:38:06 +0200
Subject: [PATCH v2] perf tools: Unify perf.data mapping and events handling

This librarizes the perf.data file mapping and handling in various perf tools, roughly reducing the amount of code and fixing the places that mmap from beginning of the file whereas we want to mmap from the beginning of the data, leading to page fault because the mmap window is too small since the trace info are written in the file too.

v2: Forgot to git-add data_map.[c|h]

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 tools/perf/Makefile         |    2 +
 tools/perf/builtin-report.c |  211 +++++++----------------------------------
 tools/perf/builtin-sched.c  |  140 +++++----------------------
 tools/perf/builtin-trace.c  |  129 ++++---------------------
 tools/perf/util/data_map.c  |  222 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/data_map.h  |   31 ++++++
 6 files changed, 334 insertions(+), 401 deletions(-)
 create mode 100644 tools/perf/util/data_map.c
 create mode 100644 tools/perf/util/data_map.h
tools/perf/Makefile +2 -0
index 5a42996..495eb6d 100644
@@ -342,6 +342,7 @@ LIB_H += util/values.h
 LIB_H += util/sort.h
 LIB_H += util/hist.h
 LIB_H += util/thread.h
+LIB_H += util/data_map.h
 
 LIB_OBJS += util/abspath.o
 LIB_OBJS += util/alias.o
@@ -378,6 +379,7 @@ LIB_OBJS += util/trace-event-info.o
 LIB_OBJS += util/svghelper.o
 LIB_OBJS += util/sort.o
 LIB_OBJS += util/hist.o
+LIB_OBJS += util/data_map.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-report.c +34 -177

285 lines not on this page · raw message

tools/perf/builtin-sched.c +27 -113

184 lines not on this page · raw message

tools/perf/builtin-trace.c +18 -111

167 lines not on this page · raw message

tools/perf/util/data_map.c new file +222 -0

222 lines not on this page · raw message

tools/perf/util/data_map.h new file +31 -0
new file mode 100644
index 0000000..716d105
@@ -0,0 +1,31 @@
+#ifndef __PERF_DATAMAP_H
+#define __PERF_DATAMAP_H
+
+#include "event.h"
+#include "header.h"
+
+typedef int (*event_type_handler_t)(event_t *, unsigned long, unsigned long);
+
+struct perf_file_handler {
+	event_type_handler_t	process_sample_event;
+	event_type_handler_t	process_mmap_event;
+	event_type_handler_t	process_comm_event;
+	event_type_handler_t	process_fork_event;
+	event_type_handler_t	process_exit_event;
+	event_type_handler_t	process_lost_event;
+	event_type_handler_t	process_read_event;
+	event_type_handler_t	process_throttle_event;
+	event_type_handler_t	process_unthrottle_event;
+	int			(*sample_type_check)(u64 sample_type);
+	unsigned long		total_unknown;
+};
+
+void register_perf_file_handler(struct perf_file_handler *handler);
+int mmap_dispatch_perf_file(struct perf_header **pheader,
+			    const char *input_name,
+			    int force,
+			    int full_paths,
+			    int *cwdlen,
+			    char **cwd);
+
+#endif
Signature · 1 line
1.6.2.3
#2 lore raw
Commit-ID:  016e92fbc9ef33689cf654f343a94383d43235e7
Gitweb:     http://git.kernel.org/tip/016e92fbc9ef33689cf654f343a94383d43235e7
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Wed, 7 Oct 2009 12:47:31 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 8 Oct 2009 16:56:32 +0200

perf tools: Unify perf.data mapping and events handling

This librarizes the perf.data file mapping and handling in various perf tools, roughly reducing the amount of code and fixing the places that mmap from beginning of the file whereas we want to mmap from the beginning of the data, leading to page fault because the mmap window is too small since the trace info are written in the file too.

TODO:

- convert perf timechart too

Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arjan van de Ven <[email protected]>

LKML-Reference: <20091007104729.GD5043@nowhere>

---
 tools/perf/Makefile         |    2 +
 tools/perf/builtin-report.c |  211 +++++++----------------------------------
 tools/perf/builtin-sched.c  |  140 +++++----------------------
 tools/perf/builtin-trace.c  |  129 ++++---------------------
 tools/perf/util/data_map.c  |  222 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/data_map.h  |   31 ++++++
 6 files changed, 334 insertions(+), 401 deletions(-)
tools/perf/Makefile +2 -0
index 5a42996..495eb6d 100644
@@ -342,6 +342,7 @@ LIB_H += util/values.h
 LIB_H += util/sort.h
 LIB_H += util/hist.h
 LIB_H += util/thread.h
+LIB_H += util/data_map.h
 
 LIB_OBJS += util/abspath.o
 LIB_OBJS += util/alias.o
@@ -378,6 +379,7 @@ LIB_OBJS += util/trace-event-info.o
 LIB_OBJS += util/svghelper.o
 LIB_OBJS += util/sort.o
 LIB_OBJS += util/hist.o
+LIB_OBJS += util/data_map.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/builtin-report.c +34 -177

285 lines not on this page · raw message

tools/perf/builtin-sched.c +27 -113

184 lines not on this page · raw message

tools/perf/builtin-trace.c +18 -111

167 lines not on this page · raw message

tools/perf/util/data_map.c new file +222 -0

222 lines not on this page · raw message

tools/perf/util/data_map.h new file +31 -0
new file mode 100644
index 0000000..716d105
@@ -0,0 +1,31 @@
+#ifndef __PERF_DATAMAP_H
+#define __PERF_DATAMAP_H
+
+#include "event.h"
+#include "header.h"
+
+typedef int (*event_type_handler_t)(event_t *, unsigned long, unsigned long);
+
+struct perf_file_handler {
+	event_type_handler_t	process_sample_event;
+	event_type_handler_t	process_mmap_event;
+	event_type_handler_t	process_comm_event;
+	event_type_handler_t	process_fork_event;
+	event_type_handler_t	process_exit_event;
+	event_type_handler_t	process_lost_event;
+	event_type_handler_t	process_read_event;
+	event_type_handler_t	process_throttle_event;
+	event_type_handler_t	process_unthrottle_event;
+	int			(*sample_type_check)(u64 sample_type);
+	unsigned long		total_unknown;
+};
+
+void register_perf_file_handler(struct perf_file_handler *handler);
+int mmap_dispatch_perf_file(struct perf_header **pheader,
+			    const char *input_name,
+			    int force,
+			    int full_paths,
+			    int *cwdlen,
+			    char **cwd);
+
+#endif