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.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 0c978128
...@@ -209,7 +209,7 @@ static void perf_record__open(struct perf_record *rec) ...@@ -209,7 +209,7 @@ static void perf_record__open(struct perf_record *rec)
if (opts->exclude_guest_missing) if (opts->exclude_guest_missing)
attr->exclude_guest = attr->exclude_host = 0; attr->exclude_guest = attr->exclude_host = 0;
retry_sample_id: retry_sample_id:
attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
try_again: try_again:
if (perf_evsel__open(pos, evlist->cpus, evlist->threads, if (perf_evsel__open(pos, evlist->cpus, evlist->threads,
opts->group, group_fd) < 0) { opts->group, group_fd) < 0) {
...@@ -228,11 +228,11 @@ static void perf_record__open(struct perf_record *rec) ...@@ -228,11 +228,11 @@ static void perf_record__open(struct perf_record *rec)
"guest or host samples.\n"); "guest or host samples.\n");
opts->exclude_guest_missing = true; opts->exclude_guest_missing = true;
goto fallback_missing_features; goto fallback_missing_features;
} else if (opts->sample_id_all_avail) { } else if (!opts->sample_id_all_missing) {
/* /*
* Old kernel, no attr->sample_id_type_all field * Old kernel, no attr->sample_id_type_all field
*/ */
opts->sample_id_all_avail = false; opts->sample_id_all_missing = true;
if (!opts->sample_time && !opts->raw_samples && !time_needed) if (!opts->sample_time && !opts->raw_samples && !time_needed)
attr->sample_type &= ~PERF_SAMPLE_TIME; attr->sample_type &= ~PERF_SAMPLE_TIME;
...@@ -660,7 +660,6 @@ static struct perf_record record = { ...@@ -660,7 +660,6 @@ static struct perf_record record = {
.user_freq = UINT_MAX, .user_freq = UINT_MAX,
.user_interval = ULLONG_MAX, .user_interval = ULLONG_MAX,
.freq = 1000, .freq = 1000,
.sample_id_all_avail = true,
}, },
.write_mode = WRITE_FORCE, .write_mode = WRITE_FORCE,
.file_new = true, .file_new = true,
......
...@@ -1013,7 +1013,6 @@ static int test__PERF_RECORD(void) ...@@ -1013,7 +1013,6 @@ static int test__PERF_RECORD(void)
.no_delay = true, .no_delay = true,
.freq = 10, .freq = 10,
.mmap_pages = 256, .mmap_pages = 256,
.sample_id_all_avail = true,
}; };
cpu_set_t *cpu_mask = NULL; cpu_set_t *cpu_mask = NULL;
size_t cpu_mask_size = 0; size_t cpu_mask_size = 0;
......
...@@ -876,7 +876,7 @@ static void perf_top__start_counters(struct perf_top *top) ...@@ -876,7 +876,7 @@ static void perf_top__start_counters(struct perf_top *top)
if (top->exclude_guest_missing) if (top->exclude_guest_missing)
attr->exclude_guest = attr->exclude_host = 0; attr->exclude_guest = attr->exclude_host = 0;
retry_sample_id: retry_sample_id:
attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; attr->sample_id_all = top->sample_id_all_missing ? 0 : 1;
try_again: try_again:
if (perf_evsel__open(counter, top->evlist->cpus, if (perf_evsel__open(counter, top->evlist->cpus,
top->evlist->threads, top->group, top->evlist->threads, top->group,
...@@ -893,11 +893,11 @@ static void perf_top__start_counters(struct perf_top *top) ...@@ -893,11 +893,11 @@ static void perf_top__start_counters(struct perf_top *top)
"guest or host samples.\n"); "guest or host samples.\n");
top->exclude_guest_missing = true; top->exclude_guest_missing = true;
goto fallback_missing_features; goto fallback_missing_features;
} else if (top->sample_id_all_avail) { } else if (!top->sample_id_all_missing) {
/* /*
* Old kernel, no attr->sample_id_type_all field * Old kernel, no attr->sample_id_type_all field
*/ */
top->sample_id_all_avail = false; top->sample_id_all_missing = true;
goto retry_sample_id; goto retry_sample_id;
} }
} }
...@@ -1122,7 +1122,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1122,7 +1122,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
.delay_secs = 2, .delay_secs = 2,
.uid = UINT_MAX, .uid = UINT_MAX,
.freq = 1000, /* 1 KHz */ .freq = 1000, /* 1 KHz */
.sample_id_all_avail = true,
.mmap_pages = 128, .mmap_pages = 128,
.sym_pcnt_filter = 5, .sym_pcnt_filter = 5,
}; };
......
...@@ -198,7 +198,7 @@ struct perf_record_opts { ...@@ -198,7 +198,7 @@ struct perf_record_opts {
bool raw_samples; bool raw_samples;
bool sample_address; bool sample_address;
bool sample_time; bool sample_time;
bool sample_id_all_avail; bool sample_id_all_missing;
bool exclude_guest_missing; bool exclude_guest_missing;
bool system_wide; bool system_wide;
bool period; bool period;
......
...@@ -68,7 +68,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts) ...@@ -68,7 +68,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
struct perf_event_attr *attr = &evsel->attr; struct perf_event_attr *attr = &evsel->attr;
int track = !evsel->idx; /* only the first counter needs these */ int track = !evsel->idx; /* only the first counter needs these */
attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
attr->inherit = !opts->no_inherit; attr->inherit = !opts->no_inherit;
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
PERF_FORMAT_TOTAL_TIME_RUNNING | PERF_FORMAT_TOTAL_TIME_RUNNING |
...@@ -111,7 +111,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts) ...@@ -111,7 +111,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
if (opts->period) if (opts->period)
attr->sample_type |= PERF_SAMPLE_PERIOD; attr->sample_type |= PERF_SAMPLE_PERIOD;
if (opts->sample_id_all_avail && if (!opts->sample_id_all_missing &&
(opts->sample_time || opts->system_wide || (opts->sample_time || opts->system_wide ||
!opts->no_inherit || opts->cpu_list)) !opts->no_inherit || opts->cpu_list))
attr->sample_type |= PERF_SAMPLE_TIME; attr->sample_type |= PERF_SAMPLE_TIME;
......
...@@ -34,7 +34,7 @@ struct perf_top { ...@@ -34,7 +34,7 @@ struct perf_top {
bool vmlinux_warned; bool vmlinux_warned;
bool inherit; bool inherit;
bool group; bool group;
bool sample_id_all_avail; bool sample_id_all_missing;
bool exclude_guest_missing; bool exclude_guest_missing;
bool dump_symtab; bool dump_symtab;
const char *cpu_list; const char *cpu_list;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册