Skip to contentSkip to conversation

perf events: Add realtime clock event, time-of-day strings to script output

PATCH In review David Ahern 6 participants 32 messages Feb 28, 2011 – Mar 3, 2011 perf events

lore
Share & tools
lore
#0 lore raw

v3 cover perf events: Add realtime clock event, time-of-day strings to script output

v2 -> v3:
- changed timehist arg in perf-record to tod to better reflect usage
- removed timehist changes from perf-report
- added dumping software events to perf-script
- added time-of-day output to perf-script

v1 -> v2:
- removed change to WARN_ON_ONCE in perf_event.c
- fixed init of realtime_clock event (needed call to perf_swevent_init_hrtimer)
- changed userspace event name to clock-realtime with the alias clkr as the raw events code sucks up all options that start with 'r' followed by a hex character
- remove RAW sample hack for pushing realtime clock event data to userspace
- plumbed PERF_SAMPLE_READ to enable retrieving event data during sample generation
- add patch to perf-stat to recognize realtime-clock as a nsec counter
- implementation of tiemhist in perf-record was revamped significantly -- to use event data,
-- to better handle fallback to synthesized event,
-- added feature to force a sample to be generated at startup (to output
wall-clock times we need a sample immediately; after that realtime-clock samples are generated periodically)
-- change counter creation to be done only on first cpu; we do not need a
counter for each cpu

A request was made to modify perf-trace and perf-script. From what I can see perf-trace does not exist yet and perf-script requires raw data which means it does not work for the primary use case that motivated this feature (perf record -e cs -1 -ag).

CC Arnaldo Carvalho de Melo <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Paul Mackerras <[email protected]>
CC Thomas Gleixner <[email protected]>

David Ahern (6):
perf events: Introduce realtime clock event
perf events: plumbing for PERF_SAMPLE_READ and read_format perf record: add time-of-day option
perf script: dump software events too
perf script: Prepend lines with time-of-day string perf stat: treat realtime-clock as nsec counter

 include/linux/perf_event.h               |    2 +
 kernel/perf_event.c                      |   85 ++++++++++++++++++++++
 tools/perf/Documentation/perf-record.txt |    5 ++
 tools/perf/builtin-record.c              |  115 +++++++++++++++++++++++++++++-
 tools/perf/builtin-script.c              |   89 ++++++++++++++++++++++--
 tools/perf/builtin-stat.c                |    5 +-
 tools/perf/builtin-test.c                |    3 +-
 tools/perf/util/event.c                  |   96 +++++++++++++++++++++++++
 tools/perf/util/event.h                  |   28 +++++++-
 tools/perf/util/evlist.c                 |    2 +-
 tools/perf/util/evlist.h                 |    2 +
 tools/perf/util/evsel.c                  |   24 ++++++-
 tools/perf/util/header.c                 |   18 +++++
 tools/perf/util/header.h                 |    1 +
 tools/perf/util/parse-events.c           |    2 +
 tools/perf/util/python.c                 |    3 +-
 tools/perf/util/session.c                |  114 +++++++++++++++++++++++++++++
 tools/perf/util/session.h                |   12 +++-
 18 files changed, 588 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.4
#1 lore raw

PATCH v3 1/6 perf events: Introduce realtime clock event

The motivation for this event is to correlate perf_clock() time stamps to wall-clock (gettimeofday()) equivalents for comparing perf events to other log files.

This patch is based on the monotonic patch by Arnaldo Carvalho de Melo <[email protected]>.

---
 include/linux/perf_event.h     |    1 +
 kernel/perf_event.c            |   66 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/parse-events.c |    2 +
 3 files changed, 69 insertions(+), 0 deletions(-)
include/linux/perf_event.h +1 -0
index 8ceb5a6..51a2f34 100644
@@ -105,6 +105,7 @@ enum perf_sw_ids {
 	PERF_COUNT_SW_PAGE_FAULTS_MAJ		= 6,
 	PERF_COUNT_SW_ALIGNMENT_FAULTS		= 7,
 	PERF_COUNT_SW_EMULATION_FAULTS		= 8,
+	PERF_COUNT_SW_REALTIME_CLOCK		= 9,
 
 	PERF_COUNT_SW_MAX,			/* non-ABI */
 };
kernel/perf_event.c +66 -0

84 lines not on this page · raw message

tools/perf/util/parse-events.c +2 -0
index 54a7e26..c40bfef 100644
@@ -41,6 +41,7 @@ static struct event_symbol event_symbols[] = {
 
   { CSW(CPU_CLOCK),		"cpu-clock",		""		},
   { CSW(TASK_CLOCK),		"task-clock",		""		},
+  { CSW(REALTIME_CLOCK),	"clock-realtime",	"clkr"		},
   { CSW(PAGE_FAULTS),		"page-faults",		"faults"	},
   { CSW(PAGE_FAULTS_MIN),	"minor-faults",		""		},
   { CSW(PAGE_FAULTS_MAJ),	"major-faults",		""		},
@@ -78,6 +79,7 @@ static const char *sw_event_names[] = {
 	"major-faults",
 	"alignment-faults",
 	"emulation-faults",
+	"realtime-clock-msecs",
 };
 
 #define MAX_ALIASES 8
Signature · 1 line
1.7.4
#2 lore raw

PATCH v3 2/6 perf events: plumbing for PERF_SAMPLE_READ and read_format

In reply to David Ahern
---
 tools/perf/builtin-record.c |    5 +++++
 tools/perf/builtin-test.c   |    3 ++-
 tools/perf/util/event.h     |   10 +++++++++-
 tools/perf/util/evsel.c     |   24 +++++++++++++++++++++---
 tools/perf/util/header.c    |   18 ++++++++++++++++++
 tools/perf/util/header.h    |    1 +
 tools/perf/util/python.c    |    3 ++-
 tools/perf/util/session.c   |   12 ++++++++++++
 tools/perf/util/session.h   |    6 +++++-
 9 files changed, 75 insertions(+), 7 deletions(-)
tools/perf/builtin-record.c +5 -0
index db4cd1e..e39883e 100644
@@ -41,6 +41,7 @@ enum write_mode_t {
 static u64			user_interval			= ULLONG_MAX;
 static u64			default_interval		=      0;
 static u64			sample_type;
+static u64			read_format;
 
 static unsigned int		page_size;
 static unsigned int		mmap_pages			=    128;
@@ -218,6 +219,9 @@ static void create_counter(struct perf_evsel *evsel, int cpu)
 
 	if (!sample_type)
 		sample_type = attr->sample_type;
+
+	if (!read_format)
+		read_format = attr->read_format;
 }
 
 static void config_attr(struct perf_evsel *evsel, struct perf_evlist *evlist)
@@ -595,6 +599,7 @@ static int __cmd_record(int argc, const char **argv)
 	open_counters(evsel_list);
 
 	perf_session__set_sample_type(session, sample_type);
+	perf_session__set_read_format(session, read_format);
 
 	/*
 	 * perf_session__delete(session) will be called at atexit_header()
tools/perf/builtin-test.c +2 -1
index 1b2106c..a243d51 100644
@@ -558,7 +558,8 @@ static int test__basic_mmap(void)
 			goto out_munmap;
 		}
 
-		perf_event__parse_sample(event, attr.sample_type, false, &sample);
+		perf_event__parse_sample(event, attr.sample_type,
+				  attr.read_format, false, &sample);
 		evsel = perf_evlist__id2evsel(evlist, sample.id);
 		if (evsel == NULL) {
 			pr_debug("event with id %" PRIu64
tools/perf/util/event.h +9 -1
index 9c35170..512a1ca 100644
@@ -61,6 +61,13 @@ struct sample_event {
 	u64 array[];
 };
 
+struct read_format {
+	u64     value;
+	u64     time_enabled;
+	u64     time_running;
+	u64     id;
+};
+
 struct perf_sample {
 	u64 ip;
 	u32 pid, tid;
@@ -69,6 +76,7 @@ struct perf_sample {
 	u64 id;
 	u64 stream_id;
 	u64 period;
+	struct read_format values;
 	u32 cpu;
 	u32 raw_size;
 	void *raw_data;
@@ -178,6 +186,6 @@ int perf_event__preprocess_sample(const union perf_event *self,
 const char *perf_event__name(unsigned int id);
 
 int perf_event__parse_sample(const union perf_event *event, u64 type,
-			     bool sample_id_all, struct perf_sample *sample);
+			     u64 read_format, bool sample_id_all, struct perf_sample *sample);
 
 #endif /* __PERF_RECORD_H */
tools/perf/util/evsel.c +21 -3
index 8083d51..98c8471 100644
@@ -304,7 +304,7 @@ static int perf_event__parse_id_sample(const union perf_event *event, u64 type,
 }
 
 int perf_event__parse_sample(const union perf_event *event, u64 type,
-			     bool sample_id_all, struct perf_sample *data)
+			     u64 read_format, bool sample_id_all, struct perf_sample *data)
 {
 	const u64 *array;
 
@@ -364,8 +364,26 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
 	}
 
 	if (type & PERF_SAMPLE_READ) {
-		fprintf(stderr, "PERF_SAMPLE_READ is unsuported for now\n");
-		return -1;
+		if (read_format & PERF_FORMAT_GROUP) {
+			printf("READ_FORMAT_GROUP is unsuported for now\n");
+			return -1;
+		} else {
+			data->values.value = *array;
+			array++;
+
+			if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
+				data->values.time_enabled = *array;
+				array++;
+			}
+			if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
+				data->values.time_running = *array;
+				array++;
+			}
+			if (read_format & PERF_FORMAT_ID) {
+				data->values.id = *array;
+				array++;
+			}
+		}
 	}
 
 	if (type & PERF_SAMPLE_CALLCHAIN) {
tools/perf/util/header.c +18 -0
index 72c124d..f48b0b1 100644
@@ -951,6 +951,23 @@ u64 perf_header__sample_type(struct perf_header *header)
 	return type;
 }
 
+u64 perf_header__read_format(struct perf_header *header)
+{
+	u64 read_format = 0;
+	int i;
+
+	for (i = 0; i < header->attrs; i++) {
+		struct perf_header_attr *attr = header->attr[i];
+
+		if (!read_format)
+			read_format = attr->attr.read_format;
+		else if (read_format != attr->attr.read_format)
+			die("non matching read_format");
+	}
+
+	return read_format;
+}
+
 bool perf_header__sample_id_all(const struct perf_header *header)
 {
 	bool value = false, first = true;
@@ -1079,6 +1096,7 @@ int perf_event__process_attr(union perf_event *event,
 	}
 
 	perf_session__update_sample_type(session);
+	perf_session__update_read_format(session);
 
 	return 0;
 }
tools/perf/util/header.h +1 -0
index f042ceb..5d89e7f 100644
@@ -84,6 +84,7 @@ void perf_header_attr__delete(struct perf_header_attr *self);
 int perf_header_attr__add_id(struct perf_header_attr *self, u64 id);
 
 u64 perf_header__sample_type(struct perf_header *header);
+u64 perf_header__read_format(struct perf_header *header);
 bool perf_header__sample_id_all(const struct perf_header *header);
 struct perf_event_attr *
 perf_header__find_attr(u64 id, struct perf_header *header);
tools/perf/util/python.c +2 -1
index 5317ef2..b67c25f 100644
@@ -684,7 +684,8 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 			return PyErr_NoMemory();
 
 		first = list_entry(evlist->entries.next, struct perf_evsel, node);
-		perf_event__parse_sample(event, first->attr.sample_type, sample_id_all,
+		perf_event__parse_sample(event, first->attr.sample_type,
+					 first->attr.read_format, sample_id_all,
 					 &pevent->sample);
 		return pyevent;
 	}
tools/perf/util/session.c +12 -0
index a3a871f..dc0235b 100644
@@ -110,6 +110,17 @@ void perf_session__update_sample_type(struct perf_session *self)
 	perf_session__id_header_size(self);
 }
 
+void perf_session__set_read_format(struct perf_session *session,
+		   	u64 read_format)
+{
+	session->read_format = read_format;
+}
+
+void perf_session__update_read_format(struct perf_session *self)
+{
+	self->read_format = perf_header__read_format(&self->header);
+}
+
 int perf_session__create_kernel_maps(struct perf_session *self)
 {
 	int ret = machine__create_kernel_maps(&self->host_machine);
@@ -172,6 +183,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
 	}
 
 	perf_session__update_sample_type(self);
+	perf_session__update_read_format(self);
 
 	if (ops && ops->ordering_requires_timestamps &&
 	    ops->ordered_samples && !self->sample_id_all) {
tools/perf/util/session.h +5 -1
index 977b3a1..212f810 100644
@@ -43,6 +43,7 @@ struct perf_session {
 	 */
 	struct hists		hists;
 	u64			sample_type;
+	u64			read_format;
 	int			fd;
 	bool			fd_pipe;
 	bool			repipe;
@@ -115,6 +116,8 @@ void perf_session__update_sample_type(struct perf_session *self);
 void perf_session__set_sample_id_all(struct perf_session *session, bool value);
 void perf_session__set_sample_type(struct perf_session *session, u64 type);
 void perf_session__remove_thread(struct perf_session *self, struct thread *th);
+void perf_session__set_read_format(struct perf_session *session, u64 read_format);
+void perf_session__update_read_format(struct perf_session *self);
 
 static inline
 struct machine *perf_session__find_host_machine(struct perf_session *self)
@@ -162,7 +165,8 @@ static inline int perf_session__parse_sample(struct perf_session *session,
 					     struct perf_sample *sample)
 {
 	return perf_event__parse_sample(event, session->sample_type,
-					session->sample_id_all, sample);
+					session->read_format, session->sample_id_all,
+					sample);
 }
 
 #endif /* __PERF_SESSION_H */
Signature · 1 line
1.7.4
#3 lore raw

PATCH v3 3/6 perf record: add time-of-day option

In reply to David Ahern

Enable data collection for generating time-of-day strings when printing individual perf samples. This is done by sampling the realtime clock event with the perf_clock time stamps.

If the realtime-clock event is not available (e.g, older kernels) fallback to a synthesized event. (I realize there is resistance to new synthesized events, but it is a simple way to gain this feature on older kernels without the need to modify the kernel code).

---
 include/linux/perf_event.h               |    1 +
 kernel/perf_event.c                      |   19 +++++
 tools/perf/Documentation/perf-record.txt |    5 ++
 tools/perf/builtin-record.c              |  110 +++++++++++++++++++++++++++++-
 tools/perf/util/event.c                  |    1 +
 tools/perf/util/event.h                  |    8 ++
 tools/perf/util/evlist.c                 |    2 +-
 tools/perf/util/evlist.h                 |    2 +
 tools/perf/util/session.c                |    4 +
 tools/perf/util/session.h                |    3 +-
 10 files changed, 151 insertions(+), 4 deletions(-)
include/linux/perf_event.h +1 -0
index 51a2f34..404b1ee 100644
@@ -240,6 +240,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_PERIOD		_IOW('$', 4, __u64)
 #define PERF_EVENT_IOC_SET_OUTPUT	_IO ('$', 5)
 #define PERF_EVENT_IOC_SET_FILTER	_IOW('$', 6, char *)
+#define PERF_EVENT_IOC_RECORD_SAMPLE	_IO('$', 7)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
kernel/perf_event.c +19 -0
index a25a63d..7999f55 100644
@@ -3250,6 +3250,7 @@ static struct perf_event *perf_fget_light(int fd, int *fput_needed)
 static int perf_event_set_output(struct perf_event *event,
 				 struct perf_event *output_event);
 static int perf_event_set_filter(struct perf_event *event, void __user *arg);
+static int perf_event_generate_sample(struct perf_event *event);
 
 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -3296,6 +3297,9 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case PERF_EVENT_IOC_SET_FILTER:
 		return perf_event_set_filter(event, (void __user *)arg);
 
+	case PERF_EVENT_IOC_RECORD_SAMPLE:
+		return perf_event_generate_sample(event);
+
 	default:
 		return -ENOTTY;
 	}
@@ -4398,6 +4402,21 @@ exit:
 	rcu_read_unlock();
 }
 
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+	struct perf_sample_data data;
+	struct pt_regs regs;
+
+	perf_fetch_caller_regs(&regs);
+	event->pmu->read(event);
+	perf_sample_data_init(&data, 0);
+	data.period = event->hw.last_period;
+	perf_event_output(event, 0, &data, &regs);
+
+	return 0;
+}
+
 /*
  * read event_id
  */
tools/perf/Documentation/perf-record.txt +5 -0
index 5a520f8..8eb5b0a 100644
@@ -148,6 +148,11 @@ an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must ha
 corresponding events, i.e., they always refer to events defined earlier on the command
 line.
 
+--tod::
+Collect data for time-of-day strings when printing events. This option adds
+reference time samples to the event stream for converting perf timestamps to
+time-of-day.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +108 -2

158 lines not on this page · raw message

tools/perf/util/event.c +1 -0
index fbf5754..6bbd551 100644
@@ -24,6 +24,7 @@ static const char *perf_event__names[] = {
 	[PERF_RECORD_HEADER_TRACING_DATA]	 = "TRACING_DATA",
 	[PERF_RECORD_HEADER_BUILD_ID]	 = "BUILD_ID",
 	[PERF_RECORD_FINISHED_ROUND]	 = "FINISHED_ROUND",
+	[PERF_RECORD_REFTIME]		 = "REF_TIME",
 };
 
 const char *perf_event__name(unsigned int id)
tools/perf/util/event.h +8 -0
index 512a1ca..d4810e0 100644
@@ -99,6 +99,7 @@ enum perf_user_event_type { /* above any possible kernel type */
 	PERF_RECORD_HEADER_TRACING_DATA		= 66,
 	PERF_RECORD_HEADER_BUILD_ID		= 67,
 	PERF_RECORD_FINISHED_ROUND		= 68,
+	PERF_RECORD_REFTIME			= 69,
 	PERF_RECORD_HEADER_MAX
 };
 
@@ -125,6 +126,12 @@ struct tracing_data_event {
 	u32 size;
 };
 
+struct reftime_event {
+	struct perf_event_header header;
+	struct timeval tv;
+	u64 nsec;
+};
+
 union perf_event {
 	struct perf_event_header	header;
 	struct ip_event			ip;
@@ -138,6 +145,7 @@ union perf_event {
 	struct event_type_event		event_type;
 	struct tracing_data_event	tracing_data;
 	struct build_id_event		build_id;
+	struct reftime_event		reftime;
 };
 
 void perf_event__print_totals(void);
tools/perf/util/evlist.c +1 -1
index 95b21fe..bb49243 100644
@@ -106,7 +106,7 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd)
 	evlist->nr_fds++;
 }
 
-static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel,
+int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel,
 			       int cpu, int thread, int fd)
 {
 	struct perf_sample_id *sid;
tools/perf/util/evlist.h +2 -0
index c988405..bd73572 100644
@@ -48,6 +48,8 @@ union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu);
 int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
 int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
+int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel,
+					       int cpu, int thread, int fd);
 
 static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
 					 struct cpu_map *cpus,
tools/perf/util/session.c +4 -0
index dc0235b..1ef8e8a 100644
@@ -791,6 +791,10 @@ static int perf_session__process_user_event(struct perf_session *session, union
 		return ops->build_id(event, session);
 	case PERF_RECORD_FINISHED_ROUND:
 		return ops->finished_round(event, session, ops);
+	case PERF_RECORD_REFTIME:
+		if (ops->reftime)
+			return ops->reftime(event, session);
+		return -EINVAL;
 	default:
 		return -EINVAL;
 	}
tools/perf/util/session.h +2 -1
index 212f810..b46672a 100644
@@ -78,7 +78,8 @@ struct perf_event_ops {
 	event_synth_op	attr,
 			event_type,
 			tracing_data,
-			build_id;
+			build_id,
+			reftime;
 	event_op2	finished_round;
 	bool		ordered_samples;
 	bool		ordering_requires_timestamps;
Signature · 1 line
1.7.4
#22 lore raw

PATCH v3 4/6 perf script: dump software events too

In reply to David Ahern

Call chain options mirror perf-report. Line format follows tracepoints precedent:

comm-pid [cpu] secs.usecs: event: IP symbol dso

Example:
perf record -v -ga -e cs -c 1 -- sleep 5
perf script

(Line lengths wrapped):

sshd-794 [000] 2572.863440: context-switches: ffffffff810355de \
perf_event_task_sched_out ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff81382b01 \
schedule ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8138380a \
schedule_hrtimeout_range_clock ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff813838e6 \
schedule_hrtimeout_range ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8110c55d \
poll_schedule_timeout ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8110cd84 \
do_select ([kernel.kallsyms])

or 'perf script -G'

swapper-0 [001] 2572.863188: context-switches: ffffffff810355de ... sshd-794 [000] 2572.863440: context-switches: ffffffff810355de ... kworker/0:1-10 [000] 2572.863451: context-switches: ffffffff810355de ...

---
 tools/perf/builtin-script.c |   65 +++++++++++++++++++++++++++--
 tools/perf/util/session.c   |   94 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/session.h   |    3 +
 3 files changed, 157 insertions(+), 5 deletions(-)
tools/perf/builtin-script.c +60 -5
index 5f40df6..4f4c63b 100644
@@ -19,6 +19,8 @@ static bool			debug_mode;
 static u64			last_timestamp;
 static u64			nr_unordered;
 extern const struct option	record_options[];
+static bool			hide_unresolved;
+static bool			no_callchain;
 
 static int default_start_script(const char *script __unused,
 				int argc __unused,
@@ -67,7 +69,11 @@ static int process_sample_event(union perf_event *event,
 				struct perf_sample *sample,
 				struct perf_session *session)
 {
+	struct perf_event_attr *attr;
+	struct addr_location al;
 	struct thread *thread = perf_session__findnew(session, event->ip.pid);
+	const char *evname = NULL;
+	static bool check_raw = true;
 
 	if (thread == NULL) {
 		pr_debug("problem processing %d event, skipping it.\n",
@@ -75,7 +81,31 @@ static int process_sample_event(union perf_event *event,
 		return -1;
 	}
 
-	if (session->sample_type & PERF_SAMPLE_RAW) {
+	attr = perf_header__find_attr(sample->id, &session->header);
+	if (!attr) {
+		pr_debug("No attributes found for sample id %" PRId64 ". "
+		         "skipping it.\n", sample->id);
+		return -1;
+	}
+
+	switch (attr->type) {
+	case PERF_TYPE_SOFTWARE:
+		if (perf_event__preprocess_sample(event, session, &al, sample,
+					  NULL) < 0) {
+			fprintf(stderr, "problem processing %d event, skipping it.\n",
+				event->header.type);
+			return -1;
+		}
+		perf_session__print_sample(session, &al, sample, hide_unresolved);
+		break;
+
+	case PERF_TYPE_TRACEPOINT:
+		if (check_raw) {
+			if (!perf_session__has_traces(session, "record -R"))
+				return -EINVAL;
+			check_raw = false;
+		}
+
 		if (debug_mode) {
 			if (sample->time < last_timestamp) {
 				pr_err("Samples misordered, previous: %" PRIu64
@@ -94,6 +124,13 @@ static int process_sample_event(union perf_event *event,
 		scripting_ops->process_event(sample->cpu, sample->raw_data,
 					     sample->raw_size,
 					     sample->time, thread->comm);
+		break;
+
+	default:
+   		evname = __event_name(attr->type, attr->config);
+		if (verbose)
+			warning("support for event %s not implemented. skipping\n",
+			evname ? evname : "(unknown)");
 	}
 
 	session->hists.stats.total_period += sample->period;
@@ -592,6 +629,16 @@ static const struct option options[] = {
 		    "input file name"),
 	OPT_BOOLEAN('d', "debug-mode", &debug_mode,
 		   "do various checks like samples ordering and lost events"),
+	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
+		   "file", "vmlinux pathname"),
+	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
+		   "file", "kallsyms pathname"),
+	OPT_BOOLEAN('G', "hide-call-graph", &no_callchain,
+		    "Do not display call chain"),
+	OPT_BOOLEAN('U', "hide-unresolved", &hide_unresolved,
+		    "Only display entries resolved to a symbol"),
+	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+		    "Look for files with symbols relative to this directory"),
 
 	OPT_END()
 };
@@ -735,6 +782,18 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
 		exit(-1);
 	}
 
+	if (no_callchain)
+		symbol_conf.use_callchain = false;
+
+	else {
+		symbol_conf.use_callchain = true;
+		if (callchain_register_param(&callchain_param) < 0) {
+			error("Can't register callchain params\n");
+			err = -EINVAL;
+			goto out;
+		}
+	}
+
 	if (rec_script_path)
 		script_path = rec_script_path;
 	if (rep_script_path)
@@ -772,10 +831,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
 	if (session == NULL)
 		return -ENOMEM;
 
-	if (strcmp(input_name, "-") &&
-	    !perf_session__has_traces(session, "record -R"))
-		return -EINVAL;
-
 	if (generate_script_lang) {
 		struct stat perf_stat;
 
tools/perf/util/session.c +94 -0

103 lines not on this page · raw message

tools/perf/util/session.h +3 -0
index b46672a..ff8791d 100644
@@ -170,4 +170,7 @@ static inline int perf_session__parse_sample(struct perf_session *session,
 					sample);
 }
 
+void perf_session__print_sample(struct perf_session *session,
+					struct addr_location *al, struct perf_sample *sample,
+					bool hide_unresolved);
 #endif /* __PERF_SESSION_H */
Signature · 1 line
1.7.4
#29 lore raw

PATCH v3 5/6 perf script: Prepend lines with time-of-day string

In reply to David Ahern

Handle realtime-clock events and setting reference times that are then used to correlate perf_clock times with time-of-day. Output lines are then prepended with a time-of-day string if the --tod option was used with perf-record.

Was:

swapper-0 [000] 5329.151669: context-switches: ...
perf-5701 [001] 5329.151797: context-switches: ...
sleep-5702 [000] 5329.155550: context-switches: ...
swapper-0 [001] 5329.158074: context-switches: ...

Now:

20:07:14.903936 swapper-0 [000] 5329.151669: context-switches: ...
20:07:14.904065 perf-5701 [001] 5329.151797: context-switches: ...
20:07:14.907817 sleep-5702 [000] 5329.155550: context-switches: ...
20:07:14.910342 swapper-0 [001] 5329.158074: context-switches: ...

Similarly for tracepoints:

20:11:11.659801 perf-5714 [001] 5565.907534: sched_switch: ...

20:11:11.659812     swapper-0    [001] 5565.907544: sched_switch: ...
20:11:11.659828 ksoftirqd/1-9    [001] 5565.907560: sched_switch: ...
20:11:12.857334     swapper-0    [001] 5567.105067: sched_switch: ...
---
 tools/perf/builtin-script.c |   26 +++++++++++-
 tools/perf/util/event.c     |   95 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/event.h     |   10 +++++
 tools/perf/util/session.c   |   12 ++++--
 tools/perf/util/session.h   |    2 +-
 5 files changed, 139 insertions(+), 6 deletions(-)
tools/perf/builtin-script.c +25 -1
index 4f4c63b..427c257 100644
@@ -21,6 +21,8 @@ static u64			nr_unordered;
 extern const struct option	record_options[];
 static bool			hide_unresolved;
 static bool			no_callchain;
+static struct			timeval tv_ref;
+static u64 			timestamp_ref;
 
 static int default_start_script(const char *script __unused,
 				int argc __unused,
@@ -73,6 +75,7 @@ static int process_sample_event(union perf_event *event,
 	struct addr_location al;
 	struct thread *thread = perf_session__findnew(session, event->ip.pid);
 	const char *evname = NULL;
+	const char *tstr = NULL;
 	static bool check_raw = true;
 
 	if (thread == NULL) {
@@ -88,6 +91,16 @@ static int process_sample_event(union perf_event *event,
 		return -1;
 	}
 
+	if ((attr->type == PERF_TYPE_SOFTWARE) &&
+	    (attr->config == PERF_COUNT_SW_REALTIME_CLOCK) &&
+	    (perf_event__process_rclk(sample, session,
+				      &tv_ref, &timestamp_ref) == 0))
+		return 0;
+
+
+	if (session->sample_type & PERF_SAMPLE_TIME)
+		tstr = perf_event__timestr(sample, session, timestamp_ref, &tv_ref);
+
 	switch (attr->type) {
 	case PERF_TYPE_SOFTWARE:
 		if (perf_event__preprocess_sample(event, session, &al, sample,
@@ -96,7 +109,7 @@ static int process_sample_event(union perf_event *event,
 				event->header.type);
 			return -1;
 		}
-		perf_session__print_sample(session, &al, sample, hide_unresolved);
+		perf_session__print_sample(session, &al, sample, hide_unresolved, tstr);
 		break;
 
 	case PERF_TYPE_TRACEPOINT:
@@ -116,6 +129,9 @@ static int process_sample_event(union perf_event *event,
 			last_timestamp = sample->time;
 			return 0;
 		}
+		if (tstr)
+			printf("%15s ", tstr);
+
 		/*
 		 * FIXME: better resolve from pid from the struct trace_entry
 		 * field, although it should be the same than this perf
@@ -137,6 +153,13 @@ static int process_sample_event(union perf_event *event,
 	return 0;
 }
 
+static int process_reftime_event(union perf_event *event,
+                 struct perf_session *session)
+{
+	return perf_event__process_reftime(event, session,
+	                                   &tv_ref, &timestamp_ref);
+}
+
 static struct perf_event_ops event_ops = {
 	.sample		 = process_sample_event,
 	.comm		 = perf_event__process_comm,
@@ -144,6 +167,7 @@ static struct perf_event_ops event_ops = {
 	.event_type	 = perf_event__process_event_type,
 	.tracing_data	 = perf_event__process_tracing_data,
 	.build_id	 = perf_event__process_build_id,
+	.reftime	 = process_reftime_event,
 	.ordered_samples = true,
 	.ordering_requires_timestamps = true,
 };
tools/perf/util/event.c +95 -0

102 lines not on this page · raw message

tools/perf/util/event.h +10 -0
index d4810e0..22e2af8 100644
@@ -196,4 +196,14 @@ const char *perf_event__name(unsigned int id);
 int perf_event__parse_sample(const union perf_event *event, u64 type,
 			     u64 read_format, bool sample_id_all, struct perf_sample *sample);
 
+int perf_event__process_rclk(struct perf_sample *sample,
+				  struct perf_session *session, struct timeval *tv, u64 *ts);
+
+int perf_event__process_reftime(union perf_event *event,
+				  struct perf_session *session, struct timeval *tv, u64 *ts);
+
+const char *perf_event__timestr(struct perf_sample *sample,
+				  struct perf_session *session,
+				  u64 tsref, struct timeval *tvref);
+
 #endif /* __PERF_RECORD_H */
tools/perf/util/session.c +8 -4
index 7d46351..b68fd4f 100644
@@ -1157,8 +1157,12 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
 
 static inline void print_sample(const char *comm, pid_t pid, 
 			u32 cpu, u64 secs, u64 usecs, const char *evname,
-			u64 addr, const char *symname, const char *dsoname)
+			u64 addr, const char *symname, const char *dsoname,
+			const char *timestr)
 {
+	if (timestr)
+		printf("%15s ", timestr);
+
 	printf("%16s-%-5d ", comm, pid);
 
 	if (cpu != (u32) -1)
@@ -1175,7 +1179,7 @@ static inline void print_sample(const char *comm, pid_t pid,
 void perf_session__print_sample(struct perf_session *session,
 				struct addr_location *al,
 				struct perf_sample *sample,
-				bool hide_unresolved)
+				bool hide_unresolved, const char *timestr)
 {
 	struct callchain_cursor_node *node, *prev;
 	struct perf_event_attr *attr;
@@ -1228,7 +1232,7 @@ void perf_session__print_sample(struct perf_session *session,
 				continue;
 
 			print_sample(comm, al->thread->pid, cpu, secs, usecs,
-			             evname, node->ip, symname, dsoname);
+			             evname, node->ip, symname, dsoname, timestr);
 
 			prev = node;
 			node = node->next;
@@ -1244,6 +1248,6 @@ void perf_session__print_sample(struct perf_session *session,
 			dsoname = al->map->dso->name;
 
 		print_sample(comm, al->thread->pid, cpu, secs, usecs,
-		             evname, al->addr, symname, dsoname);
+		             evname, al->addr, symname, dsoname, timestr);
 	}
 }
tools/perf/util/session.h +1 -1
index ff8791d..a4f1c4f 100644
@@ -172,5 +172,5 @@ static inline int perf_session__parse_sample(struct perf_session *session,
 
 void perf_session__print_sample(struct perf_session *session,
 					struct addr_location *al, struct perf_sample *sample,
-					bool hide_unresolved);
+					bool hide_unresolved, const char *timestr);
 #endif /* __PERF_SESSION_H */
Signature · 1 line
1.7.4
#30 lore raw

PATCH v3 6/6 perf stat: treat realtime-clock as nsec counter

In reply to David Ahern

Based on patch from Arnaldo Carvalho de Melo <[email protected]>

---
 tools/perf/builtin-stat.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +3 -2
index 21c0252..35d45b4 100644
@@ -184,8 +184,9 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
  */
 static inline int nsec_counter(struct perf_evsel *evsel)
 {
-	if (perf_evsel__match(evsel, SOFTWARE, SW_CPU_CLOCK) ||
-	    perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
+	if (perf_evsel__match(evsel, SOFTWARE, SW_CPU_CLOCK)  ||
+	    perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK) ||
+	    perf_evsel__match(evsel, SOFTWARE, SW_REALTIME_CLOCK))
 		return 1;
 
 	return 0;
Signature · 1 line
1.7.4
#31 lore raw
In reply to David Ahern
Quoted 4 lines · David Ahern

A request was made to modify perf-trace and perf-script. From what I can see perf-trace does not exist yet and perf-script requires raw data which means it does not work for the primary use case that motivated this feature (perf record -e cs -1 -ag).

Please disregard the above; it is not relevant to this version.

David

#23 lore raw

Re: [PATCH 4/6] perf script: dump software events too

In reply to David Ahern
Quoted 74 lines · David Ahern

Call chain options mirror perf-report. Line format follows tracepoints precedent:

comm-pid [cpu] secs.usecs: event: IP symbol dso

Example:
perf record -v -ga -e cs -c 1 -- sleep 5
perf script

(Line lengths wrapped):

sshd-794 [000] 2572.863440: context-switches: ffffffff810355de \
perf_event_task_sched_out ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff81382b01 \
schedule ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8138380a \
schedule_hrtimeout_range_clock ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff813838e6 \
schedule_hrtimeout_range ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8110c55d \
poll_schedule_timeout ([kernel.kallsyms])
sshd-794 [000] 2572.863440: context-switches: ffffffff8110cd84 \
do_select ([kernel.kallsyms])

or 'perf script -G'

swapper-0 [001] 2572.863188: context-switches: ffffffff810355de ... sshd-794 [000] 2572.863440: context-switches: ffffffff810355de ... kworker/0:1-10 [000] 2572.863451: context-switches: ffffffff810355de ...

---
 tools/perf/builtin-script.c |   65 +++++++++++++++++++++++++++--
 tools/perf/util/session.c   |   94 +++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/session.h   |    3 +
 3 files changed, 157 insertions(+), 5 deletions(-)
tools/perf/builtin-script.c +13 -1
index 5f40df6..4f4c63b 100644
@@ -19,6 +19,8 @@ static bool			debug_mode;
 static u64			last_timestamp;
 static u64			nr_unordered;
 extern const struct option	record_options[];
+static bool			hide_unresolved;
+static bool			no_callchain;
 
 static int default_start_script(const char *script __unused,
 				int argc __unused,
@@ -67,7 +69,11 @@ static int process_sample_event(union perf_event *event,
 				struct perf_sample *sample,
 				struct perf_session *session)
 {
+	struct perf_event_attr *attr;
+	struct addr_location al;
 	struct thread *thread = perf_session__findnew(session, event->ip.pid);
+	const char *evname = NULL;
+	static bool check_raw = true;
 
 	if (thread == NULL) {
 		pr_debug("problem processing %d event, skipping it.\n",
@@ -75,7 +81,31 @@ static int process_sample_event(union perf_event *event,
 		return -1;
 	}
 
-	if (session->sample_type & PERF_SAMPLE_RAW) {
+	attr = perf_header__find_attr(sample->id, &session->header);
+	if (!attr) {
+		pr_debug("No attributes found for sample id %" PRId64 ". "
+		         "skipping it.\n", sample->id);
+		return -1;
+	}
+

tools/perf/builtin-script.c static int process_sample_event(union perf_event *event, · line 100

Quoted 10 lines
tools/perf/builtin-script.c +10 -0
+	switch (attr->type) {
+	case PERF_TYPE_SOFTWARE:
+		if (perf_event__preprocess_sample(event, session, &al, sample,
+					  NULL) < 0) {
+			fprintf(stderr, "problem processing %d event, skipping it.\n",
+				event->header.type);
+			return -1;
+		}
+		perf_session__print_sample(session, &al, sample, hide_unresolved);
+		break;

That's not on the right place. This is going to print the events even when we launch scripts. We only want to print them when we launch perf script without a script, which falls back to printing events (look at default_scripting_ops).

Like I suggested you, it's better to extend struct scripting_ops::process_event()
to take the whole event and let the handler decide what to do. Python and Perl scripting engines can just extract the raw sample and do like they did before.
But print_event(), which is the process_event() handler for the default_scripting_ops,
can handle the new printing features.

That's also more flexible, this lets Python and Perl scripting engines be extendable
to handle the rest of the event later.

#24 lore raw

Re: [PATCH 4/6] perf script: dump software events too

Quoted 15 lines · Frederic Weisbecker

That's not on the right place. This is going to print the events even when we launch scripts. We only want to print them when we launch perf script without a script, which falls back to printing events (look at default_scripting_ops).

Like I suggested you, it's better to extend struct scripting_ops::process_event()
to take the whole event and let the handler decide what to do. Python and Perl scripting engines can just extract the raw sample and do like they did before.
But print_event(), which is the process_event() handler for the default_scripting_ops,
can handle the new printing features.

Quoted 3 lines

That's also more flexible, this lets Python and Perl scripting engines be extendable
to handle the rest of the event later.

I don't follow what you mean.

This is the same place that tracepoints are dumped. In the PERF_TYPE_TRACEPOINT case process_event == print_event which dumps the lines to stdout.

I came in added a switch that invokes a different handler for software events. Software events will be processed differently than tracepoint. The print_event function and its pretty_print function are not designed to dump software events (and eventually hardware events).

David

maintainer
#4 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 42 lines · David Ahern
include/linux/perf_event.h +1 -0
index 51a2f34..404b1ee 100644
@@ -240,6 +240,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_PERIOD          _IOW('$', 4, __u64)
 #define PERF_EVENT_IOC_SET_OUTPUT      _IO ('$', 5)
 #define PERF_EVENT_IOC_SET_FILTER      _IOW('$', 6, char *)
+#define PERF_EVENT_IOC_RECORD_SAMPLE   _IO('$', 7)
 
 enum perf_event_ioc_flags {
        PERF_IOC_FLAG_GROUP             = 1U << 0,
kernel/perf_event.c +8 -0
index a25a63d..7999f55 100644
@@ -3250,6 +3250,7 @@ static struct perf_event *perf_fget_light(int fd, int *fput_needed)
 static int perf_event_set_output(struct perf_event *event,
                                 struct perf_event *output_event);
 static int perf_event_set_filter(struct perf_event *event, void __user *arg);
+static int perf_event_generate_sample(struct perf_event *event);
 
 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -3296,6 +3297,9 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case PERF_EVENT_IOC_SET_FILTER:
                return perf_event_set_filter(event, (void __user *)arg);
 
+       case PERF_EVENT_IOC_RECORD_SAMPLE:
+               return perf_event_generate_sample(event);
+
        default:
                return -ENOTTY;
        }
@@ -4398,6 +4402,21 @@ exit:
        rcu_read_unlock();
 }
 
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+       struct perf_sample_data data;

kernel/perf_event.c exit: · line 4418

Quoted 10 lines
kernel/perf_event.c +10 -0
+       struct pt_regs regs;
+
+       perf_fetch_caller_regs(&regs);
+       event->pmu->read(event);
+       perf_sample_data_init(&data, 0);
+       data.period = event->hw.last_period;
+       perf_event_output(event, 0, &data, &regs);
+
+       return 0;
+}

I'm not quite sure why you need this..

#5 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 8 lines · Peter Zijlstra
Quoted 8 lines
kernel/perf_event.c +8 -0
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+       struct perf_sample_data data;
+       struct pt_regs regs;
+
+       perf_fetch_caller_regs(&regs);
+       event->pmu->read(event);
Quoted 9 lines

kernel/perf_event.c exit: · line 4418

Quoted 6 lines
kernel/perf_event.c +6 -0
+       perf_sample_data_init(&data, 0);
+       data.period = event->hw.last_period;
+       perf_event_output(event, 0, &data, &regs);
+
+       return 0;
+}

I'm not quite sure why you need this..

periodic samples are generated after the specified period. I want the first sample immediately and the remainder based on the set period.

So generically, how do you get the first sample into the event stream and let the others happen based on the timer? I need not only the counter value but also the perf_clock timestamp that comes from the SAMPLE_TIME attribute.

David

#25 lore raw

Re: [PATCH 4/6] perf script: dump software events too

In reply to David Ahern

2011/3/1 David Ahern <[email protected]>:

Quoted 5 lines

I don't follow what you mean.

This is the same place that tracepoints are dumped. In the PERF_TYPE_TRACEPOINT case process_event == print_event which dumps the lines to stdout.

No it's not. scripting_ops can be either default_scripting_ops, perl_scripting_ops
or python_scripting_ops.

Hence process_sample_event() doesn't necessarily ends up pretty print events. It can also invoke a script that may decide to do what it wants with events.

pretty printing must be an endpoint decision.

Quoted 4 lines

I came in added a switch that invokes a different handler for software events. Software events will be processed differently than tracepoint. The print_event function and its pretty_print function are not designed to dump software events (and eventually hardware events).

Why shouldn't it be designed to dump software events? It's called print_event(). Its current version is rather something I would call "limited". But it was not designed
to be limited.

Ideally, we should have print_tracepoint_event() in trace-event-parse.c, print_software_event()
where you want, and have print_event() in builtin-script.c that wraps on those.

maintainer
#6 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 21 lines · David Ahern
Quoted 8 lines · Peter Zijlstra
Quoted 8 lines
kernel/perf_event.c +8 -0
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+       struct perf_sample_data data;
+       struct pt_regs regs;
+
+       perf_fetch_caller_regs(&regs);
+       event->pmu->read(event);
Quoted 9 lines

kernel/perf_event.c exit: · line 4418

Quoted 6 lines
kernel/perf_event.c +6 -0
+       perf_sample_data_init(&data, 0);
+       data.period = event->hw.last_period;
+       perf_event_output(event, 0, &data, &regs);
+
+       return 0;
+}

I'm not quite sure why you need this..

Quoted 7 lines

periodic samples are generated after the specified period. I want the first sample immediately and the remainder based on the set period.

So generically, how do you get the first sample into the event stream and let the others happen based on the timer? I need not only the counter value but also the perf_clock timestamp that comes from the SAMPLE_TIME attribute.

Again, why?

#7 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 25 lines · Peter Zijlstra
Quoted 24 lines · David Ahern
Quoted 8 lines · Peter Zijlstra
Quoted 8 lines
kernel/perf_event.c +8 -0
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+       struct perf_sample_data data;
+       struct pt_regs regs;
+
+       perf_fetch_caller_regs(&regs);
+       event->pmu->read(event);
Quoted 9 lines

kernel/perf_event.c exit: · line 4418

Quoted 6 lines
kernel/perf_event.c +6 -0
+       perf_sample_data_init(&data, 0);
+       data.period = event->hw.last_period;
+       perf_event_output(event, 0, &data, &regs);
+
+       return 0;
+}

I'm not quite sure why you need this..

periodic samples are generated after the specified period. I want the first sample immediately and the remainder based on the set period.

Quoted 7 lines
Quoted 4 lines

So generically, how do you get the first sample into the event stream and let the others happen based on the timer? I need not only the counter value but also the perf_clock timestamp that comes from the SAMPLE_TIME attribute.

Again, why?

realtime-clock counter is created with a period N. How do you correlate perf_clock to time-of-day until now + N? You need a sample from the beginning of the event stream, not N nanoseconds into it.

David

maintainer
#8 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 2 lines · David Ahern

realtime-clock counter is created with a period N. How do you correlate perf_clock to time-of-day until now + N?

You scan fwd? Since its at most N time ahead you're scanning fwd its still constant time.

Thing is, I'm really not convinced this is a very useful ioctl() in generic, and ioctl()s really need a good justification to add.

#9 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 7 lines · Peter Zijlstra
Quoted 2 lines · David Ahern

realtime-clock counter is created with a period N. How do you correlate perf_clock to time-of-day until now + N?

You scan fwd? Since its at most N time ahead you're scanning fwd its still constant time.

So I potentially scan a multi-gigabyte file looking for a single event -- that may not even exist. From a usability perspective the time string should appear if the clock event exists and not if it does not exist. This should happen automatically.

Quoted 4 lines

Thing is, I'm really not convinced this is a very useful ioctl() in generic, and ioctl()s really need a good justification to add.

I did not code it create samples of a realtime-clock event; I coded it to add an event to the stream on demand -- whatever event the fd is tied to.

David

#26 lore raw

Re: [PATCH 4/6] perf script: dump software events too

In reply to Frederic Weisbecker
Quoted 5 lines · Frederic Weisbecker

Why shouldn't it be designed to dump software events? It's called print_event(). Its current version is rather something I would call "limited". But it was not designed
to be limited.

That's because its origins are trace specific. Per last week's thread, perf-script was perf-trace until Nov 2010. perf-script deals with tracepoints.

Quoted 4 lines

Ideally, we should have print_tracepoint_event() in trace-event-parse.c, print_software_event()
where you want, and have print_event() in builtin-script.c that wraps on those.

process_event does not take the event sample, it takes elements of it:

struct scripting_ops {
...
void (*process_event) (int cpu, void *data, int size,
unsigned long long nsecs, char *comm);
...
};

David

#27 lore raw

Re: [PATCH 4/6] perf script: dump software events too

2011/3/1 David Ahern <[email protected]>:

Quoted 12 lines · Frederic Weisbecker
Quoted 5 lines

Why shouldn't it be designed to dump software events? It's called print_event(). Its current version is rather something I would call "limited". But it was not designed
to be limited.

That's because its origins are trace specific. Per last week's thread, perf-script was perf-trace until Nov 2010. perf-script deals with tracepoints.

Right it has been first created to support tracing events. Now why should it stay limited to them?

Quoted 5 lines
Quoted 3 lines

Ideally, we should have print_tracepoint_event() in trace-event-parse.c, print_software_event()
where you want, and have print_event() in builtin-script.c that wraps on those.

Quoted 8 lines

process_event does not take the event sample, it takes elements of it:

struct scripting_ops {
...
   void (*process_event) (int cpu, void *data, int size, unsigned long long nsecs, char *comm);
...
};

What is the problem with changing a function prototype?

maintainer
#10 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 6 lines · David Ahern

I did not code it create samples of a realtime-clock event; I coded it to add an event to the stream on demand -- whatever event the fd is tied to.

Well yes, but aside from you and the realtime clock stuff, who'd ever want to do this particular thing?

I'd much rather expose the whole local_clock()/perf_clock()/trace_clock() (should all be the same anyway) as a posix clock using CLOCK_TRACING or whatever would be an appropriate name.

[ Since the whole thing is NMI safe it should be well possible to make a VDSO version as well. ]

Anyway, once its visible as a posix clock you can sync up from userspace. And this clock is indeed wanted for other things too, like user-space tracing etc.

#11 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · David Ahern

I did not code it create samples of a realtime-clock event; I coded it to add an event to the stream on demand -- whatever event the fd is tied to.

Well yes, but aside from you and the realtime clock stuff, who'd ever want to do this particular thing?

One example would be a system watchdog that decided for some reason or another to force an event sample because of some event it detected.

Quoted 6 lines

I'd much rather expose the whole local_clock()/perf_clock()/trace_clock() (should all be the same anyway) as a posix clock using CLOCK_TRACING or whatever would be an appropriate name.

Quoted 7 lines

[ Since the whole thing is NMI safe it should be well possible to make a VDSO version as well. ]

Anyway, once its visible as a posix clock you can sync up from userspace. And this clock is indeed wanted for other things too, like user-space tracing etc.

And for some silly reason I sense a time trap here (pun intended) .....

So your pushback is:
1. throw out the realtime-clock event patch,

2. add a new CLOCK_TRACING type to clock_gettime with VDSO hook,

3. and use a synthesized event from userspace for snapshotting perf_clock to time-of-day -- similar to what I have now, but one that will guarantee a time-of-day to perf_clock correlation (versus the current one which hopes that perf_clock is the monotonic clock).

David

#28 lore raw

Re: [PATCH 4/6] perf script: dump software events too

In reply to David Ahern

Em Tue, Mar 01, 2011 at 09:11:20AM -0700, David Ahern escreveu:

Quoted 13 lines · Frederic Weisbecker
Quoted 3 lines

Why shouldn't it be designed to dump software events? It's called print_event(). Its current version is rather something I would call "limited". But it was not designed to be limited.

That's because its origins are trace specific. Per last week's thread, perf-script was perf-trace until Nov 2010. perf-script deals with tracepoints.

Quoted 3 lines

Ideally, we should have print_tracepoint_event() in trace-event-parse.c, print_software_event()
where you want, and have print_event() in builtin-script.c that wraps on those.

Quoted 6 lines

process_event does not take the event sample, it takes elements of it:

struct scripting_ops {
...
void (*process_event) (int cpu, void *data, int size,
unsigned long long nsecs, char *comm);

I still have to read the entire thread, but this definetely should receive "struct perf_sample", i.e. the parsed sample and the 'struct thread' from where it can get the comm, etc

Look at the process_event for builtin-script.c:

                scripting_ops->process_event(sample->cpu,
					     sample->raw_data,
                                             sample->raw_size,
                                             sample->time,
					     thread->comm);

I'd change it to:

                scripting_ops->process_event(event, sample, thread);

Or even short circuit it completely modulo debugging, becoming:

static int process_sample_event(union perf_event *event,
struct perf_sample *sample, struct perf_session *session)

{
	if (debug_mode) {
		if (sample->time < last_timestamp) {
			pr_err("Samples misordered, previous: %" PRIu64
			       " this: %" PRIu64 "\n", last_timestamp,
				sample->time);
				nr_unordered++;
		}
		last_timestamp = sample->time;
	} else {
		scripting_ops->process_event(event, sample, session);
		session->hists.stats.total_period += sample->period;
	}
        return 0;
}

Script modules may then do their thread accounting if comms are asked for, etc.

- Arnaldo

#12 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern

Em Tue, Mar 01, 2011 at 09:45:27AM -0700, David Ahern escreveu:

Quoted 30 lines · Peter Zijlstra
Quoted 9 lines · David Ahern
Quoted 6 lines

I did not code it create samples of a realtime-clock event; I coded it to add an event to the stream on demand -- whatever event the fd is tied to.

Well yes, but aside from you and the realtime clock stuff, who'd ever want to do this particular thing?

One example would be a system watchdog that decided for some reason or another to force an event sample because of some event it detected.

Quoted 6 lines

I'd much rather expose the whole local_clock()/perf_clock()/trace_clock() (should all be the same anyway) as a posix clock using CLOCK_TRACING or whatever would be an appropriate name.

Quoted 7 lines

[ Since the whole thing is NMI safe it should be well possible to make a VDSO version as well. ]

Anyway, once its visible as a posix clock you can sync up from userspace. And this clock is indeed wanted for other things too, like user-space tracing etc.

Quoted 4 lines

And for some silly reason I sense a time trap here (pun intended) .....

So your pushback is:
1. throw out the realtime-clock event patch,

Nope

Quoted 1 line

2. add a new CLOCK_TRACING type to clock_gettime with VDSO hook,

Yes

Quoted 4 lines

3. and use a synthesized event from userspace for snapshotting perf_clock to time-of-day -- similar to what I have now, but one that will guarantee a time-of-day to perf_clock correlation (versus the current one which hopes that perf_clock is the monotonic clock).

Nope.

My understanding was that for the initial gettime you use clock_gettime(), and then you get CLOCK_REALTIME events in the stream for resynch, etc.

Peter?

- Arnaldo

#13 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Em Tue, Mar 01, 2011 at 02:07:50PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 38 lines

Em Tue, Mar 01, 2011 at 09:45:27AM -0700, David Ahern escreveu:

Quoted 28 lines · Peter Zijlstra
Quoted 9 lines · David Ahern
Quoted 6 lines

I did not code it create samples of a realtime-clock event; I coded it to add an event to the stream on demand -- whatever event the fd is tied to.

Well yes, but aside from you and the realtime clock stuff, who'd ever want to do this particular thing?

One example would be a system watchdog that decided for some reason or another to force an event sample because of some event it detected.

Quoted 6 lines

I'd much rather expose the whole local_clock()/perf_clock()/trace_clock() (should all be the same anyway) as a posix clock using CLOCK_TRACING or whatever would be an appropriate name.

Quoted 7 lines

[ Since the whole thing is NMI safe it should be well possible to make a VDSO version as well. ]

Anyway, once its visible as a posix clock you can sync up from userspace. And this clock is indeed wanted for other things too, like user-space tracing etc.

Quoted 4 lines

And for some silly reason I sense a time trap here (pun intended) .....

So your pushback is:
1. throw out the realtime-clock event patch,

Nope

Quoted 1 line

2. add a new CLOCK_TRACING type to clock_gettime with VDSO hook,

Quoted 8 lines

Yes

Quoted 4 lines

3. and use a synthesized event from userspace for snapshotting perf_clock to time-of-day -- similar to what I have now, but one that will guarantee a time-of-day to perf_clock correlation (versus the current one which hopes that perf_clock is the monotonic clock).

Nope.

I see, yeah, the very first CLOCK_REALTIME sample would be synthesized from the return of clock_gettime(CLOCK_TRACING), all the others would come in the event stream.

Quoted 7 lines

My understanding was that for the initial gettime you use clock_gettime(), and then you get CLOCK_REALTIME events in the stream for resynch, etc.

Peter?

- Arnaldo

maintainer
#14 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 2 lines · David Ahern

One example would be a system watchdog that decided for some reason or another to force an event sample because of some event it detected.

That would be a design error, there already is an event, use that.

Quoted 14 lines
Quoted 6 lines

I'd much rather expose the whole local_clock()/perf_clock()/trace_clock() (should all be the same anyway) as a posix clock using CLOCK_TRACING or whatever would be an appropriate name.

Quoted 7 lines

[ Since the whole thing is NMI safe it should be well possible to make a VDSO version as well. ]

Anyway, once its visible as a posix clock you can sync up from userspace. And this clock is indeed wanted for other things too, like user-space tracing etc.

Quoted 4 lines

And for some silly reason I sense a time trap here (pun intended) .....

So your pushback is:
1. throw out the realtime-clock event patch,

Well, no, you need continues samples to keep in sync, so having this is required [*].

Quoted 1 line

2. add a new CLOCK_TRACING type to clock_gettime with VDSO hook,

Right, that is something we need anyway at some point in time.

Quoted 4 lines

3. and use a synthesized event from userspace for snapshotting perf_clock to time-of-day -- similar to what I have now, but one that will guarantee a time-of-day to perf_clock correlation (versus the current one which hopes that perf_clock is the monotonic clock).

I guess you could do that if we have full userspace tracing support, but it wouldn't need synthesized events, it would need a pure userspace event stream.

Thing is, I really dislike the ioctl() trigger

#15 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 12 lines · Peter Zijlstra
Quoted 4 lines

And for some silly reason I sense a time trap here (pun intended) .....

So your pushback is:
1. throw out the realtime-clock event patch,

Well, no, you need continues samples to keep in sync, so having this is required [*].

Quoted 1 line

2. add a new CLOCK_TRACING type to clock_gettime with VDSO hook,

Right, that is something we need anyway at some point in time.

Quoted 8 lines
Quoted 4 lines

3. and use a synthesized event from userspace for snapshotting perf_clock to time-of-day -- similar to what I have now, but one that will guarantee a time-of-day to perf_clock correlation (versus the current one which hopes that perf_clock is the monotonic clock).

I guess you could do that if we have full userspace tracing support, but it wouldn't need synthesized events, it would need a pure userspace event stream.

I still don't see how this solves the need to trigger the initial sample into the event stream.

David

Quoted 5 lines

Thing is, I really dislike the ioctl() trigger

#16 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 9 lines · David Ahern

Enable data collection for generating time-of-day strings when printing individual perf samples. This is done by sampling the realtime clock event with the perf_clock time stamps.

If the realtime-clock event is not available (e.g, older kernels) fallback to a synthesized event. (I realize there is resistance to new synthesized events, but it is a simple way to gain this feature on older kernels without the need to modify the kernel code).

...

Quoted 4 lines
kernel/perf_event.c +4 -0
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+	struct perf_sample_data data;

kernel/perf_event.c exit: · line 4418

Quoted 10 lines
kernel/perf_event.c +10 -0
+	struct pt_regs regs;
+
+	perf_fetch_caller_regs(&regs);
+	event->pmu->read(event);
+	perf_sample_data_init(&data, 0);
+	data.period = event->hw.last_period;
+	perf_event_output(event, 0, &data, &regs);
+
+	return 0;
+}

Errm. This is a generic ioctl to inject random events from user space.

First of all this wants to be a separate patch and not burried into some 100 lines of changes to tools/perf.

Secondly adding such an ioctl needs a pretty good reason, and the use case at hand is not really one.

Reading through the other patches, your goal is to correlate CLOCK_REALTIME based logs to CLOCK_PERF based events.

To achieve that you inject cyclic clock_realtime samples into the event stream and want to have this initial event inserted via the ioctl.

How does all that deal with CLOCK_REALTIME being affected by NTP and settimeofday? Not really, as far as I can tell. It somehow works, but that depends on the frequency of your event injection.

To be honest, that's just too much churn for a feature which is single purpose and questionable functionality.

It would be far more interesting to have trace points in the timekeeping code, which are useful for other things as well (e.g. precise monitoring of NTP) and provide always a correct association with the trace clock. That would cover everything from frequency adjustments, clock setting including the information about the relation to clock monotonic.

Thanks,

tglx

#17 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 31 lines · Thomas Gleixner
Quoted 9 lines · David Ahern

Enable data collection for generating time-of-day strings when printing individual perf samples. This is done by sampling the realtime clock event with the perf_clock time stamps.

If the realtime-clock event is not available (e.g, older kernels) fallback to a synthesized event. (I realize there is resistance to new synthesized events, but it is a simple way to gain this feature on older kernels without the need to modify the kernel code).

...

Quoted 4 lines
kernel/perf_event.c +4 -0
+/* add a sample to the event stream based on user request */
+static int perf_event_generate_sample(struct perf_event *event)
+{
+	struct perf_sample_data data;

kernel/perf_event.c exit: · line 4418

Quoted 10 lines
kernel/perf_event.c +10 -0
+	struct pt_regs regs;
+
+	perf_fetch_caller_regs(&regs);
+	event->pmu->read(event);
+	perf_sample_data_init(&data, 0);
+	data.period = event->hw.last_period;
+	perf_event_output(event, 0, &data, &regs);
+
+	return 0;
+}

Errm. This is a generic ioctl to inject random events from user space.

Quoted 5 lines

First of all this wants to be a separate patch and not burried into some 100 lines of changes to tools/perf.

Secondly adding such an ioctl needs a pretty good reason, and the use case at hand is not really one.

Peter has made it clear he objects to the ioctl.

Quoted 7 lines

Reading through the other patches, your goal is to correlate CLOCK_REALTIME based logs to CLOCK_PERF based events.

To achieve that you inject cyclic clock_realtime samples into the event stream and want to have this initial event inserted via the ioctl.

I still need a solution. There is no means for requesting a sample immediately when a counter is opened, and there is a desire not to add any more synthesized events. How then do I get the initial correlation without scanning a potentially large file looking for a single event type occurrence.

Quoted 4 lines

How does all that deal with CLOCK_REALTIME being affected by NTP and settimeofday? Not really, as far as I can tell. It somehow works, but that depends on the frequency of your event injection.

It is sampled at some periodic rate to get NTP changes. Right now it is hardcoded at once an hour. The frequency option can be added to the --tod parameter.

Quoted 10 lines

To be honest, that's just too much churn for a feature which is single purpose and questionable functionality.

It would be far more interesting to have trace points in the timekeeping code, which are useful for other things as well (e.g. precise monitoring of NTP) and provide always a correct association with the trace clock. That would cover everything from frequency adjustments, clock setting including the information about the relation to clock monotonic.

I'm not looking to track ntp changes. I want time-of-day strings on sample dumps. That is not a questionable feature request; it is a usability enhancement.

We are users of perf. Fantastic tool, but of limited functionality to the engineers on the team if they cannot correlate event samples with application logs.

David

Quoted 4 lines

Thanks,

tglx

#18 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

Quoted 8 lines · David Ahern
Quoted 3 lines · Thomas Gleixner

How does all that deal with CLOCK_REALTIME being affected by NTP and settimeofday? Not really, as far as I can tell. It somehow works, but that depends on the frequency of your event injection.

It is sampled at some periodic rate to get NTP changes. Right now it is hardcoded at once an hour. The frequency option can be added to the --tod parameter.

Once an hour. Brilliant. And how do you correlated that when settimeofday was called 5 times in between the samples. Not at all.

Quoted 11 lines
Quoted 10 lines

To be honest, that's just too much churn for a feature which is single purpose and questionable functionality.

It would be far more interesting to have trace points in the timekeeping code, which are useful for other things as well (e.g. precise monitoring of NTP) and provide always a correct association with the trace clock. That would cover everything from frequency adjustments, clock setting including the information about the relation to clock monotonic.

Quoted 3 lines

I'm not looking to track ntp changes. I want time-of-day strings on sample dumps. That is not a questionable feature request; it is a usability enhancement.

Sigh, did you even read what I wrote?

I did not say, that YOU have to track NTP changes.

And I fully understood that you want to correlate perf time stamps with CLOCK_REALTIME.

Neither did I say, that this is a questionable feature request.

I merily objected to add functionality which is half baken and only particular useful.

Further I made a suggestion to add trace points to the time keeping code instead, which

- solve your problem
- are useful for other purposes
- do not require ioctls, timer driven sw events

Thanks,

tglx

#20 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to David Ahern
Quoted 7 lines · David Ahern
Quoted 3 lines

How does all that deal with CLOCK_REALTIME being affected by NTP and settimeofday? Not really, as far as I can tell. It somehow works, but that depends on the frequency of your event injection.

It is sampled at some periodic rate to get NTP changes. Right now it is hardcoded at once an hour. The frequency option can be added to the --tod parameter.

As Thomas mentioned, we probably need something more complete than that.

Still your approach is obviously useful and i'd like to stress that explicitly. Have you considered another related feature, feeding printk lines as special 'string events' into the perf ringbuffer?

It would round up your scheme very nicely: that way you'd have a single, global, GTOD-correlated event store/flow for basically every system event you might be interested in. You could switch events (and tracepoints) on/off based on need, controlling the type and rate of information in a very finegrained way.

If the printk approach works out i'd even suggest that such a facility would need a separate tool within perf: 'perf syslog' or 'perf log'. It would heavily reuse perf-script and other perf internal facilities, obviously - but you would not be tied to any particular sub-tool implementation.

EDAC type events could feed into this as well, giving the tool a broader 'system health' aspect as well, beyond the 'system performance analysis' aspect.

Thanks,

Ingo

#19 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to Thomas Gleixner
Quoted 2 lines · Thomas Gleixner

Further I made a suggestion to add trace points to the time keeping code instead, which

Ok, so let's say we have a tracepoint in do_settimeofday, another in whatever function is needed to get ntp updates to the timekeeper parameters. I still don't see how the initial sample is grabbed. I definitely do not want a tracepoint in any of the gettimeofday functions. Furthermore, seems like timekeeping code now needs to be replicated within perf to some degree.

How about a simpler alternative? Adding the time-of-day stamp to the samples. --tod is an optional parameter, and if desired a warning can be added to the usage about the additional overhead of reading gettimeofday for each sample. Users can decided if the overhead is acceptable (this is still much lighterweight than strace which has a time-of-day option).

This is the kernel side change; userspace changes are much simpler as well.

include/linux/perf_event.h +3 -1
index 8ceb5a6..3297394 100644
@@ -125,8 +125,9 @@ enum perf_event_sample_format {
 	PERF_SAMPLE_PERIOD			= 1U << 8,
 	PERF_SAMPLE_STREAM_ID			= 1U << 9,
 	PERF_SAMPLE_RAW				= 1U << 10,
+	PERF_SAMPLE_REALTIME			= 1U << 11,
 
-	PERF_SAMPLE_MAX = 1U << 11,		/* non-ABI */
+	PERF_SAMPLE_MAX = 1U << 12,		/* non-ABI */
 };
 
 /*
@@ -989,6 +990,7 @@ struct perf_sample_data {
 		u32	cpu;
 		u32	reserved;
 	}				cpu_entry;
+	u64				realtime;
 	u64				period;
 	struct perf_callchain_entry	*callchain;
 	struct perf_raw_record		*raw;
kernel/perf_event.c +0 -0
index 64a018e..0711cc9 100644
@@ -908,6 +908,9 @@ static void perf_event__id_header_size(struct

perf_event *event)
if (sample_type & PERF_SAMPLE_CPU)
size += sizeof(data->cpu_entry);

+ if (sample_type & PERF_SAMPLE_REALTIME)
+ size += sizeof(data->realtime);
+
event->id_header_size = size;
}

@@ -4010,6 +4013,9 @@ static void __perf_event_header__init_id(struct perf_event_header *header,
if (sample_type & PERF_SAMPLE_TIME)
data->time = perf_clock();

+ if (sample_type & PERF_SAMPLE_REALTIME)
+ data->realtime = ktime_to_ns(ktime_get_real());
+
if (sample_type & PERF_SAMPLE_ID)
data->id = primary_event_id(event);

@@ -4049,6 +4055,9 @@ static void __perf_event__output_id_sample(struct perf_output_handle *handle,

if (sample_type & PERF_SAMPLE_CPU)
perf_output_put(handle, data->cpu_entry);
+
+ if (sample_type & PERF_SAMPLE_REALTIME)
+ perf_output_put(handle, data->realtime);
}

static void perf_event__output_id_sample(struct perf_event *event,
@@ -4293,6 +4302,9 @@ void perf_output_sample(struct perf_output_handle *handle,
if (sample_type & PERF_SAMPLE_CPU)
perf_output_put(handle, data->cpu_entry);

+ if (sample_type & PERF_SAMPLE_REALTIME)
+ perf_output_put(handle, data->realtime);
+
if (sample_type & PERF_SAMPLE_PERIOD)
perf_output_put(handle, data->period);

#21 lore raw

Re: [PATCH 3/6] perf record: add time-of-day option

In reply to Ingo Molnar
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · David Ahern
Quoted 3 lines

How does all that deal with CLOCK_REALTIME being affected by NTP and settimeofday? Not really, as far as I can tell. It somehow works, but that depends on the frequency of your event injection.

Quoted 5 lines
Quoted 3 lines

It is sampled at some periodic rate to get NTP changes. Right now it is hardcoded at once an hour. The frequency option can be added to the --tod parameter.

As Thomas mentioned, we probably need something more complete than that.

Just responded to Thomas' email with a simpler proposal than munging on tracepoints and trying to track time-of-day implicitly.

Quoted 1 line

Still your approach is obviously useful and i'd like to stress that explicitly. Have

Thanks for stating that.

Quoted 8 lines

you considered another related feature, feeding printk lines as special 'string events' into the perf ringbuffer?

It would round up your scheme very nicely: that way you'd have a single, global, GTOD-correlated event store/flow for basically every system event you might be interested in. You could switch events (and tracepoints) on/off based on need, controlling the type and rate of information in a very finegrained way.

Quoted 7 lines

If the printk approach works out i'd even suggest that such a facility would need a separate tool within perf: 'perf syslog' or 'perf log'. It would heavily reuse perf-script and other perf internal facilities, obviously - but you would not be tied to any particular sub-tool implementation.

EDAC type events could feed into this as well, giving the tool a broader 'system health' aspect as well, beyond the 'system performance analysis' aspect.

I can look into it (as time allows) once I get the dumping of software events done.

David

Quoted 4 lines

Thanks,

Ingo