aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-02-14 11:18:57 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-02-14 11:18:57 -0500
commit808e122630d45a7f036d25582474d70548a87e2c (patch)
tree96a8d45358110ce48f184d2a62f7816022ff5c1a /tools/perf
parent0c9781280fb672ca09c997df3f14ba506bbdb977 (diff)
perf tools: Invert the sample_id_all logic
Instead of requiring that users of perf_record_opts set .sample_id_all_avail to true, just invert the logic, using .sample_id_all_missing, that doesn't need to be explicitely initialized since gcc will zero members ommitted in a struct initialization. Just like the newly introduced .exclude_{guest,host} feature test. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-ab772uzk78cwybihf0vt7kxw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c7
-rw-r--r--tools/perf/builtin-test.c1
-rw-r--r--tools/perf/builtin-top.c7
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/util/evsel.c4
-rw-r--r--tools/perf/util/top.h2
6 files changed, 10 insertions, 13 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d6c10e8ff6b6..75d230fef202 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -209,7 +209,7 @@ fallback_missing_features:
209 if (opts->exclude_guest_missing) 209 if (opts->exclude_guest_missing)
210 attr->exclude_guest = attr->exclude_host = 0; 210 attr->exclude_guest = attr->exclude_host = 0;
211retry_sample_id: 211retry_sample_id:
212 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 212 attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
213try_again: 213try_again:
214 if (perf_evsel__open(pos, evlist->cpus, evlist->threads, 214 if (perf_evsel__open(pos, evlist->cpus, evlist->threads,
215 opts->group, group_fd) < 0) { 215 opts->group, group_fd) < 0) {
@@ -228,11 +228,11 @@ try_again:
228 "guest or host samples.\n"); 228 "guest or host samples.\n");
229 opts->exclude_guest_missing = true; 229 opts->exclude_guest_missing = true;
230 goto fallback_missing_features; 230 goto fallback_missing_features;
231 } else if (opts->sample_id_all_avail) { 231 } else if (!opts->sample_id_all_missing) {
232 /* 232 /*
233 * Old kernel, no attr->sample_id_type_all field 233 * Old kernel, no attr->sample_id_type_all field
234 */ 234 */
235 opts->sample_id_all_avail = false; 235 opts->sample_id_all_missing = true;
236 if (!opts->sample_time && !opts->raw_samples && !time_needed) 236 if (!opts->sample_time && !opts->raw_samples && !time_needed)
237 attr->sample_type &= ~PERF_SAMPLE_TIME; 237 attr->sample_type &= ~PERF_SAMPLE_TIME;
238 238
@@ -660,7 +660,6 @@ static struct perf_record record = {
660 .user_freq = UINT_MAX, 660 .user_freq = UINT_MAX,
661 .user_interval = ULLONG_MAX, 661 .user_interval = ULLONG_MAX,
662 .freq = 1000, 662 .freq = 1000,
663 .sample_id_all_avail = true,
664 }, 663 },
665 .write_mode = WRITE_FORCE, 664 .write_mode = WRITE_FORCE,
666 .file_new = true, 665 .file_new = true,
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 0f151952a770..3e087ce8daa6 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -1013,7 +1013,6 @@ static int test__PERF_RECORD(void)
1013 .no_delay = true, 1013 .no_delay = true,
1014 .freq = 10, 1014 .freq = 10,
1015 .mmap_pages = 256, 1015 .mmap_pages = 256,
1016 .sample_id_all_avail = true,
1017 }; 1016 };
1018 cpu_set_t *cpu_mask = NULL; 1017 cpu_set_t *cpu_mask = NULL;
1019 size_t cpu_mask_size = 0; 1018 size_t cpu_mask_size = 0;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 02e11ff5a729..e3c63aef8efc 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -876,7 +876,7 @@ fallback_missing_features:
876 if (top->exclude_guest_missing) 876 if (top->exclude_guest_missing)
877 attr->exclude_guest = attr->exclude_host = 0; 877 attr->exclude_guest = attr->exclude_host = 0;
878retry_sample_id: 878retry_sample_id:
879 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; 879 attr->sample_id_all = top->sample_id_all_missing ? 0 : 1;
880try_again: 880try_again:
881 if (perf_evsel__open(counter, top->evlist->cpus, 881 if (perf_evsel__open(counter, top->evlist->cpus,
882 top->evlist->threads, top->group, 882 top->evlist->threads, top->group,
@@ -893,11 +893,11 @@ try_again:
893 "guest or host samples.\n"); 893 "guest or host samples.\n");
894 top->exclude_guest_missing = true; 894 top->exclude_guest_missing = true;
895 goto fallback_missing_features; 895 goto fallback_missing_features;
896 } else if (top->sample_id_all_avail) { 896 } else if (!top->sample_id_all_missing) {
897 /* 897 /*
898 * Old kernel, no attr->sample_id_type_all field 898 * Old kernel, no attr->sample_id_type_all field
899 */ 899 */
900 top->sample_id_all_avail = false; 900 top->sample_id_all_missing = true;
901 goto retry_sample_id; 901 goto retry_sample_id;
902 } 902 }
903 } 903 }
@@ -1122,7 +1122,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1122 .delay_secs = 2, 1122 .delay_secs = 2,
1123 .uid = UINT_MAX, 1123 .uid = UINT_MAX,
1124 .freq = 1000, /* 1 KHz */ 1124 .freq = 1000, /* 1 KHz */
1125 .sample_id_all_avail = true,
1126 .mmap_pages = 128, 1125 .mmap_pages = 128,
1127 .sym_pcnt_filter = 5, 1126 .sym_pcnt_filter = 5,
1128 }; 1127 };
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8b9c43635f4d..f0227e93665d 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -198,7 +198,7 @@ struct perf_record_opts {
198 bool raw_samples; 198 bool raw_samples;
199 bool sample_address; 199 bool sample_address;
200 bool sample_time; 200 bool sample_time;
201 bool sample_id_all_avail; 201 bool sample_id_all_missing;
202 bool exclude_guest_missing; 202 bool exclude_guest_missing;
203 bool system_wide; 203 bool system_wide;
204 bool period; 204 bool period;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f910f50136d0..302d49a9f985 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -68,7 +68,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
68 struct perf_event_attr *attr = &evsel->attr; 68 struct perf_event_attr *attr = &evsel->attr;
69 int track = !evsel->idx; /* only the first counter needs these */ 69 int track = !evsel->idx; /* only the first counter needs these */
70 70
71 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 71 attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
72 attr->inherit = !opts->no_inherit; 72 attr->inherit = !opts->no_inherit;
73 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | 73 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
74 PERF_FORMAT_TOTAL_TIME_RUNNING | 74 PERF_FORMAT_TOTAL_TIME_RUNNING |
@@ -111,7 +111,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
111 if (opts->period) 111 if (opts->period)
112 attr->sample_type |= PERF_SAMPLE_PERIOD; 112 attr->sample_type |= PERF_SAMPLE_PERIOD;
113 113
114 if (opts->sample_id_all_avail && 114 if (!opts->sample_id_all_missing &&
115 (opts->sample_time || opts->system_wide || 115 (opts->sample_time || opts->system_wide ||
116 !opts->no_inherit || opts->cpu_list)) 116 !opts->no_inherit || opts->cpu_list))
117 attr->sample_type |= PERF_SAMPLE_TIME; 117 attr->sample_type |= PERF_SAMPLE_TIME;
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index 7dea8912aa97..ce61cb2d1acf 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -34,7 +34,7 @@ struct perf_top {
34 bool vmlinux_warned; 34 bool vmlinux_warned;
35 bool inherit; 35 bool inherit;
36 bool group; 36 bool group;
37 bool sample_id_all_avail; 37 bool sample_id_all_missing;
38 bool exclude_guest_missing; 38 bool exclude_guest_missing;
39 bool dump_symtab; 39 bool dump_symtab;
40 const char *cpu_list; 40 const char *cpu_list;