aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-06-05 07:27:02 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-05 07:39:23 -0400
commitcf1f45744c6fa3501e0a6f0ddc418f0ef27e725b (patch)
treeca0823475af28c2b0bcbcc699111712d50836115
parentf250c030a87273f8838a2302bee7c2b4d03e9151 (diff)
perf record, top: Implement --freq
Support frequency-based profiling and make it the default. (Also add a Hz printout in perf top.) Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--Documentation/perf_counter/builtin-record.c10
-rw-r--r--Documentation/perf_counter/builtin-top.c13
2 files changed, 18 insertions, 5 deletions
diff --git a/Documentation/perf_counter/builtin-record.c b/Documentation/perf_counter/builtin-record.c
index 7f2d7ce94075..e2301f39e551 100644
--- a/Documentation/perf_counter/builtin-record.c
+++ b/Documentation/perf_counter/builtin-record.c
@@ -27,6 +27,7 @@ static int fd[MAX_NR_CPUS][MAX_COUNTERS];
27static int nr_cpus = 0; 27static int nr_cpus = 0;
28static unsigned int page_size; 28static unsigned int page_size;
29static unsigned int mmap_pages = 128; 29static unsigned int mmap_pages = 128;
30static int freq = 0;
30static int output; 31static int output;
31static const char *output_name = "perf.data"; 32static const char *output_name = "perf.data";
32static int group = 0; 33static int group = 0;
@@ -347,9 +348,10 @@ static void create_counter(int counter, int cpu, pid_t pid)
347 attr.config = event_id[counter]; 348 attr.config = event_id[counter];
348 attr.sample_period = event_count[counter]; 349 attr.sample_period = event_count[counter];
349 attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; 350 attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
351 attr.freq = freq;
350 attr.mmap = track; 352 attr.mmap = track;
351 attr.comm = track; 353 attr.comm = track;
352 attr.inherit = (cpu < 0) && inherit; 354 attr.inherit = (cpu < 0) && inherit;
353 355
354 track = 0; /* only the first counter needs these */ 356 track = 0; /* only the first counter needs these */
355 357
@@ -520,6 +522,8 @@ static const struct option options[] = {
520 "output file name"), 522 "output file name"),
521 OPT_BOOLEAN('i', "inherit", &inherit, 523 OPT_BOOLEAN('i', "inherit", &inherit,
522 "child tasks inherit counters"), 524 "child tasks inherit counters"),
525 OPT_INTEGER('F', "freq", &freq,
526 "profile at this frequency"),
523 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 527 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
524 "number of mmap data pages"), 528 "number of mmap data pages"),
525 OPT_END() 529 OPT_END()
@@ -540,6 +544,10 @@ int cmd_record(int argc, const char **argv, const char *prefix)
540 event_id[0] = 0; 544 event_id[0] = 0;
541 } 545 }
542 546
547 if (freq) {
548 default_interval = freq;
549 freq = 1;
550 }
543 for (counter = 0; counter < nr_counters; counter++) { 551 for (counter = 0; counter < nr_counters; counter++) {
544 if (event_count[counter]) 552 if (event_count[counter])
545 continue; 553 continue;
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index 28cbde4b6e83..2fee5951b231 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -74,8 +74,8 @@ static int nr_cpus = 0;
74static unsigned int realtime_prio = 0; 74static unsigned int realtime_prio = 0;
75static int group = 0; 75static int group = 0;
76static unsigned int page_size; 76static unsigned int page_size;
77static unsigned int mmap_pages = 16; 77static unsigned int mmap_pages = 16;
78static int freq = 0; 78static int freq = 0;
79 79
80static char *sym_filter; 80static char *sym_filter;
81static unsigned long filter_start; 81static unsigned long filter_start;
@@ -212,8 +212,13 @@ static void print_sym_table(void)
212 events_per_sec, 212 events_per_sec,
213 100.0 - (100.0*((events_per_sec-kevents_per_sec)/events_per_sec))); 213 100.0 - (100.0*((events_per_sec-kevents_per_sec)/events_per_sec)));
214 214
215 if (nr_counters == 1) 215 if (nr_counters == 1) {
216 printf("%d ", event_count[0]); 216 printf("%d", event_count[0]);
217 if (freq)
218 printf("Hz ");
219 else
220 printf(" ");
221 }
217 222
218 for (counter = 0; counter < nr_counters; counter++) { 223 for (counter = 0; counter < nr_counters; counter++) {
219 if (counter) 224 if (counter)