diff options
author | Mike Galbraith <efault@gmx.de> | 2009-10-12 01:56:03 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-12 03:10:55 -0400 |
commit | 7e4ff9e3e8f88de8a8536f43294cd32b4e7d9123 (patch) | |
tree | 4033b2ab865ce039f0287059c520be8703a08d42 /tools/perf | |
parent | fe9081cc9bdabb0be953a39ad977cea14e35bce5 (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')
-rw-r--r-- | tools/perf/builtin-record.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 28 |
2 files changed, 34 insertions, 8 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 59af03d80d07..4e3a374e7aa7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; | 27 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; |
28 | 28 | ||
29 | static long default_interval = 100000; | 29 | static long default_interval = 0; |
30 | 30 | ||
31 | static int nr_cpus = 0; | 31 | static int nr_cpus = 0; |
32 | static unsigned int page_size; | 32 | static unsigned int page_size; |
@@ -730,6 +730,18 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
730 | attrs[0].config = PERF_COUNT_HW_CPU_CYCLES; | 730 | attrs[0].config = PERF_COUNT_HW_CPU_CYCLES; |
731 | } | 731 | } |
732 | 732 | ||
733 | /* | ||
734 | * User specified count overrides default frequency. | ||
735 | */ | ||
736 | if (default_interval) | ||
737 | freq = 0; | ||
738 | else if (freq) { | ||
739 | default_interval = freq; | ||
740 | } else { | ||
741 | fprintf(stderr, "frequency and count are zero, aborting\n"); | ||
742 | exit(EXIT_FAILURE); | ||
743 | } | ||
744 | |||
733 | for (counter = 0; counter < nr_counters; counter++) { | 745 | for (counter = 0; counter < nr_counters; counter++) { |
734 | if (attrs[counter].sample_period) | 746 | if (attrs[counter].sample_period) |
735 | continue; | 747 | continue; |
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 | ||
58 | static int system_wide = 0; | 58 | static int system_wide = 0; |
59 | 59 | ||
60 | static int default_interval = 100000; | 60 | static int default_interval = 0; |
61 | 61 | ||
62 | static int count_filter = 5; | 62 | static int count_filter = 5; |
63 | static int print_entries = 15; | 63 | static 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 | ||
981 | try_again: | 987 | try_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 | */ |