Skip to contentSkip to conversation

perf: Add a timestamp to fork events

PATCH In review Arjan van de Ven 5 participants 24 messages Sep 12, 2009 – Sep 19, 2009 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/8 perf: Add a timestamp to fork events

Quoted 1 line

From 52d6521b9c81230e3a318dfc741274d6601374ca Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:52:47 +0200
Subject: [PATCH] perf: Add a timestamp to fork events

timechart needs to know when a process forked, in order to be able to visualize properly when tasks start.

This patch adds a time field to the event structure, and fills it in appropriately.

---
 include/linux/perf_counter.h |    2 ++
 kernel/perf_counter.c        |   11 +++++++++--
 tools/perf/util/event.h      |    1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +2 -0
index 972f90d..5fe6898 100644
@@ -332,6 +332,7 @@ enum perf_event_type {
 	 *	struct perf_event_header	header;
 	 *	u32				pid, ppid;
 	 *	u32				tid, ptid;
+	 *	u64				time;
 	 * };
 	 */
 	PERF_EVENT_EXIT			= 4,
@@ -352,6 +353,7 @@ enum perf_event_type {
 	 *	struct perf_event_header	header;
 	 *	u32				pid, ppid;
 	 *	u32				tid, ptid;
+	 *	{ u64				time;     } && PERF_SAMPLE_TIME
 	 * };
 	 */
 	PERF_EVENT_FORK			= 7,
kernel/perf_counter.c +9 -2
index e0d91fd..25490db 100644
@@ -3071,6 +3071,7 @@ struct perf_task_event {
 		u32				ppid;
 		u32				tid;
 		u32				ptid;
+		u64				time;
 	} event;
 };
 
@@ -3078,9 +3079,12 @@ static void perf_counter_task_output(struct perf_counter *counter,
 				     struct perf_task_event *task_event)
 {
 	struct perf_output_handle handle;
-	int size = task_event->event.header.size;
+	int size;
 	struct task_struct *task = task_event->task;
-	int ret = perf_output_begin(&handle, counter, size, 0, 0);
+	int ret;
+
+	size  = task_event->event.header.size;
+	ret = perf_output_begin(&handle, counter, size, 0, 0);
 
 	if (ret)
 		return;
@@ -3091,7 +3095,10 @@ static void perf_counter_task_output(struct perf_counter *counter,
 	task_event->event.tid = perf_counter_tid(counter, task);
 	task_event->event.ptid = perf_counter_tid(counter, current);
 
+	task_event->event.time = sched_clock();
+
 	perf_output_put(&handle, task_event->event);
+
 	perf_output_end(&handle);
 }
 
tools/perf/util/event.h +1 -0
index fa2d4e9..1545349 100644
@@ -39,6 +39,7 @@ struct fork_event {
 	struct perf_event_header header;
 	u32 pid, ppid;
 	u32 tid, ptid;
+	u64 time;
 };
 
 struct lost_event {
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#2 lore raw
Commit-ID:  393b2ad8c757ba3ccd2a99ca5bbcd6db4d3fa53d
Gitweb:     http://git.kernel.org/tip/393b2ad8c757ba3ccd2a99ca5bbcd6db4d3fa53d
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 07:52:47 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:10 +0200

perf: Add a timestamp to fork events

perf timechart needs to know when a process forked, in order to be able to visualize properly when tasks start.

This patch adds a time field to the event structure, and fills it in appropriately.

LKML-Reference: <[email protected]>

---
 include/linux/perf_counter.h |    2 ++
 kernel/perf_counter.c        |   11 +++++++++--
 tools/perf/util/event.h      |    1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +2 -0
index c7375f9..bd34100 100644
@@ -336,6 +336,7 @@ enum perf_event_type {
 	 *	struct perf_event_header	header;
 	 *	u32				pid, ppid;
 	 *	u32				tid, ptid;
+	 *	u64				time;
 	 * };
 	 */
 	PERF_EVENT_EXIT			= 4,
@@ -356,6 +357,7 @@ enum perf_event_type {
 	 *	struct perf_event_header	header;
 	 *	u32				pid, ppid;
 	 *	u32				tid, ptid;
+	 *	{ u64				time;     } && PERF_SAMPLE_TIME
 	 * };
 	 */
 	PERF_EVENT_FORK			= 7,
kernel/perf_counter.c +9 -2
index d013f4e..d5899b6 100644
@@ -3083,6 +3083,7 @@ struct perf_task_event {
 		u32				ppid;
 		u32				tid;
 		u32				ptid;
+		u64				time;
 	} event;
 };
 
@@ -3090,9 +3091,12 @@ static void perf_counter_task_output(struct perf_counter *counter,
 				     struct perf_task_event *task_event)
 {
 	struct perf_output_handle handle;
-	int size = task_event->event.header.size;
+	int size;
 	struct task_struct *task = task_event->task;
-	int ret = perf_output_begin(&handle, counter, size, 0, 0);
+	int ret;
+
+	size  = task_event->event.header.size;
+	ret = perf_output_begin(&handle, counter, size, 0, 0);
 
 	if (ret)
 		return;
@@ -3103,7 +3107,10 @@ static void perf_counter_task_output(struct perf_counter *counter,
 	task_event->event.tid = perf_counter_tid(counter, task);
 	task_event->event.ptid = perf_counter_tid(counter, current);
 
+	task_event->event.time = perf_clock();
+
 	perf_output_put(&handle, task_event->event);
+
 	perf_output_end(&handle);
 }
 
tools/perf/util/event.h +1 -0
index 2495529..28a579f 100644
@@ -39,6 +39,7 @@ struct fork_event {
 	struct perf_event_header header;
 	u32 pid, ppid;
 	u32 tid, ptid;
+	u64 time;
 };
 
 struct lost_event {
#3 lore raw

PATCH 2/8 perf: Store trace event name/id pairs in perf.data

In reply to a message not in the archive
Quoted 1 line

From c9d9dfc617df7a6a6029feb486f2433b7d825ef4 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:52:51 +0200
Subject: [PATCH] perf: Store trace event name/id pairs in perf.data

The trace event name<->id mapping is dynamic for each kernel compile. In order for perf.data to be useable outside the actual system, we thus need to store a table of this mapping for later use.

This patch adds this table to perf.data, and provides helper functions for lookup up fields from this table.

To avoid mistakes, lookup-from-table is kept completely seprate from lookup-from-local-debugfs.

---
 tools/perf/util/header.c       |   59 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h       |    6 ++++
 tools/perf/util/parse-events.c |   25 +++++++++++++++++
 3 files changed, 90 insertions(+), 0 deletions(-)
tools/perf/util/header.c +59 -0
index ec4d4c2..ef91145 100644
@@ -86,6 +86,44 @@ void perf_header__add_attr(struct perf_header *self,
 	self->attr[pos] = attr;
 }
 
+struct perf_trace_event_type {
+	u64	event_id;
+	char	name[64];
+};
+
+static int event_count;
+static struct perf_trace_event_type *events;
+
+void perf_header__push_event(u64 id, const char *name)
+{
+	if (strlen(name) > 64)
+		printf("Event %s will be truncated\n", name);
+
+	if (!events) {
+		events = malloc(sizeof(struct perf_trace_event_type));
+		if (!events)
+			die("nomem");
+	} else {
+		events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type));
+		if (!events)
+			die("nomem");
+	}
+	memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
+	events[event_count].event_id = id;
+	strncpy(events[event_count].name, name, 63);
+	event_count++;
+}
+
+char *perf_header__find_event(u64 id)
+{
+	int i;
+	for (i = 0 ; i < event_count; i++) {
+		if (events[i].event_id == id)
+			return events[i].name;
+	}
+	return NULL;
+}
+
 static const char *__perf_magic = "PERFFILE";
 
 #define PERF_MAGIC	(*(u64 *)__perf_magic)
@@ -106,6 +144,7 @@ struct perf_file_header {
 	u64				attr_size;
 	struct perf_file_section	attrs;
 	struct perf_file_section	data;
+	struct perf_file_section	event_types;
 };
 
 static void do_write(int fd, void *buf, size_t size)
@@ -154,6 +193,11 @@ void perf_header__write(struct perf_header *self, int fd)
 		do_write(fd, &f_attr, sizeof(f_attr));
 	}
 
+	self->event_offset = lseek(fd, 0, SEEK_CUR);
+	self->event_size = event_count * sizeof(struct perf_trace_event_type);
+	if (events)
+		do_write(fd, events, self->event_size);
+
 
 	self->data_offset = lseek(fd, 0, SEEK_CUR);
 
@@ -169,6 +213,10 @@ void perf_header__write(struct perf_header *self, int fd)
 			.offset = self->data_offset,
 			.size	= self->data_size,
 		},
+		.event_types = {
+			.offset = self->event_offset,
+			.size	= self->event_size,
+		},
 	};
 
 	lseek(fd, 0, SEEK_SET);
@@ -234,6 +282,17 @@ struct perf_header *perf_header__read(int fd)
 		lseek(fd, tmp, SEEK_SET);
 	}
 
+	if (f_header.event_types.size) {
+		lseek(fd, f_header.event_types.offset, SEEK_SET);
+		events = malloc(f_header.event_types.size);
+		if (!events)
+			die("nomem");
+		do_read(fd, events, f_header.event_types.size);
+		event_count =  f_header.event_types.size / sizeof(struct perf_trace_event_type);
+	}
+	self->event_offset = f_header.event_types.offset;
+	self->event_size   = f_header.event_types.size;
+
 	self->data_offset = f_header.data.offset;
 	self->data_size   = f_header.data.size;
 
tools/perf/util/header.h +6 -0
index 5d0a72e..7b0e84a 100644
@@ -19,6 +19,8 @@ struct perf_header {
 	s64 attr_offset;
 	u64 data_offset;
 	u64 data_size;
+	u64 event_offset;
+	u64 event_size;
 };
 
 struct perf_header *perf_header__read(int fd);
@@ -27,6 +29,10 @@ void perf_header__write(struct perf_header *self, int fd);
 void perf_header__add_attr(struct perf_header *self,
 			   struct perf_header_attr *attr);
 
+void perf_header__push_event(u64 id, const char *name);
+char *perf_header__find_event(u64 id);
+
+
 struct perf_header_attr *
 perf_header_attr__new(struct perf_counter_attr *attr);
 void perf_header_attr__add_id(struct perf_header_attr *self, u64 id);
tools/perf/util/parse-events.c +25 -0
index a587d41..37f1357 100644
@@ -6,6 +6,7 @@
 #include "exec_cmd.h"
 #include "string.h"
 #include "cache.h"
+#include "header.h"
 
 int					nr_counters;
 
@@ -583,10 +584,34 @@ static int parse_event_symbols(const char **str, struct perf_counter_attr *attr)
 	return 1;
 }
 
+static void store_event_type(const char *orgname)
+{
+	char filename[PATH_MAX], *c;
+	FILE *file;
+	int id;
+
+	sprintf(filename, "/sys/kernel/debug/tracing/events/%s/id", orgname);
+	c = strchr(filename, ':');
+	if (c)
+		*c = '/';
+
+	file = fopen(filename, "r");
+	if (!file)
+		return;
+	if (fscanf(file, "%i", &id) < 1)
+		die("cannot store event ID");
+	fclose(file);
+	perf_header__push_event(id, orgname);
+}
+
+
 int parse_events(const struct option *opt __used, const char *str, int unset __used)
 {
 	struct perf_counter_attr attr;
 
+	if (strchr(str, ':'))
+		store_event_type(str);
+
 	for (;;) {
 		if (nr_counters == MAX_COUNTERS)
 			return -1;
Signature · 9 lines
1.6.0.6




-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#4 lore raw

Re: [PATCH 2/8] perf: Store trace event name/id pairs in perf.data

Quoted 46 lines · Arjan van de Ven

From c9d9dfc617df7a6a6029feb486f2433b7d825ef4 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:52:51 +0200
Subject: [PATCH] perf: Store trace event name/id pairs in perf.data

The trace event name<->id mapping is dynamic for each kernel compile. In order for perf.data to be useable outside the actual system, we thus need to store a table of this mapping for later use.

This patch adds this table to perf.data, and provides helper functions for lookup up fields from this table.

To avoid mistakes, lookup-from-table is kept completely seprate from lookup-from-local-debugfs.

---
 tools/perf/util/header.c       |   59 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h       |    6 ++++
 tools/perf/util/parse-events.c |   25 +++++++++++++++++
 3 files changed, 90 insertions(+), 0 deletions(-)
tools/perf/util/header.c +16 -0
index ec4d4c2..ef91145 100644
@@ -86,6 +86,44 @@ void perf_header__add_attr(struct perf_header *self,
 	self->attr[pos] = attr;
 }
 
+struct perf_trace_event_type {
+	u64	event_id;
+	char	name[64];
+};
+
+static int event_count;
+static struct perf_trace_event_type *events;
+
+void perf_header__push_event(u64 id, const char *name)
+{
+	if (strlen(name) > 64)
+		printf("Event %s will be truncated\n", name);
+
+	if (!events) {
+		events = malloc(sizeof(struct perf_trace_event_type));
+		if (!events)

tools/perf/util/header.c void perf_header__add_attr(struct perf_header *self, · line 114

Quoted 10 lines
tools/perf/util/header.c +10 -0
+			die("nomem");
+	} else {
+		events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type));
+		if (!events)
+			die("nomem");
+	}
+	memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
+	events[event_count].event_id = id;
+	strncpy(events[event_count].name, name, 63);
+	event_count++;

This has the string length limit '64' embedded in 3 open-coded forms...

Ingo

#5 lore raw

[tip:perfcounters/core] perf: Store trace event name/id pairs in perf.data

In reply to Arjan van de Ven
Commit-ID:  8755a8f27ae590dde225f9005ee18c6d9c4c6d78
Gitweb:     http://git.kernel.org/tip/8755a8f27ae590dde225f9005ee18c6d9c4c6d78
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 07:52:51 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:11 +0200

perf: Store trace event name/id pairs in perf.data

The trace event name<->id mapping is dynamic for each kernel compile. In order for perf.data to be useable outside the actual system, we thus need to store a table of this mapping for later use.

This patch adds this table to perf.data, and provides helper functions for lookup up fields from this table.

To avoid mistakes, lookup-from-table is kept completely seprate from lookup-from-local-debugfs.

LKML-Reference: <[email protected]>

---
 tools/perf/util/header.c       |   59 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h       |    6 ++++
 tools/perf/util/parse-events.c |   25 +++++++++++++++++
 3 files changed, 90 insertions(+), 0 deletions(-)
tools/perf/util/header.c +59 -0
index ec4d4c2..ef91145 100644
@@ -86,6 +86,44 @@ void perf_header__add_attr(struct perf_header *self,
 	self->attr[pos] = attr;
 }
 
+struct perf_trace_event_type {
+	u64	event_id;
+	char	name[64];
+};
+
+static int event_count;
+static struct perf_trace_event_type *events;
+
+void perf_header__push_event(u64 id, const char *name)
+{
+	if (strlen(name) > 64)
+		printf("Event %s will be truncated\n", name);
+
+	if (!events) {
+		events = malloc(sizeof(struct perf_trace_event_type));
+		if (!events)
+			die("nomem");
+	} else {
+		events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type));
+		if (!events)
+			die("nomem");
+	}
+	memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
+	events[event_count].event_id = id;
+	strncpy(events[event_count].name, name, 63);
+	event_count++;
+}
+
+char *perf_header__find_event(u64 id)
+{
+	int i;
+	for (i = 0 ; i < event_count; i++) {
+		if (events[i].event_id == id)
+			return events[i].name;
+	}
+	return NULL;
+}
+
 static const char *__perf_magic = "PERFFILE";
 
 #define PERF_MAGIC	(*(u64 *)__perf_magic)
@@ -106,6 +144,7 @@ struct perf_file_header {
 	u64				attr_size;
 	struct perf_file_section	attrs;
 	struct perf_file_section	data;
+	struct perf_file_section	event_types;
 };
 
 static void do_write(int fd, void *buf, size_t size)
@@ -154,6 +193,11 @@ void perf_header__write(struct perf_header *self, int fd)
 		do_write(fd, &f_attr, sizeof(f_attr));
 	}
 
+	self->event_offset = lseek(fd, 0, SEEK_CUR);
+	self->event_size = event_count * sizeof(struct perf_trace_event_type);
+	if (events)
+		do_write(fd, events, self->event_size);
+
 
 	self->data_offset = lseek(fd, 0, SEEK_CUR);
 
@@ -169,6 +213,10 @@ void perf_header__write(struct perf_header *self, int fd)
 			.offset = self->data_offset,
 			.size	= self->data_size,
 		},
+		.event_types = {
+			.offset = self->event_offset,
+			.size	= self->event_size,
+		},
 	};
 
 	lseek(fd, 0, SEEK_SET);
@@ -234,6 +282,17 @@ struct perf_header *perf_header__read(int fd)
 		lseek(fd, tmp, SEEK_SET);
 	}
 
+	if (f_header.event_types.size) {
+		lseek(fd, f_header.event_types.offset, SEEK_SET);
+		events = malloc(f_header.event_types.size);
+		if (!events)
+			die("nomem");
+		do_read(fd, events, f_header.event_types.size);
+		event_count =  f_header.event_types.size / sizeof(struct perf_trace_event_type);
+	}
+	self->event_offset = f_header.event_types.offset;
+	self->event_size   = f_header.event_types.size;
+
 	self->data_offset = f_header.data.offset;
 	self->data_size   = f_header.data.size;
 
tools/perf/util/header.h +6 -0
index 5d0a72e..7b0e84a 100644
@@ -19,6 +19,8 @@ struct perf_header {
 	s64 attr_offset;
 	u64 data_offset;
 	u64 data_size;
+	u64 event_offset;
+	u64 event_size;
 };
 
 struct perf_header *perf_header__read(int fd);
@@ -27,6 +29,10 @@ void perf_header__write(struct perf_header *self, int fd);
 void perf_header__add_attr(struct perf_header *self,
 			   struct perf_header_attr *attr);
 
+void perf_header__push_event(u64 id, const char *name);
+char *perf_header__find_event(u64 id);
+
+
 struct perf_header_attr *
 perf_header_attr__new(struct perf_counter_attr *attr);
 void perf_header_attr__add_id(struct perf_header_attr *self, u64 id);
tools/perf/util/parse-events.c +25 -0
index a9bdcab..89172fd 100644
@@ -6,6 +6,7 @@
 #include "exec_cmd.h"
 #include "string.h"
 #include "cache.h"
+#include "header.h"
 
 int					nr_counters;
 
@@ -687,11 +688,35 @@ modifier:
 	return ret;
 }
 
+static void store_event_type(const char *orgname)
+{
+	char filename[PATH_MAX], *c;
+	FILE *file;
+	int id;
+
+	sprintf(filename, "/sys/kernel/debug/tracing/events/%s/id", orgname);
+	c = strchr(filename, ':');
+	if (c)
+		*c = '/';
+
+	file = fopen(filename, "r");
+	if (!file)
+		return;
+	if (fscanf(file, "%i", &id) < 1)
+		die("cannot store event ID");
+	fclose(file);
+	perf_header__push_event(id, orgname);
+}
+
+
 int parse_events(const struct option *opt __used, const char *str, int unset __used)
 {
 	struct perf_counter_attr attr;
 	enum event_result ret;
 
+	if (strchr(str, ':'))
+		store_event_type(str);
+
 	for (;;) {
 		if (nr_counters == MAX_COUNTERS)
 			return -1;
#6 lore raw

PATCH 3/8 perf: Allow perf utilities to have "callback" options without arguments

In reply to a message not in the archive
Quoted 2 lines

From b37c714203e12c2104b2fae41c6f4ea4fa589528 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:52:54 +0200
Subject: [PATCH] perf: Allow perf utilities to have "callback" options without arguments

timechart needs to add a "callback" type command line argument that does not take arguments.

This patch adds the parse-options.h infrastructure to make this possible.

---
 tools/perf/util/parse-options.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/parse-options.h +2 -0
index 8aa3464..2ee248f 100644
@@ -104,6 +104,8 @@ struct option {
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f) }
+#define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
+	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = PARSE_OPT_LASTARG_DEFAULT }
 
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#7 lore raw

[tip:perfcounters/core] perf: Allow perf utilities to have "callback" options without arguments

Commit-ID:  a79d7db9fdb0037925ffa31f6ff9b189ff75d235
Gitweb:     http://git.kernel.org/tip/a79d7db9fdb0037925ffa31f6ff9b189ff75d235
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 07:52:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:11 +0200

perf: Allow perf utilities to have "callback" options without arguments

timechart needs to add a "callback" type command line argument that does not take arguments.

This patch adds the parse-options.h infrastructure to make this possible.

LKML-Reference: <[email protected]>

---
 tools/perf/util/parse-options.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/parse-options.h +2 -0
index 8aa3464..2ee248f 100644
@@ -104,6 +104,8 @@ struct option {
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f) }
+#define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
+	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
 	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = PARSE_OPT_LASTARG_DEFAULT }
 
#8 lore raw

PATCH 4/8 perf: Add a sample_event type to the event_union

In reply to a message not in the archive
Quoted 1 line

From 4837fa586ab440d6a79f542b90994c1dde9be8ef Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:53:00 +0200
Subject: [PATCH] perf: Add a sample_event type to the event_union

Add a sample_event type to the event_union so that raw samples can be processed easily.

---
 tools/perf/util/event.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
tools/perf/util/event.h +7 -0
index 1545349..33ced5a 100644
@@ -60,6 +60,12 @@ struct read_event {
 	u64 id;
 };
 
+struct sample_event{
+	struct perf_event_header        header;
+	u64 array[];
+};
+
+
 typedef union event_union {
 	struct perf_event_header	header;
 	struct ip_event			ip;
@@ -68,6 +74,7 @@ typedef union event_union {
 	struct fork_event		fork;
 	struct lost_event		lost;
 	struct read_event		read;
+	struct sample_event		sample;
 } event_t;
 
 struct map {
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#9 lore raw

[tip:perfcounters/core] perf: Add a sample_event type to the event_union

Commit-ID:  fd39e055c4fefa4553efc9030f9903afdc6ee323
Gitweb:     http://git.kernel.org/tip/fd39e055c4fefa4553efc9030f9903afdc6ee323
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 07:53:00 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:12 +0200

perf: Add a sample_event type to the event_union

Add a sample_event type to the event_union so that raw samples can be processed easily.

LKML-Reference: <[email protected]>

---
 tools/perf/util/event.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
tools/perf/util/event.h +7 -0
index 28a579f..018d414 100644
@@ -60,6 +60,12 @@ struct read_event {
 	u64 id;
 };
 
+struct sample_event{
+	struct perf_event_header        header;
+	u64 array[];
+};
+
+
 typedef union event_union {
 	struct perf_event_header	header;
 	struct ip_event			ip;
@@ -68,6 +74,7 @@ typedef union event_union {
 	struct fork_event		fork;
 	struct lost_event		lost;
 	struct read_event		read;
+	struct sample_event		sample;
 } event_t;
 
 struct map {
#10 lore raw

PATCH 5/8 trace: Convert the power tracer into an event tracer

In reply to a message not in the archive
Quoted 1 line

From f591a0f126263733d606838a5d113b9807b12c84 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:53:03 +0200
Subject: [PATCH] trace: Convert the power tracer into an event tracer

This patch converts the existing power tracer into an event tracer, so that power events (C states and frequency changes) can be tracked via "perf".

This also removes the perl script that was used to demo the tracer; its functionality is being replaced entirely with timechart.

---
 arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c |    7 +-
 arch/x86/kernel/process.c                  |   28 +---
 include/trace/events/power.h               |   81 ++++++++++
 include/trace/power.h                      |   32 ----
 kernel/trace/Makefile                      |    2 +-
 kernel/trace/power-traces.c                |   18 +++
 kernel/trace/trace.h                       |    8 -
 kernel/trace/trace_event_types.h           |   10 --
 kernel/trace/trace_power.c                 |  218 ----------------------------
 scripts/tracing/power.pl                   |  108 --------------
 10 files changed, 111 insertions(+), 401 deletions(-)
 create mode 100644 include/trace/events/power.h
 delete mode 100644 include/trace/power.h
 create mode 100644 kernel/trace/power-traces.c
 delete mode 100644 kernel/trace/trace_power.c
 delete mode 100644 scripts/tracing/power.pl
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +2 -5
index ae9b503..dc23bf7 100644
@@ -33,7 +33,7 @@
 #include <linux/cpufreq.h>
 #include <linux/compiler.h>
 #include <linux/dmi.h>
-#include <trace/power.h>
+#include <trace/events/power.h>
 
 #include <linux/acpi.h>
 #include <linux/io.h>
@@ -77,8 +77,6 @@ struct acpi_msr_data {
 
 static DEFINE_PER_CPU(struct acpi_msr_data, msr_data);
 
-DEFINE_TRACE(power_mark);
-
 /* acpi_perf_data is a pointer to percpu data. */
 static struct acpi_processor_performance *acpi_perf_data;
 
@@ -394,7 +392,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 	unsigned int next_perf_state = 0; /* Index into perf table */
 	unsigned int i;
 	int result = 0;
-	struct power_trace it;
 
 	dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
 
@@ -426,7 +423,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 		}
 	}
 
-	trace_power_mark(&it, POWER_PSTATE, next_perf_state);
+	trace_power_frequency(POWER_PSTATE, data->freq_table[next_state].frequency);
 
 	switch (data->cpu_feature) {
 	case SYSTEM_INTEL_MSR_CAPABLE:
arch/x86/kernel/process.c +9 -19
index 1092a1a..98e9cac 100644
@@ -9,7 +9,7 @@
 #include <linux/pm.h>
 #include <linux/clockchips.h>
 #include <linux/random.h>
-#include <trace/power.h>
+#include <trace/events/power.h>
 #include <asm/system.h>
 #include <asm/apic.h>
 #include <asm/syscalls.h>
@@ -27,9 +27,6 @@ EXPORT_SYMBOL(idle_nomwait);
 
 struct kmem_cache *task_xstate_cachep;
 
-DEFINE_TRACE(power_start);
-DEFINE_TRACE(power_end);
-
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
 	*dst = *src;
@@ -289,9 +286,7 @@ static inline int hlt_use_halt(void)
 void default_idle(void)
 {
 	if (hlt_use_halt()) {
-		struct power_trace it;
-
-		trace_power_start(&it, POWER_CSTATE, 1);
+		trace_power_start(POWER_CSTATE, 1);
 		current_thread_info()->status &= ~TS_POLLING;
 		/*
 		 * TS_POLLING-cleared state must be visible before we
@@ -304,7 +299,7 @@ void default_idle(void)
 		else
 			local_irq_enable();
 		current_thread_info()->status |= TS_POLLING;
-		trace_power_end(&it);
+		trace_power_end(0);
 	} else {
 		local_irq_enable();
 		/* loop is done by the caller */
@@ -362,9 +357,7 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
  */
 void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
 {
-	struct power_trace it;
-
-	trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
+	trace_power_start(POWER_CSTATE, (ax>>4)+1);
 	if (!need_resched()) {
 		if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
 			clflush((void *)&current_thread_info()->flags);
@@ -374,15 +367,14 @@ void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
 		if (!need_resched())
 			__mwait(ax, cx);
 	}
-	trace_power_end(&it);
+	trace_power_end(0);
 }
 
 /* Default MONITOR/MWAIT with no hints, used for default C1 state */
 static void mwait_idle(void)
 {
-	struct power_trace it;
 	if (!need_resched()) {
-		trace_power_start(&it, POWER_CSTATE, 1);
+		trace_power_start(POWER_CSTATE, 1);
 		if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
 			clflush((void *)&current_thread_info()->flags);
 
@@ -392,7 +384,7 @@ static void mwait_idle(void)
 			__sti_mwait(0, 0);
 		else
 			local_irq_enable();
-		trace_power_end(&it);
+		trace_power_end(0);
 	} else
 		local_irq_enable();
 }
@@ -404,13 +396,11 @@ static void mwait_idle(void)
  */
 static void poll_idle(void)
 {
-	struct power_trace it;
-
-	trace_power_start(&it, POWER_CSTATE, 0);
+	trace_power_start(POWER_CSTATE, 0);
 	local_irq_enable();
 	while (!need_resched())
 		cpu_relax();
-	trace_power_end(&it);
+	trace_power_end(0);
 }
 
 /*
include/trace/events/power.h new file +81 -0

81 lines not on this page · raw message

include/trace/power.h deleted +0 -32
deleted file mode 100644
index ef20466..0000000
@@ -1,32 +0,0 @@
-#ifndef _TRACE_POWER_H
-#define _TRACE_POWER_H
-
-#include <linux/ktime.h>
-#include <linux/tracepoint.h>
-
-enum {
-	POWER_NONE = 0,
-	POWER_CSTATE = 1,
-	POWER_PSTATE = 2,
-};
-
-struct power_trace {
-	ktime_t			stamp;
-	ktime_t			end;
-	int			type;
-	int			state;
-};
-
-DECLARE_TRACE(power_start,
-	TP_PROTO(struct power_trace *it, unsigned int type, unsigned int state),
-	      TP_ARGS(it, type, state));
-
-DECLARE_TRACE(power_mark,
-	TP_PROTO(struct power_trace *it, unsigned int type, unsigned int state),
-	      TP_ARGS(it, type, state));
-
-DECLARE_TRACE(power_end,
-	TP_PROTO(struct power_trace *it),
-	      TP_ARGS(it));
-
-#endif /* _TRACE_POWER_H */
kernel/trace/Makefile +1 -1
index ce3b1cd..b5ca90b 100644
@@ -42,7 +42,6 @@ obj-$(CONFIG_BOOT_TRACER) += trace_boot.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o
 obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
 obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o
-obj-$(CONFIG_POWER_TRACER) += trace_power.o
 obj-$(CONFIG_KMEMTRACE) += kmemtrace.o
 obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
 obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
@@ -54,6 +53,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_export.o
 obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
 obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o
 obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
+obj-$(CONFIG_EVENT_TRACING) += power-traces.o
 obj-$(CONFIG_KSYM_TRACER) += trace_ksym.o
 
 libftrace-y := ftrace.o
kernel/trace/power-traces.c new file +18 -0
new file mode 100644
index 0000000..cb4fc51
@@ -0,0 +1,18 @@
+/*
+ * Power trace points
+ *
+ * Copyright (C) 2009 Arjan van de Ven <[email protected]>
+ */
+
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/power.h>
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
+
kernel/trace/trace.h +0 -8
index 9027112..f7d0f46 100644
@@ -10,7 +10,6 @@
 #include <linux/ftrace.h>
 #include <trace/boot.h>
 #include <linux/kmemtrace.h>
-#include <trace/power.h>
 
 #include <linux/trace_seq.h>
 #include <linux/ftrace_event.h>
@@ -40,7 +39,6 @@ enum trace_type {
 	TRACE_HW_BRANCHES,
 	TRACE_KMEM_ALLOC,
 	TRACE_KMEM_FREE,
-	TRACE_POWER,
 	TRACE_BLK,
 	TRACE_KSYM,
 
@@ -162,11 +160,6 @@ struct hw_branch_entry {
 	u64			to;
 };
 
-struct trace_power {
-	struct trace_entry	ent;
-	struct power_trace	state_data;
-};
-
 enum kmemtrace_type_id {
 	KMEMTRACE_TYPE_KMALLOC = 0,	/* kmalloc() or kfree(). */
 	KMEMTRACE_TYPE_CACHE,		/* kmem_cache_*(). */
@@ -318,7 +311,6 @@ extern void __ftrace_bad_type(void);
 		IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry,	\
 			  TRACE_GRAPH_RET);		\
 		IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\
-		IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \
 		IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry,	\
 			  TRACE_KMEM_ALLOC);	\
 		IF_ASSIGN(var, ent, struct kmemtrace_free_entry,	\
kernel/trace/trace_event_types.h +0 -10
index 6db005e..d7ced2c 100644
@@ -142,16 +142,6 @@ TRACE_EVENT_FORMAT(hw_branch, TRACE_HW_BRANCHES, hw_branch_entry, ignore,
 	TP_RAW_FMT("from: %llx to: %llx")
 );
 
-TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore,
-	TRACE_STRUCT(
-		TRACE_FIELD_SIGN(ktime_t, state_data.stamp, stamp, 1)
-		TRACE_FIELD_SIGN(ktime_t, state_data.end, end, 1)
-		TRACE_FIELD(int, state_data.type, type)
-		TRACE_FIELD(int, state_data.state, state)
-	),
-	TP_RAW_FMT("%llx->%llx type:%u state:%u")
-);
-
 TRACE_EVENT_FORMAT(kmem_alloc, TRACE_KMEM_ALLOC, kmemtrace_alloc_entry, ignore,
 	TRACE_STRUCT(
 		TRACE_FIELD(enum kmemtrace_type_id, type_id, type_id)
kernel/trace/trace_power.c deleted +0 -218

218 lines not on this page · raw message

scripts/tracing/power.pl deleted +0 -108

108 lines not on this page · raw message

Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#11 lore raw

Re: [PATCH 5/8] trace: Convert the power tracer into an event tracer

Quoted 5 lines · Arjan van de Ven
Quoted 1 line

From f591a0f126263733d606838a5d113b9807b12c84 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:53:03 +0200
Subject: [PATCH] trace: Convert the power tracer into an event tracer

Quoted 7 lines

This patch converts the existing power tracer into an event tracer, so that power events (C states and frequency changes) can be tracked via "perf".

This also removes the perl script that was used to demo the tracer; its functionality is being replaced entirely with timechart.

And Documentation/power.txt needs update, or just remove it?

Quoted 1 line

...

kernel/trace/power-traces.c

Quoted 5 lines
kernel/trace/power-traces.c new file +0 -0
new file mode 100644
index 0000000..cb4fc51

This file is not necessarily needed.

You can just add definition of CREATE_TRACE_POINTS in process.c.

Quoted 9 lines
kernel/trace/power-traces.c new file +8 -0
@@ -0,0 +1,18 @@
+/*
+ * Power trace points
+ *
+ * Copyright (C) 2009 Arjan van de Ven <[email protected]>
+ */
+
+#include <linux/string.h>
+#include <linux/types.h>

kernel/trace/power-traces.c line 18

Quoted 10 lines
kernel/trace/power-traces.c new file +10 -0
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/power.h>
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
+

I think it's power_frequency that needs to be exported?

#12 lore raw

Re: [PATCH 5/8] trace: Convert the power tracer into an event tracer

Quoted 12 lines · On Tue, 15 Sep 2009 11:43:16 +0800 Li Zefan <[email protected]> wrote:
Quoted 11 lines · Arjan van de Ven
Quoted 2 lines

From f591a0f126263733d606838a5d113b9807b12c84 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:53:03 +0200
Subject: [PATCH] trace: Convert the power tracer into an event tracer

This patch converts the existing power tracer into an event tracer, so that power events (C states and frequency changes) can be tracked via "perf".

Quoted 5 lines
Quoted 3 lines

This also removes the perl script that was used to demo the tracer; its functionality is being replaced entirely with timechart.

And Documentation/power.txt needs update, or just remove it?

remove it; will do

Quoted 13 lines
Quoted 2 lines

...

kernel/trace/power-traces.c

Quoted 5 lines
(quoted diff) +0 -0

b/kernel/trace/power-traces.c new file mode 100644 index 0000000..cb4fc51

kernel/trace/power-traces.c new file +0 -0

This file is not necessarily needed.

Quoted 1 line

You can just add definition of CREATE_TRACE_POINTS in process.c.

hmm it seems existing style to do this in kernel/trace/ though

Quoted 5 lines

kernel/trace/power-traces.c line 18

Quoted 3 lines
kernel/trace/power-traces.c new file +3 -0
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
+

I think it's power_frequency that needs to be exported?

very valid point, will fix.

thank you for reviewing the patch; I will send an updated patch out asap.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#13 lore raw

[tip:perfcounters/core] tracing, perf: Convert the power tracer into an event tracer

In reply to Arjan van de Ven
Commit-ID:  6161352142d5fed4cd753b32e5ccde66e705b14e
Gitweb:     http://git.kernel.org/tip/6161352142d5fed4cd753b32e5ccde66e705b14e
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Thu, 17 Sep 2009 16:11:28 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:12 +0200

tracing, perf: Convert the power tracer into an event tracer

This patch converts the existing power tracer into an event tracer, so that power events (C states and frequency changes) can be tracked via "perf".

This also removes the perl script that was used to demo the tracer; its functionality is being replaced entirely with timechart.

LKML-Reference: <[email protected]>

---
 Documentation/trace/power.txt              |   17 --
 arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c |    7 +-
 arch/x86/kernel/process.c                  |   28 +---
 include/trace/events/power.h               |   81 ++++++++++
 kernel/trace/Makefile                      |    2 +-
 kernel/trace/power-traces.c                |   20 +++
 kernel/trace/trace.h                       |    3 -
 kernel/trace/trace_entries.h               |   17 --
 kernel/trace/trace_power.c                 |  218 ----------------------------
 scripts/tracing/power.pl                   |  108 --------------
 10 files changed, 113 insertions(+), 388 deletions(-)
Documentation/trace/power.txt deleted +0 -17
deleted file mode 100644
index cd805e1..0000000
@@ -1,17 +0,0 @@
-The power tracer collects detailed information about C-state and P-state
-transitions, instead of just looking at the high-level "average"
-information.
-
-There is a helper script found in scrips/tracing/power.pl in the kernel
-sources which can be used to parse this information and create a
-Scalable Vector Graphics (SVG) picture from the trace data.
-
-To use this tracer:
-
-	echo 0 > /sys/kernel/debug/tracing/tracing_enabled
-	echo power > /sys/kernel/debug/tracing/current_tracer
-	echo 1 > /sys/kernel/debug/tracing/tracing_enabled
-	sleep 1
-	echo 0 > /sys/kernel/debug/tracing/tracing_enabled
-	cat /sys/kernel/debug/tracing/trace | \
-		perl scripts/tracing/power.pl > out.sv
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +2 -5
index 4109679..479cc8c 100644
@@ -33,7 +33,7 @@
 #include <linux/cpufreq.h>
 #include <linux/compiler.h>
 #include <linux/dmi.h>
-#include <trace/power.h>
+#include <trace/events/power.h>
 
 #include <linux/acpi.h>
 #include <linux/io.h>
@@ -72,8 +72,6 @@ static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data);
 
 static DEFINE_PER_CPU(struct aperfmperf, old_perf);
 
-DEFINE_TRACE(power_mark);
-
 /* acpi_perf_data is a pointer to percpu data. */
 static struct acpi_processor_performance *acpi_perf_data;
 
@@ -332,7 +330,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 	unsigned int next_perf_state = 0; /* Index into perf table */
 	unsigned int i;
 	int result = 0;
-	struct power_trace it;
 
 	dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
 
@@ -364,7 +361,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 		}
 	}
 
-	trace_power_mark(&it, POWER_PSTATE, next_perf_state);
+	trace_power_frequency(POWER_PSTATE, data->freq_table[next_state].frequency);
 
 	switch (data->cpu_feature) {
 	case SYSTEM_INTEL_MSR_CAPABLE:
arch/x86/kernel/process.c +9 -19
index 071166a..7b60e39 100644
@@ -9,7 +9,7 @@
 #include <linux/pm.h>
 #include <linux/clockchips.h>
 #include <linux/random.h>
-#include <trace/power.h>
+#include <trace/events/power.h>
 #include <asm/system.h>
 #include <asm/apic.h>
 #include <asm/syscalls.h>
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(idle_nomwait);
 
 struct kmem_cache *task_xstate_cachep;
 
-DEFINE_TRACE(power_start);
-DEFINE_TRACE(power_end);
-
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
 	*dst = *src;
@@ -299,9 +296,7 @@ static inline int hlt_use_halt(void)
 void default_idle(void)
 {
 	if (hlt_use_halt()) {
-		struct power_trace it;
-
-		trace_power_start(&it, POWER_CSTATE, 1);
+		trace_power_start(POWER_CSTATE, 1);
 		current_thread_info()->status &= ~TS_POLLING;
 		/*
 		 * TS_POLLING-cleared state must be visible before we
@@ -314,7 +309,7 @@ void default_idle(void)
 		else
 			local_irq_enable();
 		current_thread_info()->status |= TS_POLLING;
-		trace_power_end(&it);
+		trace_power_end(0);
 	} else {
 		local_irq_enable();
 		/* loop is done by the caller */
@@ -372,9 +367,7 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
  */
 void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
 {
-	struct power_trace it;
-
-	trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
+	trace_power_start(POWER_CSTATE, (ax>>4)+1);
 	if (!need_resched()) {
 		if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
 			clflush((void *)&current_thread_info()->flags);
@@ -384,15 +377,14 @@ void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
 		if (!need_resched())
 			__mwait(ax, cx);
 	}
-	trace_power_end(&it);
+	trace_power_end(0);
 }
 
 /* Default MONITOR/MWAIT with no hints, used for default C1 state */
 static void mwait_idle(void)
 {
-	struct power_trace it;
 	if (!need_resched()) {
-		trace_power_start(&it, POWER_CSTATE, 1);
+		trace_power_start(POWER_CSTATE, 1);
 		if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
 			clflush((void *)&current_thread_info()->flags);
 
@@ -402,7 +394,7 @@ static void mwait_idle(void)
 			__sti_mwait(0, 0);
 		else
 			local_irq_enable();
-		trace_power_end(&it);
+		trace_power_end(0);
 	} else
 		local_irq_enable();
 }
@@ -414,13 +406,11 @@ static void mwait_idle(void)
  */
 static void poll_idle(void)
 {
-	struct power_trace it;
-
-	trace_power_start(&it, POWER_CSTATE, 0);
+	trace_power_start(POWER_CSTATE, 0);
 	local_irq_enable();
 	while (!need_resched())
 		cpu_relax();
-	trace_power_end(&it);
+	trace_power_end(0);
 }
 
 /*
include/trace/events/power.h new file +81 -0

81 lines not on this page · raw message

kernel/trace/Makefile +1 -1
index 844164d..26f03ac 100644
@@ -42,7 +42,6 @@ obj-$(CONFIG_BOOT_TRACER) += trace_boot.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o
 obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
 obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o
-obj-$(CONFIG_POWER_TRACER) += trace_power.o
 obj-$(CONFIG_KMEMTRACE) += kmemtrace.o
 obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
 obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
@@ -54,5 +53,6 @@ obj-$(CONFIG_EVENT_TRACING) += trace_export.o
 obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
 obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o
 obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
+obj-$(CONFIG_EVENT_TRACING) += power-traces.o
 
 libftrace-y := ftrace.o
kernel/trace/power-traces.c new file +20 -0
new file mode 100644
index 0000000..e06c6e3
@@ -0,0 +1,20 @@
+/*
+ * Power trace points
+ *
+ * Copyright (C) 2009 Arjan van de Ven <[email protected]>
+ */
+
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/power.h>
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_end);
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_frequency);
+
kernel/trace/trace.h +0 -3
index 86bcff9..405cb85 100644
@@ -11,7 +11,6 @@
 #include <linux/ftrace.h>
 #include <trace/boot.h>
 #include <linux/kmemtrace.h>
-#include <trace/power.h>
 
 #include <linux/trace_seq.h>
 #include <linux/ftrace_event.h>
@@ -37,7 +36,6 @@ enum trace_type {
 	TRACE_HW_BRANCHES,
 	TRACE_KMEM_ALLOC,
 	TRACE_KMEM_FREE,
-	TRACE_POWER,
 	TRACE_BLK,
 
 	__TRACE_LAST_TYPE,
@@ -207,7 +205,6 @@ extern void __ftrace_bad_type(void);
 		IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry,	\
 			  TRACE_GRAPH_RET);		\
 		IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\
-		IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \
 		IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry,	\
 			  TRACE_KMEM_ALLOC);	\
 		IF_ASSIGN(var, ent, struct kmemtrace_free_entry,	\
kernel/trace/trace_entries.h +0 -17
index a431748..ead3d72 100644
@@ -330,23 +330,6 @@ FTRACE_ENTRY(hw_branch, hw_branch_entry,
 	F_printk("from: %llx to: %llx", __entry->from, __entry->to)
 );
 
-FTRACE_ENTRY(power, trace_power,
-
-	TRACE_POWER,
-
-	F_STRUCT(
-		__field_struct(	struct power_trace,	state_data	)
-		__field_desc(	s64,	state_data,	stamp		)
-		__field_desc(	s64,	state_data,	end		)
-		__field_desc(	int,	state_data,	type		)
-		__field_desc(	int,	state_data,	state		)
-	),
-
-	F_printk("%llx->%llx type:%u state:%u",
-		 __entry->stamp, __entry->end,
-		 __entry->type, __entry->state)
-);
-
 FTRACE_ENTRY(kmem_alloc, kmemtrace_alloc_entry,
 
 	TRACE_KMEM_ALLOC,
kernel/trace/trace_power.c deleted +0 -218

218 lines not on this page · raw message

scripts/tracing/power.pl deleted +0 -108

108 lines not on this page · raw message

#14 lore raw

PATCH 6/8 perf: Add a SVG helper library file

In reply to a message not in the archive
Quoted 1 line

From 0aeceb5dd0714f68bc8fc120fc010791c670558d Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 12:52:11 +0200
Subject: [PATCH] perf: Add a SVG helper library file

The timechart tool writes out SVG format output; this patch adds a set of helper functions to abstract dealing with SVG from the core timechart code.

---
 tools/perf/Makefile         |    1 +
 tools/perf/util/svghelper.c |  382 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/svghelper.h |   25 +++
 3 files changed, 408 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/util/svghelper.c
 create mode 100644 tools/perf/util/svghelper.h
tools/perf/Makefile +1 -0
index 9f8d207..a087bf8 100644
@@ -373,6 +373,7 @@ LIB_OBJS += util/thread.o
 LIB_OBJS += util/trace-event-parse.o
 LIB_OBJS += util/trace-event-read.o
 LIB_OBJS += util/trace-event-info.o
+LIB_OBJS += util/svghelper.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/util/svghelper.c new file +382 -0

382 lines not on this page · raw message

tools/perf/util/svghelper.h new file +25 -0
new file mode 100644
index 0000000..ad79b5d
@@ -0,0 +1,25 @@
+#ifndef _INCLUDE_GUARD_SVG_HELPER_
+#define _INCLUDE_GUARD_SVG_HELPER_
+
+#include "types.h"
+
+extern void open_svg(const char *filename, int cpus, int rows);
+extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
+extern void svg_sample(int Yslot, int cpu, u64 start, u64 end, const char *type);
+extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
+
+
+extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name);
+extern void svg_cstate(int cpu, u64 start, u64 end, int type);
+extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
+
+
+extern void svg_time_grid(u64 start, u64 end);
+extern void svg_legenda(void);
+extern void svg_wakeline(u64 start, int row1, int row2);
+extern void svg_partial_wakeline(u64 start, int row1, int row2);
+extern void svg_interrupt(u64 start, int row);
+extern void svg_text(int Yslot, u64 start, const char *text);
+extern void svg_close(void);
+
+#endif
Signature · 9 lines
1.6.0.6




-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#15 lore raw

[tip:perfcounters/core] perf: Add a SVG helper library file

Commit-ID:  f48d55ce7871824eae3065f4d81956d7113eff19
Gitweb:     http://git.kernel.org/tip/f48d55ce7871824eae3065f4d81956d7113eff19
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 12:52:11 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:13 +0200

perf: Add a SVG helper library file

The timechart tool writes out SVG format output; this patch adds a set of helper functions to abstract dealing with SVG from the core timechart code.

LKML-Reference: <[email protected]>

---
 tools/perf/Makefile         |    1 +
 tools/perf/util/svghelper.c |  382 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/svghelper.h |   25 +++
 3 files changed, 408 insertions(+), 0 deletions(-)
tools/perf/Makefile +1 -0
index 2cb8cc3..0388e36 100644
@@ -373,6 +373,7 @@ LIB_OBJS += util/thread.o
 LIB_OBJS += util/trace-event-parse.o
 LIB_OBJS += util/trace-event-read.o
 LIB_OBJS += util/trace-event-info.o
+LIB_OBJS += util/svghelper.o
 
 BUILTIN_OBJS += builtin-annotate.o
 BUILTIN_OBJS += builtin-help.o
tools/perf/util/svghelper.c new file +382 -0

382 lines not on this page · raw message

tools/perf/util/svghelper.h new file +25 -0
new file mode 100644
index 0000000..ad79b5d
@@ -0,0 +1,25 @@
+#ifndef _INCLUDE_GUARD_SVG_HELPER_
+#define _INCLUDE_GUARD_SVG_HELPER_
+
+#include "types.h"
+
+extern void open_svg(const char *filename, int cpus, int rows);
+extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
+extern void svg_sample(int Yslot, int cpu, u64 start, u64 end, const char *type);
+extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
+
+
+extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name);
+extern void svg_cstate(int cpu, u64 start, u64 end, int type);
+extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
+
+
+extern void svg_time_grid(u64 start, u64 end);
+extern void svg_legenda(void);
+extern void svg_wakeline(u64 start, int row1, int row2);
+extern void svg_partial_wakeline(u64 start, int row1, int row2);
+extern void svg_interrupt(u64 start, int row);
+extern void svg_text(int Yslot, u64 start, const char *text);
+extern void svg_close(void);
+
+#endif
#16 lore raw

PATCH 7/8 perf: Add a perf record --timechart option

In reply to a message not in the archive
Quoted 1 line

From 2f2ee48c6cbf556724929c55b6c0842f737e9658 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 12:52:13 +0200
Subject: [PATCH] perf: Add a perf record --timechart option

This patch adds a "perf record --timechart" option, to make it easy to capture traces for use by the timechart tool.

---
 tools/perf/builtin-record.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
tools/perf/builtin-record.c +28 -0
index 99a12fe..f06a447 100644
@@ -47,6 +47,7 @@ static int			append_file			= 0;
 static int			call_graph			= 0;
 static int			inherit_stat			= 0;
 static int			no_samples			= 0;
+static int			timechart			= 0;
 static int			sample_address			= 0;
 
 static long			samples;
@@ -385,6 +386,12 @@ static void create_counter(int counter, int cpu, pid_t pid)
 
 	attr->sample_type	|= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
 
+	if (timechart) {
+		attr->sample_type |= PERF_SAMPLE_CPU;
+		attr->sample_type |= PERF_SAMPLE_TIME;
+		attr->sample_type |= PERF_SAMPLE_RAW;
+	}
+
 	if (freq) {
 		attr->sample_type	|= PERF_SAMPLE_PERIOD;
 		attr->freq		= 1;
@@ -637,6 +644,24 @@ static int __cmd_record(int argc, const char **argv)
 	return 0;
 }
 
+static int do_timechart(const struct option *opt __used, const char *str __used, int unset __used)
+{
+	parse_events(NULL, "power:power_start", 0);
+	parse_events(NULL, "power:power_end", 0);
+	parse_events(NULL, "power:power_frequency", 0);
+	parse_events(NULL, "sched:sched_wakeup", 0);
+	parse_events(NULL, "sched:sched_switch", 0);
+	default_interval = 1;
+	system_wide = 1;
+	timechart = 1;
+	if (!nr_counters) {
+		printf("No counters found.. is debugfs mounted?\n");
+		exit(0);
+	}
+	return 0;
+}
+
+
 static const char * const record_usage[] = {
 	"perf record [<options>] [<command>]",
 	"perf record [<options>] -- <command> [<options>]",
@@ -681,6 +706,9 @@ static const struct option options[] = {
 		    "Sample addresses"),
 	OPT_BOOLEAN('n', "no-samples", &no_samples,
 		    "don't sample"),
+	OPT_CALLBACK_NOOPT('t', "timechart", NULL, NULL,
+		     "create a timechart recording",
+		     do_timechart),
 	OPT_END()
 };
 
Signature · 9 lines
1.6.0.6




-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
maintainer
#17 lore raw

Re: [PATCH 7/8] perf: Add a perf record --timechart option

Quoted 2 lines · Arjan van de Ven

This patch adds a "perf record --timechart" option, to make it easy to capture traces for use by the timechart tool.

Would it perhaps make sense to make that:

perf timechart record

?

#18 lore raw

Re: [PATCH 7/8] perf: Add a perf record --timechart option

Quoted 7 lines · On Mon, 14 Sep 2009 10:06:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 2 lines · Arjan van de Ven

This patch adds a "perf record --timechart" option, to make it easy to capture traces for use by the timechart tool.

Would it perhaps make sense to make that:

perf timechart record

well yes, but it would just be an alias for the former, since it's the record code that has to do the recording... and that's a rather obscene layering violation in how perf is set up I think.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#19 lore raw

Re: [PATCH 7/8] perf: Add a perf record --timechart option

Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 14 Sep 2009 10:06:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 2 lines · Arjan van de Ven

This patch adds a "perf record --timechart" option, to make it easy to capture traces for use by the timechart tool.

Quoted 7 lines
Quoted 3 lines

Would it perhaps make sense to make that:

perf timechart record

well yes, but it would just be an alias for the former, since it's the record code that has to do the recording... and that's a rather obscene layering violation in how perf is set up I think.

No, please do it like 'perf sched record' does - it constructs an argument list of pre-cooked options. See builtin-sched.c's record_args[] array.

Ingo

#20 lore raw

PATCH 1/1 perf: Add "perf timechart record"

Quoted 1 line

From f11a27881ef0fcdf459e6f52dd57885c7af93426 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 19 Sep 2009 12:59:47 +0200
Subject: [PATCH] perf: Add "perf timechart record"

Add a command line option to record a trace, similar to "perf sched record".

---
 tools/perf/builtin-timechart.c |   47 +++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 8 deletions(-)
tools/perf/builtin-timechart.c +39 -8
index 00fac1b..58d737e 100644
@@ -1086,11 +1086,42 @@ done:
 	return rc;
 }
 
-static const char * const report_usage[] = {
-	"perf report [<options>] <command>",
+static const char * const timechart_usage[] = {
+	"perf timechart [<options>] {record}",
 	NULL
 };
 
+static const char *record_args[] = {
+	"record",
+	"-a",
+	"-R",
+	"-M",
+	"-f",
+	"-c", "1",
+	"-e", "power:power_start",
+	"-e", "power:power_end",
+	"-e", "power:power_frequency",
+	"-e", "sched:sched_wakeup",
+	"-e", "sched:sched_switch",
+};
+
+static int __cmd_record(int argc, const char **argv)
+{
+	unsigned int rec_argc, i, j;
+	const char **rec_argv;
+
+	rec_argc = ARRAY_SIZE(record_args) + argc - 1;
+	rec_argv = calloc(rec_argc + 1, sizeof(char *));
+
+	for (i = 0; i < ARRAY_SIZE(record_args); i++)
+		rec_argv[i] = strdup(record_args[i]);
+
+	for (j = 1; j < (unsigned int)argc; j++, i++)
+		rec_argv[i] = argv[j];
+
+	return cmd_record(i, rec_argv, NULL);
+}
+
 static const struct option options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
 		    "input file name"),
@@ -1106,13 +1137,13 @@ int cmd_timechart(int argc, const char **argv, const char *prefix __used)
 
 	page_size = getpagesize();
 
-	argc = parse_options(argc, argv, options, report_usage, 0);
+	argc = parse_options(argc, argv, options, timechart_usage,
+			PARSE_OPT_STOP_AT_NON_OPTION);
 
-	/*
-	 * Any (unrecognized) arguments left?
-	 */
-	if (argc)
-		usage_with_options(report_usage, options);
+	if (argc && !strncmp(argv[0], "rec", 3))
+		return __cmd_record(argc, argv);
+	else if (argc)
+		usage_with_options(timechart_usage, options);
 
 	setup_pager();
 
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#21 lore raw

PATCH 8/8 perf: Add the timechart tool

In reply to a message not in the archive
Quoted 1 line

From 4935620ab9ca8217ed00ae2fdf856b115a5081c0 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Sat, 12 Sep 2009 07:53:05 +0200
Subject: [PATCH] perf: Add the timechart tool

timechart is a tool to visualize what is going on in the system.

The user makes a trace of what is going on with

Quoted 1 line

perf record --timechart /usr/bin/some_command

and then can turn the output of this into an svg file

Quoted 1 line

perf timechart

which then can be viewed with any SVG view; inkscape works well enough for me.

The idea behind timechart is to create a "infinitly zoomable" picture; something that has high level information on a 1:1 zoom level, but which exposes more details every time you zoom into a specific area.

Detailed preview of how this works can be found at http://blog.fenrus.org/?p=5

---
 tools/perf/Makefile            |    7 +
 tools/perf/builtin-timechart.c | 1120 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h           |    1 +
 tools/perf/perf.c              |    1 +
 4 files changed, 1129 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/builtin-timechart.c
tools/perf/Makefile +7 -0
index a087bf8..847437b 100644
@@ -381,6 +381,7 @@ BUILTIN_OBJS += builtin-list.o
 BUILTIN_OBJS += builtin-record.o
 BUILTIN_OBJS += builtin-report.o
 BUILTIN_OBJS += builtin-stat.o
+BUILTIN_OBJS += builtin-timechart.o
 BUILTIN_OBJS += builtin-top.o
 BUILTIN_OBJS += builtin-trace.o
 
@@ -711,6 +712,12 @@ builtin-help.o: builtin-help.c common-cmds.h PERF-CFLAGS
 		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
 		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
 
+builtin-timechart.o: builtin-timechart.c common-cmds.h PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
+		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
+		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
+
 $(BUILT_INS): perf$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
 	ln perf$X $@ 2>/dev/null || \
tools/perf/builtin-timechart.c new file +1120 -0

1,120 lines not on this page · raw message

tools/perf/builtin.h +1 -0
index 3a63e41..f2dafae 100644
@@ -19,6 +19,7 @@ extern int cmd_help(int argc, const char **argv, const char *prefix);
 extern int cmd_record(int argc, const char **argv, const char *prefix);
 extern int cmd_report(int argc, const char **argv, const char *prefix);
 extern int cmd_stat(int argc, const char **argv, const char *prefix);
+extern int cmd_timechart(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);
tools/perf/perf.c +1 -0
index fe4589d..7585b5d 100644
@@ -289,6 +289,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "record", cmd_record, 0 },
 		{ "report", cmd_report, 0 },
 		{ "stat", cmd_stat, 0 },
+		{ "timechart", cmd_timechart, 0 },
 		{ "top", cmd_top, 0 },
 		{ "annotate", cmd_annotate, 0 },
 		{ "version", cmd_version, 0 },
Signature · 9 lines
1.6.0.6

 


-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#22 lore raw

Re: [PATCH 8/8] perf: Add the timechart tool

Quoted 6 lines · Arjan van de Ven
---
 tools/perf/Makefile            |    7 +
 tools/perf/builtin-timechart.c | 1120 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h           |    1 +
 tools/perf/perf.c              |    1 +
 4 files changed, 1129 insertions(+), 0 deletions(-)

i've applied your latest patches (sans the perf record --timechart thing) - thanks Arjan.

There's a few missing things with the main timechart command:

- it's not in tools/perf/common-cmds.h that way 'perf help' does not list 'timechart' as an available command.

- there's no tools/perf/Documentation/perf-timechart.txt file - hence 'perf help timechart' does not work and there's no manpage/etc.

Ingo

#23 lore raw

Re: [PATCH 8/8] perf: Add the timechart tool

there's also a few other infrastructure things that should be improved:

- struct wake_event / trace_entry / wakeup_entry / sched_switch etc. are all present in the existing tracing bits or in builtin-sched. These should be factored out into common facilities and shared between perf timechart and perf sched. We in essence want a good facility to access tracepoint data.

- the kernel side scheduler tracepoints relied on here should be updated from TRACE_EVENT to TRACE_EVENT_ABI. (TRACE_EVENT_ABI should just be an alias of TRACE_EVENT)

Ingo

#24 lore raw

[tip:perfcounters/core] perf: Add the timechart tool

In reply to Arjan van de Ven
Commit-ID:  10274989fd595db455874fc2c83272fb33f6b27b
Gitweb:     http://git.kernel.org/tip/10274989fd595db455874fc2c83272fb33f6b27b
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 12 Sep 2009 07:53:05 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 11:42:13 +0200

perf: Add the timechart tool

timechart is a tool to visualize what is going on in the system.

The user makes a trace of what is going on with

Quoted 1 line

perf record --timechart /usr/bin/some_command

and then can turn the output of this into an svg file

Quoted 1 line

perf timechart

which then can be viewed with any SVG view; inkscape works well enough for me.

The idea behind timechart is to create a "infinitely zoomable" picture; something that has high level information on a 1:1 zoom level, but which exposes more details every time you zoom into a specific area.

LKML-Reference: <[email protected]>

---
 tools/perf/Makefile            |    7 +
 tools/perf/builtin-timechart.c | 1120 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin.h           |    1 +
 tools/perf/perf.c              |    1 +
 4 files changed, 1129 insertions(+), 0 deletions(-)
tools/perf/Makefile +7 -0
index 0388e36..0aba8b6 100644
@@ -382,6 +382,7 @@ BUILTIN_OBJS += builtin-list.o
 BUILTIN_OBJS += builtin-record.o
 BUILTIN_OBJS += builtin-report.o
 BUILTIN_OBJS += builtin-stat.o
+BUILTIN_OBJS += builtin-timechart.o
 BUILTIN_OBJS += builtin-top.o
 BUILTIN_OBJS += builtin-trace.o
 
@@ -712,6 +713,12 @@ builtin-help.o: builtin-help.c common-cmds.h PERF-CFLAGS
 		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
 		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
 
+builtin-timechart.o: builtin-timechart.c common-cmds.h PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
+		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+		'-DPERF_MAN_PATH="$(mandir_SQ)"' \
+		'-DPERF_INFO_PATH="$(infodir_SQ)"' $<
+
 $(BUILT_INS): perf$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
 	ln perf$X $@ 2>/dev/null || \
tools/perf/builtin-timechart.c new file +1120 -0

1,120 lines not on this page · raw message

tools/perf/builtin.h +1 -0
index b09cadb..e11d8d2 100644
@@ -21,6 +21,7 @@ extern int cmd_list(int argc, const char **argv, const char *prefix);
 extern int cmd_record(int argc, const char **argv, const char *prefix);
 extern int cmd_report(int argc, const char **argv, const char *prefix);
 extern int cmd_stat(int argc, const char **argv, const char *prefix);
+extern int cmd_timechart(int argc, const char **argv, const char *prefix);
 extern int cmd_top(int argc, const char **argv, const char *prefix);
 extern int cmd_trace(int argc, const char **argv, const char *prefix);
 extern int cmd_version(int argc, const char **argv, const char *prefix);
tools/perf/perf.c +1 -0
index c972d1c..19fc7fe 100644
@@ -289,6 +289,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "record", cmd_record, 0 },
 		{ "report", cmd_report, 0 },
 		{ "stat", cmd_stat, 0 },
+		{ "timechart", cmd_timechart, 0 },
 		{ "top", cmd_top, 0 },
 		{ "annotate", cmd_annotate, 0 },
 		{ "version", cmd_version, 0 },