diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-07 13:42:27 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-07 13:42:27 -0400 |
commit | c9d366287042489090da0391318df528bdce9941 (patch) | |
tree | 72435b9d9fbeac8db97b8e007cf5d08c9035b3c3 /tools/perf | |
parent | 29f9fcdd3f8edccad5809cf939ce921752460fe7 (diff) |
perf hists: Reimplement hists__has_callchains()
There are places where we have only access to struct hists and need to
know if any of its hist_entries has callchains, like when drawing
headers for the various output modes (stdio, TUI, etc), so, when adding
a new hist_entry, check if it has callchains, storing this info for
later use by hists__has_callchains().
This reimplementation is necessary because not always a 'struct hists'
is allocated together with a 'struct perf evsel', so we can't go from
'hists' to 'perf_event_attr.sample_type & PERF_SAMPLE_CALLCHAIN'.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.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-hg5g7yddjio3ljwyqnnaj5dt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/hist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 0441a92b855f..828cb9794c76 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -621,9 +621,11 @@ __hists__add_entry(struct hists *hists, | |||
621 | .raw_data = sample->raw_data, | 621 | .raw_data = sample->raw_data, |
622 | .raw_size = sample->raw_size, | 622 | .raw_size = sample->raw_size, |
623 | .ops = ops, | 623 | .ops = ops, |
624 | }; | 624 | }, *he = hists__findnew_entry(hists, &entry, al, sample_self); |
625 | 625 | ||
626 | return hists__findnew_entry(hists, &entry, al, sample_self); | 626 | if (!hists->has_callchains && he && he->callchain_size != 0) |
627 | hists->has_callchains = true; | ||
628 | return he; | ||
627 | } | 629 | } |
628 | 630 | ||
629 | struct hist_entry *hists__add_entry(struct hists *hists, | 631 | struct hist_entry *hists__add_entry(struct hists *hists, |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 06607c434949..73049f7f0f60 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -85,6 +85,7 @@ struct hists { | |||
85 | struct events_stats stats; | 85 | struct events_stats stats; |
86 | u64 event_stream; | 86 | u64 event_stream; |
87 | u16 col_len[HISTC_NR_COLS]; | 87 | u16 col_len[HISTC_NR_COLS]; |
88 | bool has_callchains; | ||
88 | int socket_filter; | 89 | int socket_filter; |
89 | struct perf_hpp_list *hpp_list; | 90 | struct perf_hpp_list *hpp_list; |
90 | struct list_head hpp_formats; | 91 | struct list_head hpp_formats; |
@@ -222,8 +223,7 @@ static inline struct hists *evsel__hists(struct perf_evsel *evsel) | |||
222 | 223 | ||
223 | static __pure inline bool hists__has_callchains(struct hists *hists) | 224 | static __pure inline bool hists__has_callchains(struct hists *hists) |
224 | { | 225 | { |
225 | const struct perf_evsel *evsel = hists_to_evsel(hists); | 226 | return hists->has_callchains; |
226 | return evsel__has_callchain(evsel); | ||
227 | } | 227 | } |
228 | 228 | ||
229 | int hists__init(void); | 229 | int hists__init(void); |