Skip to content

Commit fa79aa6

Browse files
Jin Yaoacmel
authored andcommitted
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>
1 parent 47ef839 commit fa79aa6

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

tools/perf/util/stream.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,43 @@ struct evsel_streams *evsel_streams__entry(struct evlist_streams *els,
175175

176176
return NULL;
177177
}
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+
}

tools/perf/util/stream.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
struct stream {
88
struct callchain_node *cnode;
9+
struct callchain_node *pair_cnode;
910
};
1011

1112
struct evsel_streams {
@@ -30,4 +31,7 @@ struct evlist_streams *evlist__create_streams(struct evlist *evlist,
3031
struct evsel_streams *evsel_streams__entry(struct evlist_streams *els,
3132
int evsel_idx);
3233

34+
void evsel_streams__match(struct evsel_streams *es_base,
35+
struct evsel_streams *es_pair);
36+
3337
#endif /* __PERF_STREAM_H */

0 commit comments

Comments
 (0)