perf evsel: Update sample_size when setting sample_type bits
We use evsel->sample_size to detect underflows in perf_evsel__parse_sample, but we were failing to update it after perf_evsel__init(), i.e. when we decide, after creating an evsel, that we want some extra field bit set. Fix it by introducing methods to set a bit that will take care of correctly adjusting evsel->sample_size. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> 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-2ny5pzsing0dcth7hws48x9c@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -901,24 +901,25 @@ static void perf_top__start_counters(struct perf_top *top)
|
||||
list_for_each_entry(counter, &evlist->entries, node) {
|
||||
struct perf_event_attr *attr = &counter->attr;
|
||||
|
||||
attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
|
||||
perf_evsel__set_sample_bit(counter, IP);
|
||||
perf_evsel__set_sample_bit(counter, TID);
|
||||
|
||||
if (top->freq) {
|
||||
attr->sample_type |= PERF_SAMPLE_PERIOD;
|
||||
perf_evsel__set_sample_bit(counter, PERIOD);
|
||||
attr->freq = 1;
|
||||
attr->sample_freq = top->freq;
|
||||
}
|
||||
|
||||
if (evlist->nr_entries > 1) {
|
||||
attr->sample_type |= PERF_SAMPLE_ID;
|
||||
perf_evsel__set_sample_bit(counter, ID);
|
||||
attr->read_format |= PERF_FORMAT_ID;
|
||||
}
|
||||
|
||||
if (perf_target__has_cpu(&top->target))
|
||||
attr->sample_type |= PERF_SAMPLE_CPU;
|
||||
perf_evsel__set_sample_bit(counter, CPU);
|
||||
|
||||
if (symbol_conf.use_callchain)
|
||||
attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
|
||||
perf_evsel__set_sample_bit(counter, CALLCHAIN);
|
||||
|
||||
attr->mmap = 1;
|
||||
attr->comm = 1;
|
||||
|
Reference in New Issue
Block a user