Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1786542pxu; Thu, 8 Oct 2020 22:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1R/MiUfpWHR7HXdLpKKvq5CoBoUDAq9bn7KEZmeg/dvhjdrV8Ne+wrdrkJ4lOOZbQJMDu X-Received: by 2002:a17:907:2076:: with SMTP id qp22mr12353156ejb.358.1602222020694; Thu, 08 Oct 2020 22:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602222020; cv=none; d=google.com; s=arc-20160816; b=Qks9b2PVPfEUlt1A0UhQxxqzghG1rO87cWj9kzAr0+neOqNwF7EHWwIrlFmY3nvJJC hZmu3eAO0UP1gqj9R9pzsZhQ6JzvNyGUD++sQ9cZZmuSrH8LaEeiJqnbDaFgYmBqYizq LsQ1kaQtQ24KALq0zZhELrHR31awCN2NOGbrQket9aaprpiTE/MuLsmcOIiReW0PUyi5 CgdYlaVhQgOag3lX3wqoHixj0wUfVdJ94bXH8y+2EE+94kFMT5YzKvmU0xK5q9ORuHWl 5ervjEh1SFc0ZoU/lKT0w9XF0Wp84Y1YcJO14TOBx6BAFsauLRGM/0+I212gdv4WGoR8 IpSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=UiEBEj4kd1XvOvvFsmJHSeRKU79g7kuXRRiCEzzGMok=; b=W+4AkY8hTMOJX6oD8PqSe652yjCwUhPpB7QK/+/R3zjl1kRmy9ytPHntW4RfOqXWg2 kX9bq7WPAMPOfRFrA9Xig5cFtHNGTnCAVnQCvXenD7lGRgPpucVQADZ0x2ilBBxoE6UU Bw2MTkNze8jxJKOKJ1x/50Eyi4KzRxkz6YXugo4nRJ7VuDqzl6c9DZ28Az7MlZhp0XKm VPCrLe4mIjWVYKccyEsOwJL4qYQ8JkJWyHzQG69dU7VeDQv8vIEeHkBJYJx1UyQgcpSl Ne9x2rg5BcZ2PGFfe4+S4LQ+sa5eBXDfgDPKcS7r667NUGkQFxbnQhVZExbC+hpPE2Yr 6Obw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qu4si5468536ejb.611.2020.10.08.22.39.56; Thu, 08 Oct 2020 22:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731287AbgJIC3i (ORCPT + 99 others); Thu, 8 Oct 2020 22:29:38 -0400 Received: from mga01.intel.com ([192.55.52.88]:51340 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731276AbgJIC3f (ORCPT ); Thu, 8 Oct 2020 22:29:35 -0400 IronPort-SDR: TQgv4py0WsmkubYBBg1Ny51Fe1tX0LlMXiRxM4Kd+uhW+BR+q6DnYF9O7U63qD28ggBVCHmOYM Mtn0HTV7K+bA== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="182869960" X-IronPort-AV: E=Sophos;i="5.77,353,1596524400"; d="scan'208";a="182869960" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2020 19:29:35 -0700 IronPort-SDR: sLyCYsiztCDBoPDDTxrrraYHIbNDn9qKDrfpvvTmGjyiocUXw8DmVHoec2H0idFfUvJQ3fb4bI dNwFZOMyhCuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,353,1596524400"; d="scan'208";a="354700000" Received: from kbl-ppc.sh.intel.com ([10.239.159.55]) by FMSMGA003.fm.intel.com with ESMTP; 08 Oct 2020 19:29:33 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v8 4/7] perf util: Link stream pair Date: Fri, 9 Oct 2020 10:28:42 +0800 Message-Id: <20201009022845.13141-5-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201009022845.13141-1-yao.jin@linux.intel.com> References: <20201009022845.13141-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v8: - No change v7: - Rename functions with 'stream__' prefix. v6: - Rebase to perf/core v5: - Remove enum stream_type v4: - New patch in v4. tools/perf/util/stream.c | 40 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/stream.h | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/tools/perf/util/stream.c b/tools/perf/util/stream.c index e1c7d6c6126b..0d6a7452320a 100644 --- a/tools/perf/util/stream.c +++ b/tools/perf/util/stream.c @@ -175,3 +175,43 @@ struct evsel_streams *evsel_streams__entry(struct evlist_streams *els, return NULL; } + +static struct stream *stream__callchain_match(struct stream *base_stream, + struct evsel_streams *es_pair) +{ + for (int i = 0; i < es_pair->nr_streams; i++) { + struct stream *pair_stream = &es_pair->streams[i]; + + if (callchain_cnode_matched(base_stream->cnode, + pair_stream->cnode)) { + return pair_stream; + } + } + + return NULL; +} + +static struct stream *stream__match(struct stream *base_stream, + struct evsel_streams *es_pair) +{ + return stream__callchain_match(base_stream, es_pair); +} + +static void stream__link(struct stream *base_stream, struct stream *pair_stream) +{ + base_stream->pair_cnode = pair_stream->cnode; + pair_stream->pair_cnode = base_stream->cnode; +} + +void evsel_streams__match(struct evsel_streams *es_base, + struct evsel_streams *es_pair) +{ + for (int i = 0; i < es_base->nr_streams; i++) { + struct stream *base_stream = &es_base->streams[i]; + struct stream *pair_stream; + + pair_stream = stream__match(base_stream, es_pair); + if (pair_stream) + stream__link(base_stream, pair_stream); + } +} diff --git a/tools/perf/util/stream.h b/tools/perf/util/stream.h index f01335677479..cb131f41f5b1 100644 --- a/tools/perf/util/stream.h +++ b/tools/perf/util/stream.h @@ -6,6 +6,7 @@ struct stream { struct callchain_node *cnode; + struct callchain_node *pair_cnode; }; struct evsel_streams { @@ -30,4 +31,7 @@ struct evlist_streams *evlist__create_streams(struct evlist *evlist, struct evsel_streams *evsel_streams__entry(struct evlist_streams *els, int evsel_idx); +void evsel_streams__match(struct evsel_streams *es_base, + struct evsel_streams *es_pair); + #endif /* __PERF_STREAM_H */ -- 2.17.1