diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-03-25 07:30:26 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-06 03:30:34 -0400 |
commit | 4c4ba21d2c3659e4c0421533939b58a8fd9f06c9 (patch) | |
tree | a981b39b5ed0adce1642e2236064d1d957a62a91 /Documentation/perf_counter | |
parent | ea5d20cf99db5d26d43b6d322d3ace17e08a6552 (diff) |
perf_counter: kerneltop: mmap_pages argument
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>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Orig-LKML-Reference: <20090325113317.104545398@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter')
-rw-r--r-- | Documentation/perf_counter/kerneltop.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/Documentation/perf_counter/kerneltop.c b/Documentation/perf_counter/kerneltop.c index 7ebde7a336c6..3e45bf6591b2 100644 --- a/Documentation/perf_counter/kerneltop.c +++ b/Documentation/perf_counter/kerneltop.c | |||
@@ -178,6 +178,7 @@ static int nr_cpus = 0; | |||
178 | static int nmi = 1; | 178 | static int nmi = 1; |
179 | static int group = 0; | 179 | static int group = 0; |
180 | static unsigned int page_size; | 180 | static unsigned int page_size; |
181 | static unsigned int mmap_pages = 4; | ||
181 | 182 | ||
182 | static char *vmlinux; | 183 | static char *vmlinux; |
183 | 184 | ||
@@ -326,6 +327,7 @@ static void display_help(void) | |||
326 | " -x path --vmlinux=<path> # the vmlinux binary, required for -s use\n" | 327 | " -x path --vmlinux=<path> # the vmlinux binary, required for -s use\n" |
327 | " -z --zero # zero counts after display\n" | 328 | " -z --zero # zero counts after display\n" |
328 | " -D --dump_symtab # dump symbol table to stderr on startup\n" | 329 | " -D --dump_symtab # dump symbol table to stderr on startup\n" |
330 | " -m pages --mmap_pages=<pages> # number of mmap data pages\n" | ||
329 | ); | 331 | ); |
330 | 332 | ||
331 | exit(0); | 333 | exit(0); |
@@ -732,7 +734,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) | |||
732 | /* Tag events to be skipped. */ | 734 | /* Tag events to be skipped. */ |
733 | if (!strcmp("default_idle", s->sym) || !strcmp("cpu_idle", s->sym)) | 735 | if (!strcmp("default_idle", s->sym) || !strcmp("cpu_idle", s->sym)) |
734 | s->skip = 1; | 736 | s->skip = 1; |
735 | if (!strcmp("enter_idle", s->sym) || !strcmp("exit_idle", s->sym)) | 737 | else if (!strcmp("enter_idle", s->sym) || !strcmp("exit_idle", s->sym)) |
738 | s->skip = 1; | ||
739 | else if (!strcmp("mwait_idle", s->sym)) | ||
736 | s->skip = 1; | 740 | s->skip = 1; |
737 | 741 | ||
738 | if (filter_match == 1) { | 742 | if (filter_match == 1) { |
@@ -1042,9 +1046,10 @@ static void process_options(int argc, char *argv[]) | |||
1042 | {"symbol", required_argument, NULL, 's'}, | 1046 | {"symbol", required_argument, NULL, 's'}, |
1043 | {"stat", no_argument, NULL, 'S'}, | 1047 | {"stat", no_argument, NULL, 'S'}, |
1044 | {"zero", no_argument, NULL, 'z'}, | 1048 | {"zero", no_argument, NULL, 'z'}, |
1049 | {"mmap_pages", required_argument, NULL, 'm'}, | ||
1045 | {NULL, 0, NULL, 0 } | 1050 | {NULL, 0, NULL, 0 } |
1046 | }; | 1051 | }; |
1047 | int c = getopt_long(argc, argv, "+:ac:C:d:De:f:g:hn:p:s:Sx:z", | 1052 | int c = getopt_long(argc, argv, "+:ac:C:d:De:f:g:hn:m:p:s:Sx:z", |
1048 | long_options, &option_index); | 1053 | long_options, &option_index); |
1049 | if (c == -1) | 1054 | if (c == -1) |
1050 | break; | 1055 | break; |
@@ -1081,6 +1086,7 @@ static void process_options(int argc, char *argv[]) | |||
1081 | case 'S': run_perfstat = 1; break; | 1086 | case 'S': run_perfstat = 1; break; |
1082 | case 'x': vmlinux = strdup(optarg); break; | 1087 | case 'x': vmlinux = strdup(optarg); break; |
1083 | case 'z': zero = 1; break; | 1088 | case 'z': zero = 1; break; |
1089 | case 'm': mmap_pages = atoi(optarg); break; | ||
1084 | default: error = 1; break; | 1090 | default: error = 1; break; |
1085 | } | 1091 | } |
1086 | } | 1092 | } |
@@ -1134,17 +1140,30 @@ repeat: | |||
1134 | return head; | 1140 | return head; |
1135 | } | 1141 | } |
1136 | 1142 | ||
1143 | struct timeval last_read, this_read; | ||
1144 | |||
1137 | static void mmap_read(struct mmap_data *md) | 1145 | static void mmap_read(struct mmap_data *md) |
1138 | { | 1146 | { |
1139 | unsigned int head = mmap_read_head(md); | 1147 | unsigned int head = mmap_read_head(md); |
1140 | unsigned int old = md->prev; | 1148 | unsigned int old = md->prev; |
1141 | unsigned char *data = md->base + page_size; | 1149 | unsigned char *data = md->base + page_size; |
1142 | 1150 | ||
1151 | gettimeofday(&this_read, NULL); | ||
1152 | |||
1143 | if (head - old > md->mask) { | 1153 | if (head - old > md->mask) { |
1144 | printf("ERROR: failed to keep up with mmap data\n"); | 1154 | struct timeval iv; |
1145 | exit(-1); | 1155 | unsigned long msecs; |
1156 | |||
1157 | timersub(&this_read, &last_read, &iv); | ||
1158 | msecs = iv.tv_sec*1000 + iv.tv_usec/1000; | ||
1159 | |||
1160 | fprintf(stderr, "WARNING: failed to keep up with mmap data. Last read %lu msecs ago.\n", msecs); | ||
1161 | |||
1162 | old = head; | ||
1146 | } | 1163 | } |
1147 | 1164 | ||
1165 | last_read = this_read; | ||
1166 | |||
1148 | for (; old != head;) { | 1167 | for (; old != head;) { |
1149 | __u64 *ptr = (__u64 *)&data[old & md->mask]; | 1168 | __u64 *ptr = (__u64 *)&data[old & md->mask]; |
1150 | old += sizeof(__u64); | 1169 | old += sizeof(__u64); |
@@ -1220,8 +1239,8 @@ int main(int argc, char *argv[]) | |||
1220 | 1239 | ||
1221 | mmap_array[i][counter].counter = counter; | 1240 | mmap_array[i][counter].counter = counter; |
1222 | mmap_array[i][counter].prev = 0; | 1241 | mmap_array[i][counter].prev = 0; |
1223 | mmap_array[i][counter].mask = 2*page_size - 1; | 1242 | mmap_array[i][counter].mask = mmap_pages*page_size - 1; |
1224 | mmap_array[i][counter].base = mmap(NULL, 3*page_size, | 1243 | mmap_array[i][counter].base = mmap(NULL, (mmap_pages+1)*page_size, |
1225 | PROT_READ, MAP_SHARED, fd[i][counter], 0); | 1244 | PROT_READ, MAP_SHARED, fd[i][counter], 0); |
1226 | if (mmap_array[i][counter].base == MAP_FAILED) { | 1245 | if (mmap_array[i][counter].base == MAP_FAILED) { |
1227 | printf("kerneltop error: failed to mmap with %d (%s)\n", | 1246 | printf("kerneltop error: failed to mmap with %d (%s)\n", |