Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf streams: Link stream pair

In previous patch, we have created an evsel_streams for one event, and
top N hottest streams will be saved in a stream array in evsel_streams.

This patch compares total streams among two evsel_streams.

Once two streams are fully matched, they will be linked as a pair. From
the pair, we can know which streams are matched.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20201009022845.13141-5-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jin Yao and committed by
Arnaldo Carvalho de Melo
fa79aa64 47ef8398

+44
+40
tools/perf/util/stream.c
··· 175 175 176 176 return NULL; 177 177 } 178 + 179 + static struct stream *stream__callchain_match(struct stream *base_stream, 180 + struct evsel_streams *es_pair) 181 + { 182 + for (int i = 0; i < es_pair->nr_streams; i++) { 183 + struct stream *pair_stream = &es_pair->streams[i]; 184 + 185 + if (callchain_cnode_matched(base_stream->cnode, 186 + pair_stream->cnode)) { 187 + return pair_stream; 188 + } 189 + } 190 + 191 + return NULL; 192 + } 193 + 194 + static struct stream *stream__match(struct stream *base_stream, 195 + struct evsel_streams *es_pair) 196 + { 197 + return stream__callchain_match(base_stream, es_pair); 198 + } 199 + 200 + static void stream__link(struct stream *base_stream, struct stream *pair_stream) 201 + { 202 + base_stream->pair_cnode = pair_stream->cnode; 203 + pair_stream->pair_cnode = base_stream->cnode; 204 + } 205 + 206 + void evsel_streams__match(struct evsel_streams *es_base, 207 + struct evsel_streams *es_pair) 208 + { 209 + for (int i = 0; i < es_base->nr_streams; i++) { 210 + struct stream *base_stream = &es_base->streams[i]; 211 + struct stream *pair_stream; 212 + 213 + pair_stream = stream__match(base_stream, es_pair); 214 + if (pair_stream) 215 + stream__link(base_stream, pair_stream); 216 + } 217 + }
+4
tools/perf/util/stream.h
··· 6 6 7 7 struct stream { 8 8 struct callchain_node *cnode; 9 + struct callchain_node *pair_cnode; 9 10 }; 10 11 11 12 struct evsel_streams { ··· 30 29 31 30 struct evsel_streams *evsel_streams__entry(struct evlist_streams *els, 32 31 int evsel_idx); 32 + 33 + void evsel_streams__match(struct evsel_streams *es_base, 34 + struct evsel_streams *es_pair); 33 35 34 36 #endif /* __PERF_STREAM_H */