diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-14 16:09:02 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-14 22:12:52 -0400 |
commit | f92128193094c288bc315db1694fafeaeb7ee1d0 (patch) | |
tree | 492e6ead96b08c4a5d8761d75252afb9a084f66a /tools/perf/builtin-record.c | |
parent | bdef3b02ceeb97f5f67fcfa6dff13c4e70b34fb7 (diff) |
perf: Make the trace events sample period default to 1
Trace events are mostly used for tracing and then require not to
be lost when possible. As opposite to hardware events that really
require to trigger after a given sample period, trace events mostly
need to trigger everytime.
It is a frustrating experience to trace with perf and realize we
lost a lot of events because we forgot the "-c 1" option.
Then default sample_period to 1 for trace events but let the user
override it.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index dcda8993082d..ca2affc9233f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -33,11 +33,13 @@ enum write_mode_t { | |||
33 | 33 | ||
34 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; | 34 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; |
35 | 35 | ||
36 | static unsigned int user_interval = UINT_MAX; | ||
36 | static long default_interval = 0; | 37 | static long default_interval = 0; |
37 | 38 | ||
38 | static int nr_cpus = 0; | 39 | static int nr_cpus = 0; |
39 | static unsigned int page_size; | 40 | static unsigned int page_size; |
40 | static unsigned int mmap_pages = 128; | 41 | static unsigned int mmap_pages = 128; |
42 | static unsigned int user_freq = UINT_MAX; | ||
41 | static int freq = 1000; | 43 | static int freq = 1000; |
42 | static int output; | 44 | static int output; |
43 | static const char *output_name = "perf.data"; | 45 | static const char *output_name = "perf.data"; |
@@ -255,10 +257,19 @@ static void create_counter(int counter, int cpu) | |||
255 | if (nr_counters > 1) | 257 | if (nr_counters > 1) |
256 | attr->sample_type |= PERF_SAMPLE_ID; | 258 | attr->sample_type |= PERF_SAMPLE_ID; |
257 | 259 | ||
258 | if (freq) { | 260 | /* |
259 | attr->sample_type |= PERF_SAMPLE_PERIOD; | 261 | * We default some events to a 1 default interval. But keep |
260 | attr->freq = 1; | 262 | * it a weak assumption overridable by the user. |
261 | attr->sample_freq = freq; | 263 | */ |
264 | if (!attr->sample_period || (user_freq != UINT_MAX && | ||
265 | user_interval != UINT_MAX)) { | ||
266 | if (freq) { | ||
267 | attr->sample_type |= PERF_SAMPLE_PERIOD; | ||
268 | attr->freq = 1; | ||
269 | attr->sample_freq = freq; | ||
270 | } else { | ||
271 | attr->sample_period = default_interval; | ||
272 | } | ||
262 | } | 273 | } |
263 | 274 | ||
264 | if (no_samples) | 275 | if (no_samples) |
@@ -689,13 +700,13 @@ static const struct option options[] = { | |||
689 | "CPU to profile on"), | 700 | "CPU to profile on"), |
690 | OPT_BOOLEAN('f', "force", &force, | 701 | OPT_BOOLEAN('f', "force", &force, |
691 | "overwrite existing data file (deprecated)"), | 702 | "overwrite existing data file (deprecated)"), |
692 | OPT_LONG('c', "count", &default_interval, | 703 | OPT_LONG('c', "count", &user_interval, |
693 | "event period to sample"), | 704 | "event period to sample"), |
694 | OPT_STRING('o', "output", &output_name, "file", | 705 | OPT_STRING('o', "output", &output_name, "file", |
695 | "output file name"), | 706 | "output file name"), |
696 | OPT_BOOLEAN('i', "inherit", &inherit, | 707 | OPT_BOOLEAN('i', "inherit", &inherit, |
697 | "child tasks inherit counters"), | 708 | "child tasks inherit counters"), |
698 | OPT_INTEGER('F', "freq", &freq, | 709 | OPT_INTEGER('F', "freq", &user_freq, |
699 | "profile at this frequency"), | 710 | "profile at this frequency"), |
700 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, | 711 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, |
701 | "number of mmap data pages"), | 712 | "number of mmap data pages"), |
@@ -716,7 +727,6 @@ static const struct option options[] = { | |||
716 | 727 | ||
717 | int cmd_record(int argc, const char **argv, const char *prefix __used) | 728 | int cmd_record(int argc, const char **argv, const char *prefix __used) |
718 | { | 729 | { |
719 | int counter; | ||
720 | int i,j; | 730 | int i,j; |
721 | 731 | ||
722 | argc = parse_options(argc, argv, options, record_usage, | 732 | argc = parse_options(argc, argv, options, record_usage, |
@@ -774,6 +784,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
774 | if (!event_array) | 784 | if (!event_array) |
775 | return -ENOMEM; | 785 | return -ENOMEM; |
776 | 786 | ||
787 | if (user_interval != UINT_MAX) | ||
788 | default_interval = user_interval; | ||
789 | if (user_freq != UINT_MAX) | ||
790 | freq = user_freq; | ||
791 | |||
777 | /* | 792 | /* |
778 | * User specified count overrides default frequency. | 793 | * User specified count overrides default frequency. |
779 | */ | 794 | */ |
@@ -786,12 +801,5 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
786 | exit(EXIT_FAILURE); | 801 | exit(EXIT_FAILURE); |
787 | } | 802 | } |
788 | 803 | ||
789 | for (counter = 0; counter < nr_counters; counter++) { | ||
790 | if (attrs[counter].sample_period) | ||
791 | continue; | ||
792 | |||
793 | attrs[counter].sample_period = default_interval; | ||
794 | } | ||
795 | |||
796 | return __cmd_record(argc, argv); | 804 | return __cmd_record(argc, argv); |
797 | } | 805 | } |