From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Cc: Paul Mackerras <paulus@samba.org>, Mike Galbraith <efault@gmx.de>,
Arjan van de Ven <arjan@infradead.org>,
Wu Fengguang <fengguang.wu@intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC][PATCH 3/3] perf_counter: kerneltop: parse the mmap data stream
Date: Wed, 25 Mar 2009 22:04:22 +0100 [thread overview]
Message-ID: <20090325210542.382565314@chello.nl> (raw)
In-Reply-To: 20090325210419.408653980@chello.nl
[-- Attachment #1: kerneltop-mmap-events.patch --]
[-- Type: text/plain, Size: 2394 bytes --]
frob the kerneltop code to print the mmap data in the stream
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
Documentation/perf_counter/kerneltop.c | 39 ++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
Index: linux-2.6/Documentation/perf_counter/kerneltop.c
===================================================================
--- linux-2.6.orig/Documentation/perf_counter/kerneltop.c
+++ linux-2.6/Documentation/perf_counter/kerneltop.c
@@ -1184,12 +1184,29 @@ static void mmap_read(struct mmap_data *
last_read = this_read;
for (; old != head;) {
- struct event_struct {
+ struct ip_event {
struct perf_event_header header;
__u64 ip;
__u32 pid, tid;
- } *event = (struct event_struct *)&data[old & md->mask];
- struct event_struct event_copy;
+ };
+ struct mmap_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 start;
+ __u64 len;
+ __u64 pgoff;
+ char filename[PATH_MAX];
+ };
+
+ typedef union event_union {
+ struct perf_event_header header;
+ struct ip_event ip;
+ struct mmap_event mmap;
+ } event_t;
+
+ event_t *event = (event_t *)&data[old & md->mask];
+
+ event_t event_copy;
unsigned int size = event->header.size;
@@ -1199,7 +1216,7 @@ static void mmap_read(struct mmap_data *
*/
if ((old & md->mask) + size != ((old + size) & md->mask)) {
unsigned int offset = old;
- unsigned int len = sizeof(*event), cpy;
+ unsigned int len = min(sizeof(*event), size), cpy;
void *dst = &event_copy;
do {
@@ -1218,7 +1235,18 @@ static void mmap_read(struct mmap_data *
switch (event->header.type) {
case PERF_EVENT_IP:
case PERF_EVENT_IP | __PERF_EVENT_TID:
- process_event(event->ip, md->counter);
+ process_event(event->ip.ip, md->counter);
+ break;
+
+ case PERF_EVENT_MMAP:
+ case PERF_EVENT_MUNMAP:
+ printf("%s: %Lu %Lu %Lu %s\n",
+ event->header.type == PERF_EVENT_MMAP
+ ? "mmap" : "munmap",
+ event->mmap.start,
+ event->mmap.len,
+ event->mmap.pgoff,
+ event->mmap.filename);
break;
}
}
@@ -1267,6 +1295,7 @@ int main(int argc, char *argv[])
hw_event.record_type = PERF_RECORD_IRQ;
hw_event.nmi = nmi;
hw_event.include_tid = 1;
+ hw_event.mmap = 1;
fd[i][counter] = sys_perf_counter_open(&hw_event, tid, cpu, group_fd, 0);
if (fd[i][counter] < 0) {
--
prev parent reply other threads:[~2009-03-25 21:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 21:04 [RFC][PATCH 0/3] more perf_counter stuff Peter Zijlstra
2009-03-25 21:04 ` [RFC][PATCH 1/3] perf_counter: event overlow handling Peter Zijlstra
2009-03-25 21:04 ` [RFC][PATCH 2/3] perf_counter: executable mmap() information Peter Zijlstra
2009-03-26 5:52 ` Paul Mackerras
2009-03-26 10:00 ` Ingo Molnar
2009-03-26 10:57 ` Paul Mackerras
2009-03-26 11:13 ` Paul Mackerras
2009-03-25 21:04 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090325210542.382565314@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=arjan@infradead.org \
--cc=efault@gmx.de \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox