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: [PATCH 5/6] perf_counter: kerneltop: mmap_pages argument
Date: Wed, 25 Mar 2009 12:30:26 +0100 [thread overview]
Message-ID: <20090325113317.104545398@chello.nl> (raw)
In-Reply-To: 20090325113021.781490788@chello.nl
[-- Attachment #1: mike-perf_counter_tools-mmap-pages.patch --]
[-- Type: text/plain, Size: 3613 bytes --]
provide a knob to set the number of mmap data pages.
Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
Documentation/perf_counter/kerneltop.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 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
@@ -178,6 +178,7 @@ static int nr_cpus = 0;
static int nmi = 1;
static int group = 0;
static unsigned int page_size;
+static unsigned int mmap_pages = 4;
static char *vmlinux;
@@ -326,6 +327,7 @@ static void display_help(void)
" -x path --vmlinux=<path> # the vmlinux binary, required for -s use\n"
" -z --zero # zero counts after display\n"
" -D --dump_symtab # dump symbol table to stderr on startup\n"
+ " -m pages --mmap_pages=<pages> # number of mmap data pages\n"
);
exit(0);
@@ -732,7 +734,9 @@ static int read_symbol(FILE *in, struct
/* Tag events to be skipped. */
if (!strcmp("default_idle", s->sym) || !strcmp("cpu_idle", s->sym))
s->skip = 1;
- if (!strcmp("enter_idle", s->sym) || !strcmp("exit_idle", s->sym))
+ else if (!strcmp("enter_idle", s->sym) || !strcmp("exit_idle", s->sym))
+ s->skip = 1;
+ else if (!strcmp("mwait_idle", s->sym))
s->skip = 1;
if (filter_match == 1) {
@@ -1042,9 +1046,10 @@ static void process_options(int argc, ch
{"symbol", required_argument, NULL, 's'},
{"stat", no_argument, NULL, 'S'},
{"zero", no_argument, NULL, 'z'},
+ {"mmap_pages", required_argument, NULL, 'm'},
{NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "+:ac:C:d:De:f:g:hn:p:s:Sx:z",
+ int c = getopt_long(argc, argv, "+:ac:C:d:De:f:g:hn:m:p:s:Sx:z",
long_options, &option_index);
if (c == -1)
break;
@@ -1081,6 +1086,7 @@ static void process_options(int argc, ch
case 'S': run_perfstat = 1; break;
case 'x': vmlinux = strdup(optarg); break;
case 'z': zero = 1; break;
+ case 'm': mmap_pages = atoi(optarg); break;
default: error = 1; break;
}
}
@@ -1134,17 +1140,30 @@ repeat:
return head;
}
+struct timeval last_read, this_read;
+
static void mmap_read(struct mmap_data *md)
{
unsigned int head = mmap_read_head(md);
unsigned int old = md->prev;
unsigned char *data = md->base + page_size;
+ gettimeofday(&this_read, NULL);
+
if (head - old > md->mask) {
- printf("ERROR: failed to keep up with mmap data\n");
- exit(-1);
+ struct timeval iv;
+ unsigned long msecs;
+
+ timersub(&this_read, &last_read, &iv);
+ msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
+
+ fprintf(stderr, "WARNING: failed to keep up with mmap data. Last read %lu msecs ago.\n", msecs);
+
+ old = head;
}
+ last_read = this_read;
+
for (; old != head;) {
__u64 *ptr = (__u64 *)&data[old & md->mask];
old += sizeof(__u64);
@@ -1220,8 +1239,8 @@ int main(int argc, char *argv[])
mmap_array[i][counter].counter = counter;
mmap_array[i][counter].prev = 0;
- mmap_array[i][counter].mask = 2*page_size - 1;
- mmap_array[i][counter].base = mmap(NULL, 3*page_size,
+ mmap_array[i][counter].mask = mmap_pages*page_size - 1;
+ mmap_array[i][counter].base = mmap(NULL, (mmap_pages+1)*page_size,
PROT_READ, MAP_SHARED, fd[i][counter], 0);
if (mmap_array[i][counter].base == MAP_FAILED) {
printf("kerneltop error: failed to mmap with %d (%s)\n",
--
next prev parent reply other threads:[~2009-03-25 11:40 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 11:30 [PATCH 0/6] perf_counter: new output ABI Peter Zijlstra
2009-03-25 11:30 ` [PATCH 1/6] perf_counter: more elaborate write API Peter Zijlstra
2009-03-25 12:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-25 11:30 ` [PATCH 2/6] perf_counter: output objects Peter Zijlstra
2009-03-25 12:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-25 11:30 ` [PATCH 3/6] perf_counter: sanity check on the output API Peter Zijlstra
2009-03-25 12:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-25 11:30 ` [PATCH 4/6] perf_counter: optionally provide the pid/tid of the sampled task Peter Zijlstra
2009-03-25 12:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-25 11:30 ` Peter Zijlstra [this message]
2009-03-25 12:07 ` [tip:perfcounters/core] perf_counter: kerneltop: mmap_pages argument Peter Zijlstra
2009-03-25 12:18 ` [PATCH 5/6] " Ingo Molnar
2009-03-25 12:27 ` Peter Zijlstra
2009-03-25 12:35 ` Ingo Molnar
2009-03-25 12:41 ` Peter Zijlstra
2009-03-25 12:54 ` Ingo Molnar
2009-03-25 12:57 ` Peter Zijlstra
2009-03-25 14:52 ` Peter Zijlstra
2009-03-25 17:16 ` Ingo Molnar
2009-03-25 21:18 ` Peter Zijlstra
2009-03-26 2:22 ` Paul Mackerras
2009-03-25 11:30 ` [PATCH 6/6] perf_counter: kerneltop: output event support Peter Zijlstra
2009-03-25 12:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-04 0:21 ` [PATCH 6/6] " Corey Ashford
2009-04-04 12:17 ` Peter Zijlstra
2009-04-04 18:10 ` Corey Ashford
2009-03-25 12:05 ` [PATCH 0/6] perf_counter: new output ABI Ingo Molnar
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=20090325113317.104545398@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