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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4EC9C433EF for ; Mon, 2 May 2022 17:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386540AbiEBRIq (ORCPT ); Mon, 2 May 2022 13:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358432AbiEBRIl (ORCPT ); Mon, 2 May 2022 13:08:41 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF49128 for ; Mon, 2 May 2022 10:05:11 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id e24so20306422wrc.9 for ; Mon, 02 May 2022 10:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ILRP524+2fdLDTShu4hSsO+6dehNvYTua716YzeA9Fg=; b=YDWfLX1xSIUwsEMnssgIoCHQO8OLl2q81ADfKyheoORpJWFFKfJBcZNs8cOj83RvXy 31erF0OeLY0X5e2EhHdMzi09UQNQgxuAiAaP1aKGjsflBTGPEjKXLnNcdjdpQ328cwxd i+6YiDC7OMst6lOmjI8msSGBFxio8+XY4fEu8oHviRF9yG3QufHYzpoMtYWWUt6ieB4m KodYbVNfW83VJ00k/LeDcrDRb+kuEDRXc/+3am4mBrBGa1uZwbG8e5/gWuytzgFgeyYR y8JFiIwQe5GmA8Q7np9BTS9tZiTlgFfEBA3BYB4W+tcqvvfd84jUfhGepDb3Cz6DItSA z4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ILRP524+2fdLDTShu4hSsO+6dehNvYTua716YzeA9Fg=; b=66A9vCu8OzohYEnsKUrmAdmINgFgLa8V7q+SXXBSg6yhn0shdMHEwTE3tY7qUc2+oD F5xcYRq7+VcUv7T6INJL627sdt6+VIo3JFZCah+TLQO3Wd+Lsd3iMBvfQGE6mZn9VXN5 27Os/znQKvT6WN91Wt7dZXmBzxTyjW/zqpxIQZYyVK/cbWlajD4/HEErbdIMGDf/tyvu gE7N7P2fmX68xaNQZCf50HL+IZgJVJ1/0TTzmMIwI4bGxKysp6MnC+6MK6jhwpXNTafB WgZMqYs2S9AzcibZRhn2ek6xmR5RGaornhHGVMbG9ImFJoTN41knAFSMx+alJ18dpQjI VfRA== X-Gm-Message-State: AOAM5322PN6/kUpSsPi6aYYYy6qGNEOEaztOmy5xWpt9Rm1tpqYoICcf z/dETm4pbGAr/ySkiB6d11vNS5wdFLY4gVIOisThzw== X-Google-Smtp-Source: ABdhPJwapNE9nWFgzhKYpaQKNHhqIs/ouKZtT/FIYeoMKh13aLfp0xSWPQA3PWYkrL+UK68ul/j7zF71aSSPTfuVTlY= X-Received: by 2002:adf:f30a:0:b0:20a:e193:6836 with SMTP id i10-20020adff30a000000b0020ae1936836mr10089318wro.654.1651511109668; Mon, 02 May 2022 10:05:09 -0700 (PDT) MIME-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> <20220430062324.1565215-5-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Mon, 2 May 2022 10:04:57 -0700 Message-ID: Subject: Re: [PATCH v4 4/6] perf cpumap: Handle dummy maps as empty in subset To: Adrian Hunter Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , 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 , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 2, 2022 at 9:13 AM Adrian Hunter wrote: > > On 30/04/22 09:23, Ian Rogers wrote: > > perf_cpu_map__empty is true for empty and dummy maps. Make is_subset > > respect that. > > I think this might be the opposite of what I am trying to do, which is > enable all_cpus to represent all the "cpu" values (3rd parameter of > perf_event_open()) to iterate over including -1 so that per-thread and > per-cpu events can be mixed. Wouldn't you iterate over the cpus of the evsel? I'm not sure using all_cpus in that way makes sense, it also violates the definition of empty. Thanks, Ian > > > > Signed-off-by: Ian Rogers > > --- > > tools/lib/perf/cpumap.c | 4 ++-- > > tools/perf/tests/cpumap.c | 10 +++++++++- > > 2 files changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c > > index 384d5e076ee4..9c83675788c2 100644 > > --- a/tools/lib/perf/cpumap.c > > +++ b/tools/lib/perf/cpumap.c > > @@ -322,9 +322,9 @@ struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map) > > /** 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) > > + if (a == b || perf_cpu_map__empty(b)) > > return true; > > - if (!a || b->nr > a->nr) > > + if (perf_cpu_map__empty(a) || b->nr > a->nr) > > return false; > > > > for (int i = 0, j = 0; i < a->nr; i++) { > > diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c > > index f94929ebb54b..d52b58395385 100644 > > --- a/tools/perf/tests/cpumap.c > > +++ b/tools/perf/tests/cpumap.c > > @@ -128,13 +128,21 @@ static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subte > > struct perf_cpu_map *a = perf_cpu_map__new("4,2,1"); > > struct perf_cpu_map *b = perf_cpu_map__new("4,5,7"); > > struct perf_cpu_map *c = perf_cpu_map__merge(a, b); > > + struct perf_cpu_map *d = perf_cpu_map__dummy_new(); > > + struct perf_cpu_map *e = perf_cpu_map__merge(b, d); > > char buf[100]; > > > > TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(c) == 5); > > cpu_map__snprint(c, buf, sizeof(buf)); > > TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); > > - perf_cpu_map__put(b); > > + > > + TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(e) == 3); > > + cpu_map__snprint(e, buf, sizeof(buf)); > > + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "4-5,7")); > > + > > perf_cpu_map__put(c); > > + perf_cpu_map__put(d); > > + perf_cpu_map__put(e); > > return 0; > > } > > >