aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2010-04-14 16:09:02 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-04-14 22:12:52 -0400
commitf92128193094c288bc315db1694fafeaeb7ee1d0 (patch)
tree492e6ead96b08c4a5d8761d75252afb9a084f66a /tools/perf
parentbdef3b02ceeb97f5f67fcfa6dff13c4e70b34fb7 (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')
-rw-r--r--tools/perf/builtin-record.c36
-rw-r--r--tools/perf/util/parse-events.c2
2 files changed, 24 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
34static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; 34static int *fd[MAX_NR_CPUS][MAX_COUNTERS];
35 35
36static unsigned int user_interval = UINT_MAX;
36static long default_interval = 0; 37static long default_interval = 0;
37 38
38static int nr_cpus = 0; 39static int nr_cpus = 0;
39static unsigned int page_size; 40static unsigned int page_size;
40static unsigned int mmap_pages = 128; 41static unsigned int mmap_pages = 128;
42static unsigned int user_freq = UINT_MAX;
41static int freq = 1000; 43static int freq = 1000;
42static int output; 44static int output;
43static const char *output_name = "perf.data"; 45static 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
717int cmd_record(int argc, const char **argv, const char *prefix __used) 728int 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}
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 880070c02fd2..3b4ec6797565 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -422,6 +422,8 @@ parse_single_tracepoint_event(char *sys_name,
422 attr->sample_type |= PERF_SAMPLE_TIME; 422 attr->sample_type |= PERF_SAMPLE_TIME;
423 attr->sample_type |= PERF_SAMPLE_CPU; 423 attr->sample_type |= PERF_SAMPLE_CPU;
424 424
425 attr->sample_period = 1;
426
425 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path, 427 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
426 sys_name, evt_name); 428 sys_name, evt_name);
427 429