diff options
| -rw-r--r-- | tools/perf/builtin-record.c | 36 | ||||
| -rw-r--r-- | tools/perf/util/parse-events.c | 2 |
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 | ||
| 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 | } |
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 | ||
