[PATCH 6/6] perf tool: Process READ and LOST events in order
From: Ian Munsie
Date: Tue Nov 23 2010 - 00:36:51 EST
From: Ian Munsie <imunsie@xxxxxxxxxxx>
This patches changes the perf tool so that READ and LOST events will be
processed in order of their timestamp, if present.
This is not strictly necessary to fix any known bugs, but it is
foreseeable that knowing the timestamp of these events may be desirable
in the future and if we are going to add a timestamp to them, we may as
well do it now while we are changing the ABI to add timestamps to COMM
and MMAP events anyway.
Signed-off-by: Ian Munsie <imunsie@xxxxxxxxxxx>
---
tools/perf/util/event.h | 2 ++
tools/perf/util/session.c | 18 ++++++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index b9c2b2d..ba0a761 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -51,6 +51,7 @@ struct fork_event {
struct lost_event {
struct perf_event_header header;
+ u64 time; /* && all_timed */
u64 id;
u64 lost;
};
@@ -60,6 +61,7 @@ struct lost_event {
*/
struct read_event {
struct perf_event_header header;
+ u64 time; /* && all_timed */
u32 pid, tid;
u64 value;
u64 time_enabled;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 09d0f3a..025da8f 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -344,6 +344,7 @@ static void event__task_swap(event_t *self)
static void event__read_swap(event_t *self)
{
+ self->read.time = bswap_64(self->mmap.time);
self->read.pid = bswap_32(self->read.pid);
self->read.tid = bswap_32(self->read.tid);
self->read.value = bswap_64(self->read.value);
@@ -436,6 +437,12 @@ static void flush_sample_queue(struct perf_session *s,
case PERF_RECORD_MMAP:
ops->mmap((event_t *)iter->event, s);
break;
+ case PERF_RECORD_LOST:
+ ops->lost((event_t *)iter->event, s);
+ break;
+ case PERF_RECORD_READ:
+ ops->read((event_t *)iter->event, s);
+ break;
default:
printf("Warning: Unrecognised event in flush_sample_queue\n");
}
@@ -652,6 +659,12 @@ static int __perf_session__process_event(struct perf_session *self,
case PERF_RECORD_COMM:
return perf_session__process_timed(event, self, ops,
ops->comm, offset, head);
+ case PERF_RECORD_LOST:
+ return perf_session__process_timed(event, self, ops,
+ ops->lost, offset, head);
+ case PERF_RECORD_READ:
+ return perf_session__process_timed(event, self, ops,
+ ops->read, offset, head);
default: break;
}
@@ -662,10 +675,6 @@ static int __perf_session__process_event(struct perf_session *self,
return ops->fork(event, self);
case PERF_RECORD_EXIT:
return ops->exit(event, self);
- case PERF_RECORD_LOST:
- return ops->lost(event, self);
- case PERF_RECORD_READ:
- return ops->read(event, self);
case PERF_RECORD_THROTTLE:
return ops->throttle(event, self);
case PERF_RECORD_UNTHROTTLE:
@@ -701,6 +710,7 @@ static int perf_session__process_event(struct perf_session *self,
switch (event->header.type) {
case PERF_RECORD_MMAP: case PERF_RECORD_COMM:
+ case PERF_RECORD_LOST: case PERF_RECORD_READ:
/* These events are coming in with the old ABI (missing time
* field), so make a temporary copy following the new ABI data
* structure and set the time field to 0.
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/