From patchwork Fri Apr 8 03:56:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806035 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 C1779C433F5 for ; Fri, 8 Apr 2022 03:58:20 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oHoPGxiTJM3uYlOJDScwvv8e1puZED9fEFXXDAvylSU=; b=fBKXBmldUFOFRWeWzytCitoAOx lAxysu1r/FcDJq7AkRFvdmIk4ajtER6UQ8PDTFJ3/1Xsaj7tF+IKY39WF5jzrkPxWK3tGLSaZR8GE /brybX0Mn53Sohq2LUjm2e0hDl0HYF8/zfpZs0l5sGbaxP5TrOPs+K4NHxEnk2iHbBlLl7ZubFm8M hdgRpPjnV0SD+sR6olc0G2Cvr7tfXyzhJhJkI3KPcODvotRm9JxUbt9bhxsPUm9NZrHRypLsP1/D9 BqqEQx/pnX4cBBq1kQcxERmn9bd4eY8oz7JWoY2gf2UC/lLncbXpafmPEJsmxAC7XBo56/qBfijs3 F5PVGlyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjj-00EpVh-Pi; Fri, 08 Apr 2022 03:56:39 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjX-00EpNI-4C for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:28 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id v7-20020a05690204c700b0063dc849f9f8so5739710ybs.18 for ; Thu, 07 Apr 2022 20:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+UkP3lUK7ObQkCyzmAzO/DKgbCUB8zFLRfkItQiish8=; b=BNzAVEsk+y8i0hvgdOFQ3JjFIanV1LS9VEuAZRKQGCjO0pQxkFs7HPpPGinn10Etid qbGu6TJpWjAY7tbIUlgPbg3YDegF4SulYZEbqhImfHCA0bSLbcxb9In1hHjf0qFjZCvP SgeQSstMpFwmFmWUpRXp5btO080Ea/O/UWkoShdBq+D0DcObzMq3R3+XSJG9JI0mPSWi QDz27KQ4K/OH+iABrm4y66+uPvJIn+c/q9mQiJUGWR3Zdmduu2Hac54igS6lH/ACe2+u E/7s11R33gc1MsZazSS7nFG5nDxsYxZMR2FUCps5bhbd4R+En2NY/xireFZ9DN82KY0w hPEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+UkP3lUK7ObQkCyzmAzO/DKgbCUB8zFLRfkItQiish8=; b=gQ6mmb+iW6JP5Dts080Wzn39cXqeufh6zwVp5YvwFryLVccalFQR08157g/8xcvc2x LWiiW0CZ3fj8nDCzTKj0BpsaYKEeFPKWBWxdpeul+i9TsrQK9sNBX+6uZ3bZ3+ELKoWD BH5a/wSl+BC4+6jKzpMmGxWk8nNDyzJg0FnpaoGKv5qu3QP11Shn5QkNcNSvH1o+TtT9 TyPguavufkWlLAMNUJi2lzHlj2CSoRAz5jrHGGi5C72I9hhCRA+mzAjB62/H/1mR7Rn/ ASWfPCbDzHEucnKTs0Pt65RvGTuB/7wtb5Ce/jHc3tsxrBt+VOsN/wyHJ7yyS5g5IRA9 xMwQ== X-Gm-Message-State: AOAM531zbndsEvKnfTG10m0JzrTrA12QV7snR4nNgi2JOSFpLKVPpLAg BwZAibuL+ZPYfw9kjRbplJhrtG4E7Ygt X-Google-Smtp-Source: ABdhPJzAGn8IgbwUAH+00Y1LBeQMqrkd4DN8Kp/utfITpsnis/mZA85HK2v7x30g/16DPHKVX+kOi1HjQZn4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a25:af41:0:b0:633:905f:9e9b with SMTP id c1-20020a25af41000000b00633905f9e9bmr12894988ybj.77.1649390184327; Thu, 07 Apr 2022 20:56:24 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:12 -0700 In-Reply-To: <20220408035616.1356953-1-irogers@google.com> Message-Id: <20220408035616.1356953-2-irogers@google.com> Mime-Version: 1.0 References: <20220408035616.1356953-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 1/5] perf cpumap: Don't decrement refcnt on args to merge From: Ian Rogers To: 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 , 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 Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_205627_211163_9A69F220 X-CRM114-Status: GOOD ( 16.28 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Having one argument to the cpumap merge decremented but not the other leads to an inconsistent API. Don't decrement either argument. Signed-off-by: Ian Rogers --- tools/lib/perf/cpumap.c | 11 +++-------- tools/lib/perf/evlist.c | 6 +++++- tools/perf/tests/cpumap.c | 1 + 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index 384d5e076ee4..95c56e17241b 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -342,9 +342,7 @@ bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu /* * Merge two cpumaps * - * orig either gets freed and replaced with a new map, or reused - * with no reference count change (similar to "realloc") - * other has its reference count increased. + * May reuse either orig or other bumping reference count accordingly. */ struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, @@ -356,11 +354,9 @@ struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, struct perf_cpu_map *merged; 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(orig); + if (perf_cpu_map__is_subset(other, orig)) return perf_cpu_map__get(other); - } tmp_len = orig->nr + other->nr; tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu)); @@ -387,6 +383,5 @@ struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, merged = cpu_map__trim_new(k, tmp_cpus); free(tmp_cpus); - perf_cpu_map__put(orig); return merged; } diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index 1b15ba13c477..b783249a038b 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -35,6 +35,8 @@ void perf_evlist__init(struct perf_evlist *evlist) static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, struct perf_evsel *evsel) { + struct perf_cpu_map *tmp; + /* * We already have cpus for evsel (via PMU sysfs) so * keep it, if there's no target cpu list defined. @@ -52,7 +54,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, perf_thread_map__put(evsel->threads); evsel->threads = perf_thread_map__get(evlist->threads); - evlist->all_cpus = perf_cpu_map__merge(evlist->all_cpus, evsel->cpus); + tmp = perf_cpu_map__merge(evlist->all_cpus, evsel->cpus); + perf_cpu_map__put(evlist->all_cpus); + evlist->all_cpus = tmp; } static void perf_evlist__propagate_maps(struct perf_evlist *evlist) diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index f94929ebb54b..cf205ed6b158 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -133,6 +133,7 @@ static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subte 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(a); perf_cpu_map__put(b); perf_cpu_map__put(c); return 0; From patchwork Fri Apr 8 03:56:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806036 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 CC663C433EF for ; Fri, 8 Apr 2022 03:58:34 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=glnOEF2EIQ+X8MZyg6laTabJWzz+uRsPN3iG6tw+pqY=; b=D5fa5u1jm34rt4Y3Cd9ZPwve6k qae1UIXzhPuwNJJEvcwLwEyLD9/gCZZArXXOpyUY57OW+3y+zvK0YjjpebSOrfYSlZtRzVLXwU0N9 FhJU1oPxCzh7iJ7UfIUg7IkgBQ6moi++CDKljYMYpvfEHg7MScoPl4wOdGouyqLPGTaC9hhi46J0p k/aTJxKP0OrrQXRBpkvqLjB36Ng1ejSMjTc+L/EQJgYHRtYes5u+eIZX8W0rDW5/811ylydkhqK8X OfE9M257XxcawsJ7jHY+HTpkrYp35IgAb6nrTWU12/4wr3p4EiARjX2BTA4GtAj7eFDLRjzcLfl10 Ai5CSRXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjt-00EpZb-Sj; Fri, 08 Apr 2022 03:56:50 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjY-00EpO5-2h for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2eba71ef663so65492947b3.14 for ; Thu, 07 Apr 2022 20:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=l17qIMDJgHlHJkmXqdwNhErpsnzRSh+81icGNnMQVKs=; b=CDF0VWxYUKfVOpEvH57Wcg+2Ht824//X9lGhIknOL9VIIF+EdYpmgeX3CHwN9sHeAT u9PeKn+tbOApjUseyK1kOHNHVP2i7a3oY6N/aX/r+Oqy5v3/FNPZf7VsQl77EpKtFjXz x0JMAMOcie6hoUXElxRbsp2ogGcKFaa+jDBwAQLG/kcORFBLquHUEfyiXtVheFEeeW8I inJLEZUd53sSTeyezcwzA/kev6gYerwGABOZqnuIZb8SbdZ2hfZ0ujxMuq3R1R3/r14V FxilRM0ZPu80qsZ1UH7WmH9ceYh4ckUANkk5Vjg8tXV2FCorud/XocnxT0G86KTWcY/I mlRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=l17qIMDJgHlHJkmXqdwNhErpsnzRSh+81icGNnMQVKs=; b=pzumKc3ThAGjOyFbawWJkxIelsE2XYXl+glyeKQem08iu+1U5uqv8i8LAKn5REvIOI fDQ9Yw8X5JMSa2atHR6wo99LJo+O1StUxDvYsVjUGuLFzVoT1mwUJPgcdwUcFDQxLzwZ aqUpvgaNG5VXUN1TyHKPKZkNBTSRwy+pV7LhP/KnhHLIFteeWVOyOhN6V5WT5Tv+iaCQ fpra/uELCEoyEpCRwi2F2Bdox8m5pfnCX6nJKZHK5k6uUPnKhEPO/5fjFHv4D6tUQxaT 0fIPbJ6v7USNO0rpED9FmHEPKVAJVaUOUP/pkrSivX4uKjOA0HwBqo9gTW91kh/wr2OK ox5A== X-Gm-Message-State: AOAM53092Sq+hdG8OqUIOTZuhd9FM0xOIwqJzvm9SkLzsQQPlYzsmyfM Ft4xCiOFNHVqFMmVymcfK4M8AG7MgULv X-Google-Smtp-Source: ABdhPJx0t6TUTcHjyQ+6Q0vxZrojw0BDHuxcmQSgV2WmscSbmIhwWv3XjfnNAnYb/FSu9l7V1FRxddn/jSqN X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a25:e30a:0:b0:625:3d53:91b7 with SMTP id z10-20020a25e30a000000b006253d5391b7mr12600758ybd.499.1649390186782; Thu, 07 Apr 2022 20:56:26 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:13 -0700 In-Reply-To: <20220408035616.1356953-1-irogers@google.com> Message-Id: <20220408035616.1356953-3-irogers@google.com> Mime-Version: 1.0 References: <20220408035616.1356953-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 2/5] perf tests: Additional cpumap merge tests From: Ian Rogers To: 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 , 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 Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_205628_155549_D1C038CC X-CRM114-Status: GOOD ( 13.59 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Cover cases where one cpu map is a subset of the other. Signed-off-by: Ian Rogers --- tools/perf/tests/cpumap.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index cf205ed6b158..3b9fc549d30b 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -123,22 +123,36 @@ static int test__cpu_map_print(struct test_suite *test __maybe_unused, int subte return 0; } -static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subtest __maybe_unused) +static int __test__cpu_map_merge(const char *lhs, const char *rhs, int nr, const char *expected) { - 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 *a = perf_cpu_map__new(lhs); + struct perf_cpu_map *b = perf_cpu_map__new(rhs); struct perf_cpu_map *c = perf_cpu_map__merge(a, b); char buf[100]; - TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(c) == 5); + TEST_ASSERT_EQUAL("failed to merge map: bad nr", perf_cpu_map__nr(c), nr); cpu_map__snprint(c, buf, sizeof(buf)); - TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, expected)); perf_cpu_map__put(a); perf_cpu_map__put(b); perf_cpu_map__put(c); return 0; } +static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subtest __maybe_unused) +{ + int ret; + + ret = __test__cpu_map_merge("4,2,1", "4,5,7", 5, "1-2,4-5,7"); + if (ret) return ret; + ret = __test__cpu_map_merge("4,2,1", "1", 3, "1-2,4"); + if (ret) return ret; + ret = __test__cpu_map_merge("1", "4,2,1", 3, "1-2,4"); + if (ret) return ret; + ret = __test__cpu_map_merge("1", "1", 1, "1"); + return ret; +} + DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize); DEFINE_SUITE("Print cpu map", cpu_map_print); DEFINE_SUITE("Merge cpu map", cpu_map_merge); From patchwork Fri Apr 8 03:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806037 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 7DACAC433F5 for ; Fri, 8 Apr 2022 03:58:42 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KpqY/i2wyqiiMTizX4PcMHpJfBsbDYGrHU4aP3HYQNA=; b=dVIOlBI4XUBEXSDYZJjReIfGOC KyrNbBvktCQrbML4P97hc+iiCyWndYFGJQfPTWc0OZJtC3+6U4687nSFJagvri90HvCUkBa0MToNt ult/wCMvNXWhz0biBVPkkLqfI/peI9thdxVkCNBYykjHIhYzPyOhnLFBafpZNZr8FVUfXooAXbQe5 ezOGFIL6u4NgGr9XyNaPWuYn5a6/17w+faa24ZuiuulhgLBBKBuRMGKmOhZQ9HVziEPym6oDARpm+ dPGsCaaEYR0FUAPteIZ9i45B0IvoBLIOjP2tnhwQgyYbg8YERfj7Xs5Lix1gUi16wz2+MdOXA2nzj inwlPYbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfk4-00EpeO-0z; Fri, 08 Apr 2022 03:57:00 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfja-00EpPR-Op for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:32 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2eb5d4fbd54so65718057b3.4 for ; Thu, 07 Apr 2022 20:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WQySeKYeF44ltZobAOk7xNxuZcXMSl5HKLY3fUam6qQ=; b=hDSKG5yrND2PToJM4rKnqeJ62RcJGj0+ro5piw+CTfoTTw5cN0QF1P7O2M+7Pw/a2k L6jGvSd8QXVOEbBvp6N5WG9Qr2H3iF39h92XQRS14ohnfaZbdVAJkkC75h2N+su/IKoM fAs5tI8ZTlGVVORECCu57iLTSg7bB7hVyc0eos9SWzxzbfIa9pxVIPJMNcFMi1Kq4NlX 1xl/v4pATsxUxOkH77mZmhsu7yQpboO/1uk2drOLg2nCdjjUlESDDxlYYYgn0+7Z0Bqf 34wk3XU7U7sGptA96+apazLcWfA1zaTpmsPavxFg0RjKW6xb36/MyhRG0CGN6ETslOXO qIzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WQySeKYeF44ltZobAOk7xNxuZcXMSl5HKLY3fUam6qQ=; b=6pm+50sNqosoUNBfVJ+7Zw7tMsZAnY6GjF6mZrwufkllyGEVfdZ+i58SAKSNfJT0kX /SL05KKKmf13CbwR9nNbp/TG9GIQ/cGAOmBpgKMhhhEAutybNUgfyM6L//Fx5qFEYpPD L+p6QOLUd3jhYU1kaV8E1OO/o/DQJprwXToCXbjlzoXCNl7PA4Ulwq4jStbidFsyVlr7 pAPPi4a4gj5rrD7DPksrQdNZxySrrtIC4mZRYBKrX2gaizPcycCwqRYMPxyufLHr/B2z 7UwI9aEMCoErIr8oNcmxWvIVpwajhTFSaVPhTMSlRwuFT/7GaqlxomCi36PicXiJCSr1 hU7w== X-Gm-Message-State: AOAM531zJjvA9xwAOeOVW7GYVIth67UJc3GJqX1q+JvjRmyAad0CTzFD DBzYLztoong+YyDCQyIUQMfXNCc9sF9r X-Google-Smtp-Source: ABdhPJxUah9zZN5gVulVQKHMKAB9PrsIvEpYDGhc34fesgAhXN4h148IRiOkJNKasQpmJrMLd6NQV31cTvDt X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a25:e811:0:b0:63d:b0e1:c78 with SMTP id k17-20020a25e811000000b0063db0e10c78mr12871250ybd.195.1649390189216; Thu, 07 Apr 2022 20:56:29 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:14 -0700 In-Reply-To: <20220408035616.1356953-1-irogers@google.com> Message-Id: <20220408035616.1356953-4-irogers@google.com> Mime-Version: 1.0 References: <20220408035616.1356953-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 3/5] perf cpumap: Add intersect function. From: Ian Rogers To: 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 , 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 Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_205630_854612_4651AA82 X-CRM114-Status: GOOD ( 17.84 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The merge function gives the union of two cpu maps. Add an intersect function which will be used in the next change. Signed-off-by: Ian Rogers --- tools/lib/perf/cpumap.c | 35 ++++++++++++++++++++++++++++ tools/lib/perf/include/perf/cpumap.h | 2 ++ tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/cpumap.c | 35 ++++++++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + 5 files changed, 74 insertions(+) diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index 95c56e17241b..66371135e742 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -385,3 +385,38 @@ struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, free(tmp_cpus); return merged; } + +struct perf_cpu_map *perf_cpu_map__intersect(struct perf_cpu_map *orig, + struct perf_cpu_map *other) +{ + struct perf_cpu *tmp_cpus; + int tmp_len; + int i, j, k; + struct perf_cpu_map *merged = NULL; + + if (perf_cpu_map__is_subset(other, orig)) + return perf_cpu_map__get(orig); + if (perf_cpu_map__is_subset(orig, other)) + return perf_cpu_map__get(other); + + tmp_len = max(orig->nr, other->nr); + tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu)); + if (!tmp_cpus) + return NULL; + + i = j = k = 0; + while (i < orig->nr && j < other->nr) { + if (orig->map[i].cpu < other->map[j].cpu) + i++; + else if (orig->map[i].cpu > other->map[j].cpu) + j++; + else { + j++; + tmp_cpus[k++] = orig->map[i++]; + } + } + if (k) + merged = cpu_map__trim_new(k, tmp_cpus); + free(tmp_cpus); + return merged; +} diff --git a/tools/lib/perf/include/perf/cpumap.h b/tools/lib/perf/include/perf/cpumap.h index 4a2edbdb5e2b..a2a7216c0b78 100644 --- a/tools/lib/perf/include/perf/cpumap.h +++ b/tools/lib/perf/include/perf/cpumap.h @@ -19,6 +19,8 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file); LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); LIBPERF_API struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, struct perf_cpu_map *other); +LIBPERF_API struct perf_cpu_map *perf_cpu_map__intersect(struct perf_cpu_map *orig, + struct perf_cpu_map *other); LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index fac3717d9ba1..dffa41e7ee20 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -88,6 +88,7 @@ static struct test_suite *generic_tests[] = { &suite__backward_ring_buffer, &suite__cpu_map_print, &suite__cpu_map_merge, + &suite__cpu_map_intersect, &suite__sdt_event, &suite__is_printable_array, &suite__bitmap_print, diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index 3b9fc549d30b..112331829414 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -153,6 +153,41 @@ static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subte return ret; } +static int __test__cpu_map_intersect(const char *lhs, const char *rhs, int nr, const char *expected) +{ + struct perf_cpu_map *a = perf_cpu_map__new(lhs); + struct perf_cpu_map *b = perf_cpu_map__new(rhs); + struct perf_cpu_map *c = perf_cpu_map__intersect(a, b); + char buf[100]; + + TEST_ASSERT_EQUAL("failed to intersect map: bad nr", perf_cpu_map__nr(c), nr); + cpu_map__snprint(c, buf, sizeof(buf)); + TEST_ASSERT_VAL("failed to intersect map: bad result", !strcmp(buf, expected)); + perf_cpu_map__put(a); + perf_cpu_map__put(b); + perf_cpu_map__put(c); + return 0; +} + +static int test__cpu_map_intersect(struct test_suite *test __maybe_unused, int subtest __maybe_unused) +{ + int ret; + + ret = __test__cpu_map_intersect("4,2,1", "4,5,7", 1, "4"); + if (ret) return ret; + ret = __test__cpu_map_intersect("1-8", "6-9", 3, "6-8"); + if (ret) return ret; + ret = __test__cpu_map_intersect("1-8,12-20", "6-9,15", 4, "6-8,15"); + if (ret) return ret; + ret = __test__cpu_map_intersect("4,2,1", "1", 1, "1"); + if (ret) return ret; + ret = __test__cpu_map_intersect("1", "4,2,1", 1, "1"); + if (ret) return ret; + ret = __test__cpu_map_intersect("1", "1", 1, "1"); + return ret; +} + DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize); DEFINE_SUITE("Print cpu map", cpu_map_print); DEFINE_SUITE("Merge cpu map", cpu_map_merge); +DEFINE_SUITE("Intersect cpu map", cpu_map_intersect); diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 5bbb8f6a48fc..f2823c4859b8 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -127,6 +127,7 @@ DECLARE_SUITE(event_times); DECLARE_SUITE(backward_ring_buffer); DECLARE_SUITE(cpu_map_print); DECLARE_SUITE(cpu_map_merge); +DECLARE_SUITE(cpu_map_intersect); DECLARE_SUITE(sdt_event); DECLARE_SUITE(is_printable_array); DECLARE_SUITE(bitmap_print); From patchwork Fri Apr 8 03:56:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806038 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 81A2FC433F5 for ; Fri, 8 Apr 2022 03:58:49 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jUY8MLaA7pK7v1aKx4voIJPHgD249PK2LN4LRwkJxZY=; b=eVzF405vNpytHXgHsaYm70mSs8 WW+yXbxLtoWU69yU0jwcifDiLqebKISCmhL0/2uqxxUsDwpCvHT5+tOkglV6AeOh+f2fpJt2OyH4b MKq4f1aMh1Cdlg5nzNLG924M2rbbqzlAFRr/xZeR0Z8I2QPyx+zZgbrVgQ/ECHwjLS9w1fi87gBzz mi5/1ZCopxPfpI/7CPs/rnADwvupl2N26CLefVgUMUy+iOnDgCFP15jwHKFjDzGSybmGl9MYkM2Pd ki3JqOE62OHs69dmGxsBf63StoVH08c0nnQ3MmV6/yV+DfWDFGOowNHlyjclrvMPk0z0FN+L1+piF B0ARpbwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfkF-00EpiV-J0; Fri, 08 Apr 2022 03:57:11 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjd-00EpRA-7W for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:36 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id p15-20020a25818f000000b0063daf5f7957so5759582ybk.12 for ; Thu, 07 Apr 2022 20:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=px/VRI5+tmvW8TY4DxlEQefxFci8hBygfH+hQRwc2I4=; b=jK13o5ns/33SqXgzujtB4Nxs9SV3lbqEfNf0l7f4cKbJ8BtJXG8JhtTrv6Ai2BRlEl PsTUd0J0QaEWpCUXE+VCR8nDFk7Y6nV1Yozfvut3l7m5nSaov6CKzDY54e8a2V3QbhO+ LFfiDSRRVUMROTV6cf8OqnIOftobtohgynSdX4r4iSQUrnsmZZl1SH6t0hxAYIKDKO5v g8tF7sOTmSSf+Q3/Zs/Dlh6E9bgEp8Qu1QXketKA5vffysyL+KE+GTd4DGu2+PbSYgNU MEiZWs6eRTb8zr+IO4XY9VLyrGD7E9kQRKtsiynXDuYkijgu8kbuQZdhEXiequ5HjFFn mTug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=px/VRI5+tmvW8TY4DxlEQefxFci8hBygfH+hQRwc2I4=; b=YQG+ym5MJI/spkcUGfrPqB8xpFd+pEEe5UHPLCUGzL1+yvoN1qAUIEeA2W8GxnvrYN EHbdA14PiTjhq6HSVifJ2bdfeB5Y84fcd1veRzg1xU+OLrHx+A4GbqC9CrM355nFTEo1 NiwWsNc7tVUXBbYb6bw4wrZQbAbEoRMZ3TZo9xWJ7koldOJAqVXCrYnXmM+t2DlmSKDJ oJ9QTR4fTdj2QmozMDwohl7b/X0m/ThPmafsMzLAMFuFm+7Kk8/B+dVc9f4idXMzdMnW tSM7yixY6s/nD0Z0BbsccUsAiDEVNvnPmQTJmBnMY9bch0CvxnIPWcoXshMw195xHnGs cVvA== X-Gm-Message-State: AOAM5331Oj2Ww8oEzdHXicL0e6ODGo+82BxdP/YsOSvqPmJwgZXxs9VT 3PuQecJnzs1moUvnkWRENDUtIwE/sips X-Google-Smtp-Source: ABdhPJyW3JGV3PPDdlOL7zs8MeFlVd0fGndXJiqQfDxHalseZrrLAuX3NNP+EbZB2svyS4mWYSkhL5+D0oPL X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a5b:7cf:0:b0:623:df1c:b83d with SMTP id t15-20020a5b07cf000000b00623df1cb83dmr12538139ybq.75.1649390191633; Thu, 07 Apr 2022 20:56:31 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:15 -0700 In-Reply-To: <20220408035616.1356953-1-irogers@google.com> Message-Id: <20220408035616.1356953-5-irogers@google.com> Mime-Version: 1.0 References: <20220408035616.1356953-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 4/5] perf evlist: Respect all_cpus when setting user_requested_cpus From: Ian Rogers To: 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 , 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 Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_205633_316736_7C0BBB0A X-CRM114-Status: GOOD ( 15.18 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If all_cpus is calculated it represents the merge/union of all evsel cpu maps. By default user_requested_cpus is computed to be the online CPUs. For uncore events, it is often the case currently that all_cpus is a subset of user_requested_cpus. Metrics printed without aggregation and with metric-only, in print_no_aggr_metric, iterate over user_requested_cpus assuming every CPU has a metric to print. For each CPU the prefix is printed, but then if the evsel's cpus doesn't contain anything you get an empty line like the following on a 2 socket 36 core SkylakeX: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.000453137 CPU0 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 CPU18 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 2.003717143 CPU0 0.00 ... ``` While it is possible to be lazier in printing the prefix and trailing newline, having user_requested_cpus not be a subset of all_cpus is preferential so that wasted work isn't done elsewhere user_requested_cpus is used. The change modifies user_requested_cpus to be the intersection of user specified CPUs, or default all online CPUs, with the CPUs computed through the merge of all evsel cpu maps. New behavior: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.001086325 CPU0 0.00 1.001086325 CPU18 0.00 2.003671291 CPU0 0.00 2.003671291 CPU18 0.00 ... ``` Signed-off-by: Ian Rogers --- tools/perf/util/evlist.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 52ea004ba01e..196d57b905a0 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1036,6 +1036,13 @@ int evlist__create_maps(struct evlist *evlist, struct target *target) if (!cpus) goto out_delete_threads; + if (evlist->core.all_cpus) { + struct perf_cpu_map *tmp; + + tmp = perf_cpu_map__intersect(cpus, evlist->core.all_cpus); + perf_cpu_map__put(cpus); + cpus = tmp; + } evlist->core.has_user_cpus = !!target->cpu_list && !target->hybrid; perf_evlist__set_maps(&evlist->core, cpus, threads); From patchwork Fri Apr 8 03:56:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806039 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 C4BFFC433F5 for ; Fri, 8 Apr 2022 03:58:58 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9s6mjoZUhffsIU4k2hr8Q3hA1hYpo3VrggGrgmgj4r4=; b=N3+CNg/Mdh4U07cHeaL5S5mDzp zJeFYVa22CzYLjZTPXvuKJvHC8/6pbn4TocpiI4/QF6J5NE+0a60VvAVsJWCgKuZfwSiy9BlWycX4 lMMFXX4zvP0g8KG4/qjOuKOzRapfeT0eUsaoI5ipdMU9Xu1bxhZPI3kWuOKwbSTBms80e/3V4eXRC Q/SjjIX1Ze+HeEZzwHwxd3/B0x6idO4WJYFwTAF7DKX5gLOaq3lsHOTLne9ZRf7kmKCoKNgXg0rXo rvVkA5ONTOCH7+ErVyVYLJ1D9hqC7oRhM4XgVOhzquqMLHU7h/TzCZ+Y9ZNFumeGx2wP5hgnGeslc HeGPK9rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfkW-00EpvV-Op; Fri, 08 Apr 2022 03:57:29 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjf-00EpSO-K2 for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:37 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id z15-20020a25bb0f000000b00613388c7d99so5768810ybg.8 for ; Thu, 07 Apr 2022 20:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xZ10IcINVF8NaTdbFdZL+w7KjQhTRKJQcz6epMPOOOM=; b=J4qvkXu5Auw7V3C2S/vvXFegiHFo9mQHd6ao3pTChQVYX52sQr8dniWFYnHQm0j3st bEHb9vfsR+oLWFuAcQDlvK2q3VkZl8tQz1YYKUO4LP7/LugavDcnOzpgkv3zYe6dVZWU 2gila+WXN4yuqAs0Y/8n5CcZVof5ozNa+BQYvOMd9I5gede5kj5HR53kdkNQRgAduvi9 GK/7tWnOc6YXNAc8OtiGBNX4Dx9baemHfXsWm3UpV3cEKIbPRr1uTbrXOndoU8gLi5HL +EQ8BatF2gFnpVHfijt7yca9E1HUzPitJL5yYGKSHLpDVuWJuUNgZs4nUsNKC2CAMt0X qV2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xZ10IcINVF8NaTdbFdZL+w7KjQhTRKJQcz6epMPOOOM=; b=y+a5NvwxM3JTJBcl6aVarJQk6fs/Oi0HO/F65BYLSgE+9HDFRJZ4tAFCBf+rU6yB8p XUUj+D8QRJUnCuUQzDw7MnWPUjIsKWAUislPARF6hUVnNeBwlsEuRop7M+d7VP6W7vdN tDwNs/Szj3cQakUR54p4OHFklAL8Eh66vETl8uNbcq3z+Tj+2Elep1ZOGCUxaXm2dwYs iNIJoxUeQo9mRBjCcht/PR21ooyHSJec+TQP/gkbRueqT2gqxS8Ea3SFYff7m59fVQk2 vnYY82fNf3dZt6egr9q7cvp8+STtd7cXhOePcFmJswjAnjhCs9Q3LSkt5D53qAxoxFyL UjqQ== X-Gm-Message-State: AOAM531ie0Y670HnGMaIrDdgBw9cypEPEzkdI80C71ex7xK/ny3PY+FU PfmYIHhnRm4wuWmMO3AFC/6uJsDMdmws X-Google-Smtp-Source: ABdhPJy+FeSzHm3EOgknn5QLY35sfKLCgJaxnhbi0GFsA4RgFhAgYugNlhNtSIbfmK85JSq7ivRl2ioHGYzK X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a25:8546:0:b0:61e:1d34:ec71 with SMTP id f6-20020a258546000000b0061e1d34ec71mr11434496ybn.259.1649390193853; Thu, 07 Apr 2022 20:56:33 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:16 -0700 In-Reply-To: <20220408035616.1356953-1-irogers@google.com> Message-Id: <20220408035616.1356953-6-irogers@google.com> Mime-Version: 1.0 References: <20220408035616.1356953-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 5/5] perf test: Combine cpu map tests into 1 suite From: Ian Rogers To: 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 , 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 Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_205635_699635_50D4FEE3 X-CRM114-Status: GOOD ( 12.62 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Combine related CPU map tests into 1 suite reducing global state. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 5 +---- tools/perf/tests/cpumap.c | 16 ++++++++++++---- tools/perf/tests/tests.h | 5 +---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index dffa41e7ee20..1941ae52e8b6 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -79,16 +79,13 @@ static struct test_suite *generic_tests[] = { &suite__bpf, &suite__thread_map_synthesize, &suite__thread_map_remove, - &suite__cpu_map_synthesize, + &suite__cpu_map, &suite__synthesize_stat_config, &suite__synthesize_stat, &suite__synthesize_stat_round, &suite__event_update, &suite__event_times, &suite__backward_ring_buffer, - &suite__cpu_map_print, - &suite__cpu_map_merge, - &suite__cpu_map_intersect, &suite__sdt_event, &suite__is_printable_array, &suite__bitmap_print, diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index 112331829414..fc124757a082 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -187,7 +187,15 @@ static int test__cpu_map_intersect(struct test_suite *test __maybe_unused, int s return ret; } -DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize); -DEFINE_SUITE("Print cpu map", cpu_map_print); -DEFINE_SUITE("Merge cpu map", cpu_map_merge); -DEFINE_SUITE("Intersect cpu map", cpu_map_intersect); +static struct test_case cpu_map_tests[] = { + TEST_CASE("Synthesize cpu map", cpu_map_synthesize), + TEST_CASE("Print cpu map", cpu_map_print), + TEST_CASE("Merge cpu map", cpu_map_merge), + TEST_CASE("Intersect cpu map", cpu_map_intersect), + { .name = NULL, } +}; + +struct test_suite suite__cpu_map = { + .desc = "CPU map", + .test_cases = cpu_map_tests, +}; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index f2823c4859b8..895803fdedc4 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -118,16 +118,13 @@ DECLARE_SUITE(bpf); DECLARE_SUITE(session_topology); DECLARE_SUITE(thread_map_synthesize); DECLARE_SUITE(thread_map_remove); -DECLARE_SUITE(cpu_map_synthesize); +DECLARE_SUITE(cpu_map); DECLARE_SUITE(synthesize_stat_config); DECLARE_SUITE(synthesize_stat); DECLARE_SUITE(synthesize_stat_round); DECLARE_SUITE(event_update); DECLARE_SUITE(event_times); DECLARE_SUITE(backward_ring_buffer); -DECLARE_SUITE(cpu_map_print); -DECLARE_SUITE(cpu_map_merge); -DECLARE_SUITE(cpu_map_intersect); DECLARE_SUITE(sdt_event); DECLARE_SUITE(is_printable_array); DECLARE_SUITE(bitmap_print);