From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD4E9C433EF for ; Wed, 30 Mar 2022 20:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xyQuCSAycq/T65G2FOG6uy1KoZUi6tRMmUOBylhiA3E=; b=YlbcPCxHFVEaRX wxIETT+jN8BAT/4LXMbv0C8RVuRPnOsqIL/ST9NXFd19N088BqnwYKOLOFmX4UwPfcM2Qnb8+0zDC PSZXXvgoI+oe9nH8R+LjVqiyYAHayQW4U0K0UicrawKfUg2J+VaFOln2i7BDpNGTlQdLr/sHHz91f PGhHAztW99fpJBo1ZTNlKsf7XKgfybJm8BRspFHzIHfFeJWeYD4o0HXQb1WAahfGVppn0sp0pERnE 8bG0zpA9RDLD6JZOUvG8nim68UvDWYqnFA0E0c8tZegTAUCd7NSZN62qnJCKApPvhL87NZX49vTrZ Sf4ly1a+f9Htw6lGvn4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZf1k-00HS3K-Ey; Wed, 30 Mar 2022 20:34:48 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZf1i-00HS2e-9L for linux-arm-kernel@bombadil.infradead.org; Wed, 30 Mar 2022 20:34:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=G93w45uk5tXRO71YVeBleAMa7+umXWwkfdNvqDY9K8c=; b=Sce1msqZ2QVNUJHui1wAkzLXuY aFalBbdkONfNOtF4NUsCWdEVGmNfTDx7oTfDW4z0/CVlIjr/+L7wl0oxlVIxsH4OE2Dx5lt9gZyak 3iqEBdy/QP0r/T53yVSyuIw9++TkL/1XQA2wwWhl2/NNR5GLiRkjyJb1k0mL/08MbjnMKrkTzB/4u e3ctqD0ZURi8cgGGwh5BN5VXrpnKJ/J6SauP3QKSnpPxIeJGgc/jUcAc/lm6gCOmAlO3aZoyMZFbe Owhk7OCUOj56Wl5d2ixmdXK/EvRKdjaO4gUrZ2AuHP7bG5B8dORP/pJ0QwFfcmc7raOvzllI/iziW JWRY/gFA==; Received: from [187.19.239.165] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZf1g-006IS6-L5; Wed, 30 Mar 2022 20:34:45 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2EE5440407; Wed, 30 Mar 2022 17:34:42 -0300 (-03) Date: Wed, 30 Mar 2022 17:34:42 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH v2 4/6] perf cpumap: More cpu map reuse by merge. Message-ID: References: <20220328232648.2127340-1-irogers@google.com> <20220328232648.2127340-5-irogers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220328232648.2127340-5-irogers@google.com> X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Mon, Mar 28, 2022 at 04:26:46PM -0700, Ian Rogers escreveu: > perf_cpu_map__merge will reuse one of its arguments if they are equal or > the other argument is NULL. The arguments could be reused if it is known > one set of values is a subset of the other. For example, a map of 0-1 > and a map of just 0 when merged yields the map of 0-1. Currently a new > map is created rather than adding a reference count to the original 0-1 > map. Thanks, applied. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/lib/perf/cpumap.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c > index 23701024e0c0..384d5e076ee4 100644 > --- a/tools/lib/perf/cpumap.c > +++ b/tools/lib/perf/cpumap.c > @@ -355,17 +355,12 @@ struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, > int i, j, k; > struct perf_cpu_map *merged; > > - if (!orig && !other) > - return NULL; > - if (!orig) { > - perf_cpu_map__get(other); > - return other; > - } > - if (!other) > - return orig; > - if (orig->nr == other->nr && > - !memcmp(orig->map, other->map, orig->nr * sizeof(struct perf_cpu))) > + if (perf_cpu_map__is_subset(orig, other)) > return orig; > + if (perf_cpu_map__is_subset(other, orig)) { > + perf_cpu_map__put(orig); > + return perf_cpu_map__get(other); > + } > > tmp_len = orig->nr + other->nr; > tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu)); > -- > 2.35.1.1021.g381101b075-goog -- - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel