aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorMike Galbraith <efault@gmx.de>2009-10-12 01:56:03 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-12 03:10:55 -0400
commit7e4ff9e3e8f88de8a8536f43294cd32b4e7d9123 (patch)
tree4033b2ab865ce039f0287059c520be8703a08d42 /tools/perf/builtin-top.c
parentfe9081cc9bdabb0be953a39ad977cea14e35bce5 (diff)
perf tools: Fix counter sample frequency breakage
Commit 42e59d7d19dc4b4 switched to a default sample frequency of 1KHz, which overrides any user supplied count, causing sched, top and timechart to miss events due to their discrete events being flagged PERF_SAMPLE_PERIOD. Override default sample frequency when the user profides a period count, and make both record and top honor that user supplied option. Signed-off-by: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arjan van de Ven <arjan@infradead.org> LKML-Reference: <1255326963.15107.2.camel@marge.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index d978dc99236c..c0f69e80b2cc 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -57,7 +57,7 @@ static int fd[MAX_NR_CPUS][MAX_COUNTERS];
57 57
58static int system_wide = 0; 58static int system_wide = 0;
59 59
60static int default_interval = 100000; 60static int default_interval = 0;
61 61
62static int count_filter = 5; 62static int count_filter = 5;
63static int print_entries = 15; 63static int print_entries = 15;
@@ -975,7 +975,13 @@ static void start_counter(int i, int counter)
975 attr = attrs + counter; 975 attr = attrs + counter;
976 976
977 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; 977 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
978 attr->freq = freq; 978
979 if (freq) {
980 attr->sample_type |= PERF_SAMPLE_PERIOD;
981 attr->freq = 1;
982 attr->sample_freq = freq;
983 }
984
979 attr->inherit = (cpu < 0) && inherit; 985 attr->inherit = (cpu < 0) && inherit;
980 986
981try_again: 987try_again:
@@ -1130,11 +1136,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1130 if (argc) 1136 if (argc)
1131 usage_with_options(top_usage, options); 1137 usage_with_options(top_usage, options);
1132 1138
1133 if (freq) {
1134 default_interval = freq;
1135 freq = 1;
1136 }
1137
1138 /* CPU and PID are mutually exclusive */ 1139 /* CPU and PID are mutually exclusive */
1139 if (target_pid != -1 && profile_cpu != -1) { 1140 if (target_pid != -1 && profile_cpu != -1) {
1140 printf("WARNING: PID switch overriding CPU\n"); 1141 printf("WARNING: PID switch overriding CPU\n");
@@ -1151,6 +1152,19 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1151 parse_symbols(); 1152 parse_symbols();
1152 parse_source(sym_filter_entry); 1153 parse_source(sym_filter_entry);
1153 1154
1155
1156 /*
1157 * User specified count overrides default frequency.
1158 */
1159 if (default_interval)
1160 freq = 0;
1161 else if (freq) {
1162 default_interval = freq;
1163 } else {
1164 fprintf(stderr, "frequency and count are zero, aborting\n");
1165 exit(EXIT_FAILURE);
1166 }
1167
1154 /* 1168 /*
1155 * Fill in the ones not specifically initialized via -c: 1169 * Fill in the ones not specifically initialized via -c:
1156 */ 1170 */