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 0A7ACC433EF for ; Wed, 30 Mar 2022 20:35:25 +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=eCry4lKTCusygGuWlNHjR740j6nvjLq5Y7fLMyWI0KM=; b=HpPTi1R9mXktr4 hZZ+G/30pcwxkxIP/rbc4y8UVtR5muesH2ydWY9j26Brzvp1MU5wqGyW8FRuvmIL/ywLspM+/lDXF zuezd6oQhBUmxiJoQvLtZDikFpUgwCdeh4cMP7uzwfmq0M6lCCWt+okx4mcY2P3UeBcTsBN5NK7kd 1VZyJitTEoU1GuU5Rp+4JoKpAd8t74PVe/a/Yxf5HzGM7nacgIH126hdCmbswyUn4kxa7H708ZbQW u7eFEqBD01tIy0pi/xk2hqElRi8Rw+W7sqhs0Zf9dzFDziS1E4+L359CpwH94ZN/u3yw/jWk6AF1M CxJz/j1DaTe4LapooF+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZf16-00HRw6-Ve; Wed, 30 Mar 2022 20:34:09 +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 1nZf14-00HRvl-Ir for linux-arm-kernel@bombadil.infradead.org; Wed, 30 Mar 2022 20:34:06 +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=xVWhmiyCX6th2PYciVnT73nSULoQsmEIC1TkI3VZ7wg=; b=RB1D7okmQislhg5JWEb+f4g05W veoD8Uued60Gjl6iPNWHhPyUdXs0qA0qXUtCIt8X1Wkpvf1AxRFUaraFDG81WPCNOfK/tKf5gtm4L XNCWbkSLj0jvuqSUzqJMrjrOu+45a1W1UoD9Ve7GfcsWJzcF82YUBzP1cGXwucu0nRftPAgtxADuu ZKyco7dLsiB+QMuU9qkT2gdb11bfDJv6lr9RzjQzbeR/aqG4sgD8mSpyYBnFRq5Hkk10DdDD8wkxh pKQ4dcl4NwO+oviCdoEuTZLkrrC3rr/r09SrHNxBw1rqduA9yGtTrhHcMVutCPz2qXeKHZZZTfzP7 LoYUXYtw==; 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 1nZf12-006IRb-Tv; Wed, 30 Mar 2022 20:34:05 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 7FF5440407; Wed, 30 Mar 2022 17:34:02 -0300 (-03) Date: Wed, 30 Mar 2022 17:34:02 -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 3/6] perf cpumap: Add is_subset function Message-ID: References: <20220328232648.2127340-1-irogers@google.com> <20220328232648.2127340-4-irogers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220328232648.2127340-4-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:45PM -0700, Ian Rogers escreveu: > Returns true if the second argument is a subset of the first. Thanks, applied. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/lib/perf/cpumap.c | 20 ++++++++++++++++++++ > tools/lib/perf/include/internal/cpumap.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c > index ee66760f1e63..23701024e0c0 100644 > --- a/tools/lib/perf/cpumap.c > +++ b/tools/lib/perf/cpumap.c > @@ -319,6 +319,26 @@ struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map) > return map->nr > 0 ? map->map[map->nr - 1] : result; > } > > +/** Is 'b' a subset of 'a'. */ > +bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b) > +{ > + if (a == b || !b) > + return true; > + if (!a || b->nr > a->nr) > + return false; > + > + for (int i = 0, j = 0; i < a->nr; i++) { > + if (a->map[i].cpu > b->map[j].cpu) > + return false; > + if (a->map[i].cpu == b->map[j].cpu) { > + j++; > + if (j == b->nr) > + return true; > + } > + } > + return false; > +} > + > /* > * Merge two cpumaps > * > diff --git a/tools/lib/perf/include/internal/cpumap.h b/tools/lib/perf/include/internal/cpumap.h > index 1973a18c096b..35dd29642296 100644 > --- a/tools/lib/perf/include/internal/cpumap.h > +++ b/tools/lib/perf/include/internal/cpumap.h > @@ -25,5 +25,6 @@ struct perf_cpu_map { > #endif > > int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu); > +bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b); > > #endif /* __LIBPERF_INTERNAL_CPUMAP_H */ > -- > 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