perf evsel: Add has_callchain() helper to make code more compact/clear
Its common to have the (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN), so add an evsel__has_callchain(evsel) helper. This will actually get more uses as we check that instead of symbol_conf.use_callchain in places where that produces the same result but makes this decision to be more fine grained, per evsel. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-145340oytbthatpfeaq1do18@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -2197,7 +2197,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
|
||||
}
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_CALLCHAIN) {
|
||||
if (evsel__has_callchain(evsel)) {
|
||||
const u64 max_callchain_nr = UINT64_MAX / sizeof(u64);
|
||||
|
||||
OVERFLOW_CHECK_u64(array);
|
||||
@@ -2857,7 +2857,7 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
|
||||
"Hint: Try again after reducing the number of events.\n"
|
||||
"Hint: Try increasing the limit with 'ulimit -n <limit>'");
|
||||
case ENOMEM:
|
||||
if ((evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) != 0 &&
|
||||
if (evsel__has_callchain(evsel) &&
|
||||
access("/proc/sys/kernel/perf_event_max_stack", F_OK) == 0)
|
||||
return scnprintf(msg, size,
|
||||
"Not enough memory to setup event with callchain.\n"
|
||||
|
||||
@@ -459,6 +459,11 @@ static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evs
|
||||
return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
|
||||
}
|
||||
|
||||
static inline bool evsel__has_callchain(const struct perf_evsel *evsel)
|
||||
{
|
||||
return (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) != 0;
|
||||
}
|
||||
|
||||
typedef int (*attr__fprintf_f)(FILE *, const char *, const char *, void *);
|
||||
|
||||
int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
|
||||
|
||||
@@ -1757,7 +1757,7 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro
|
||||
bool use_callchain;
|
||||
|
||||
if (evsel && symbol_conf.use_callchain && !symbol_conf.show_ref_callgraph)
|
||||
use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
|
||||
use_callchain = evsel__has_callchain(evsel);
|
||||
else
|
||||
use_callchain = symbol_conf.use_callchain;
|
||||
|
||||
|
||||
@@ -1094,7 +1094,7 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
|
||||
|
||||
sample_type = evsel->attr.sample_type;
|
||||
|
||||
if (sample_type & PERF_SAMPLE_CALLCHAIN)
|
||||
if (evsel__has_callchain(evsel))
|
||||
callchain__printf(evsel, sample);
|
||||
|
||||
if ((sample_type & PERF_SAMPLE_BRANCH_STACK) && !perf_evsel__has_branch_callstack(evsel))
|
||||
|
||||
Reference in New Issue
Block a user