Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28712332rwd; Wed, 5 Jul 2023 01:18:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFWQ5EbJk0lxjgKVxuwlJIhp/P3qPKETTatDkefkmPeoxgbKy60oMZ7+fvYpfdyLH5N6khp X-Received: by 2002:a5b:3ce:0:b0:bc1:dfa5:8399 with SMTP id t14-20020a5b03ce000000b00bc1dfa58399mr12572323ybp.13.1688545113174; Wed, 05 Jul 2023 01:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688545113; cv=none; d=google.com; s=arc-20160816; b=FHO0uNm6zS2GoEGwOHTlN/IkFwnb7RxAj0J7zQKSE234DgNrBHMicafHbsA/NdKbJs /JRdq/6rgJadqsQAk7dTtvG2vM/hDom2n1PWHAJN4uB2fXaKipmOC/D/kX0xKbsTldNx Nv1g+5L03eUSs58eLtpvxLwbXXV/rQFEldRb+Pu/DkGTmLpItp+IGkKeXPD3Lq9115Qt btk2HAfE2qS87bcaKYhSFOxPsF9U9FRj9DuuRIDfItrP6gyOCd47iN1Z2J24pIBLR8R/ KF1SgR3g+//hc7uw8iEEqoPzJS48Hdf96Kd/za7+Rq22bguCvPsLnFpqE2mqd8HU6IkX PUOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=SJ3Z+IuMDDbA+LXMVEb5SfAXFdQnxL1EgY+ESvFgpF8=; fh=KsGBWkusv53QcWyhUbt1BErgQlzJS9SrAt+6KiA89Gk=; b=ZpRSQvgn04Po1UvNIZvel3GOLEpWcPeS1Md3m59DhdzIETeysAx1kN2SKXaNjHXXcj vAJRijOIS8j/A2gr8HG56A2Zfmm79voxCFL73T0sKSNwbM+lBbyhgPD7zfIcBrwbCEiS Kb4u6W+fTTCuyf4HojNHT1LrXlWgiiYUq/6I7cHL7jGNkID8nqWV8wzYmHDtMkM3pfi5 ZHSJP0rCZzYTqdHTRv7iF15UMvNFOVXSU4PduXOpgNQ0C7djviJdAke2Q8QjHWVmc3gp yk4F4HbMuMDTDPXZAqwcsu1aWB20x5HhVAg+ijeGTgULo6eqarvp4Rr/sBkrnnC4QgDc ym2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a634a03000000b00553ebb05d23si22003622pga.70.2023.07.05.01.18.20; Wed, 05 Jul 2023 01:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232289AbjGEHzB (ORCPT + 99 others); Wed, 5 Jul 2023 03:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbjGEHzA (ORCPT ); Wed, 5 Jul 2023 03:55:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B2B210DD; Wed, 5 Jul 2023 00:54:58 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5849C165C; Wed, 5 Jul 2023 00:55:40 -0700 (PDT) Received: from [192.168.1.100] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F5A53F73F; Wed, 5 Jul 2023 00:54:55 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 08:54:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 2/2] perf test: Fix event parsing test when PERF_PMU_CAP_EXTENDED_HW_TYPE isn't supported. To: Ian Rogers Cc: linux-perf-users@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , linux-kernel@vger.kernel.org References: <20230704143628.1177124-1-james.clark@arm.com> <20230704143628.1177124-2-james.clark@arm.com> Content-Language: en-US From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/07/2023 18:12, Ian Rogers wrote: > On Tue, Jul 4, 2023 at 7:38 AM James Clark wrote: >> >> Arm has multiple PMU types for heterogeneous systems, but doesn't >> currently support PERF_PMU_CAP_EXTENDED_HW_TYPE. Make the tests >> support both scenarios so that they pass on Arm, and will still pass >> once PERF_PMU_CAP_EXTENDED_HW_TYPE support is added. >> >> Fixes: 27c9fcfc1e14 ("perf test: Update parse-events expectations to test for multiple events") >> Signed-off-by: James Clark >> --- >> tools/perf/tests/parse-events.c | 86 +++++++++++++++++++-------------- >> 1 file changed, 50 insertions(+), 36 deletions(-) >> >> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c >> index 21f79aa31233..454b667e144b 100644 >> --- a/tools/perf/tests/parse-events.c >> +++ b/tools/perf/tests/parse-events.c >> @@ -20,6 +20,20 @@ >> #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ >> PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) >> >> +static int num_entries(void) > > Thanks James! A nit, I'd prefer a function name that is a little less > ambiguous, perhaps num_core_events_per_event which is too long, > perhaps num_core_entries. Other than that: > > Acked-by: Ian Rogers > Sure, will change and re-send. Thanks for the review. > Ian > >> +{ >> + /* >> + * If the kernel supports extended type, expect events to be >> + * opened once for each PMU type. Otherwise fall back to the legacy >> + * behavior of opening only one event even though there are multiple >> + * PMUs >> + */ >> + if (perf_pmus__supports_extended_type()) >> + return perf_pmus__num_core_pmus(); >> + >> + return 1; >> +} >> + >> static bool test_config(const struct evsel *evsel, __u64 expected_config) >> { >> __u32 type = evsel->core.attr.type; >> @@ -339,7 +353,7 @@ static int test__checkevent_symbolic_name_modifier(struct evlist *evlist) >> struct perf_evsel *evsel; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == perf_pmus__num_core_pmus()); >> + evlist->core.nr_entries == num_entries()); >> >> perf_evlist__for_each_entry(&evlist->core, evsel) { >> TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); >> @@ -842,11 +856,11 @@ static int test__group1(struct evlist *evlist) >> struct evsel *evsel, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (perf_pmus__num_core_pmus() * 2)); >> + evlist->core.nr_entries == (num_entries() * 2)); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == perf_pmus__num_core_pmus()); >> + evlist__nr_groups(evlist) == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* instructions:k */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -885,7 +899,7 @@ static int test__group2(struct evlist *evlist) >> struct evsel *evsel, *leader = NULL; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus() + 1)); >> + evlist->core.nr_entries == (2 * num_entries() + 1)); >> /* >> * TODO: Currently the software event won't be grouped with the hardware >> * event except for 1 PMU. >> @@ -1051,11 +1065,11 @@ static int test__group4(struct evlist *evlist __maybe_unused) >> struct evsel *evsel, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (perf_pmus__num_core_pmus() * 2)); >> + evlist->core.nr_entries == (num_entries() * 2)); >> TEST_ASSERT_VAL("wrong number of groups", >> - perf_pmus__num_core_pmus() == evlist__nr_groups(evlist)); >> + num_entries() == evlist__nr_groups(evlist)); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles:u + p */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1096,11 +1110,11 @@ static int test__group5(struct evlist *evlist __maybe_unused) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (5 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (5 * num_entries())); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == (2 * perf_pmus__num_core_pmus())); >> + evlist__nr_groups(evlist) == (2 * num_entries())); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles + G */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1131,7 +1145,7 @@ static int test__group5(struct evlist *evlist __maybe_unused) >> TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); >> TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); >> } >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles:G */ >> evsel = leader = evsel__next(evsel); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1161,7 +1175,7 @@ static int test__group5(struct evlist *evlist __maybe_unused) >> TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); >> TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); >> } >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles */ >> evsel = evsel__next(evsel); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1182,11 +1196,11 @@ static int test__group_gh1(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (2 * num_entries())); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == perf_pmus__num_core_pmus()); >> + evlist__nr_groups(evlist) == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles + :H group modifier */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1223,11 +1237,11 @@ static int test__group_gh2(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (2 * num_entries())); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == perf_pmus__num_core_pmus()); >> + evlist__nr_groups(evlist) == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles + :G group modifier */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1264,11 +1278,11 @@ static int test__group_gh3(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (2 * num_entries())); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == perf_pmus__num_core_pmus()); >> + evlist__nr_groups(evlist) == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles:G + :u group modifier */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1305,11 +1319,11 @@ static int test__group_gh4(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (2 * num_entries())); >> TEST_ASSERT_VAL("wrong number of groups", >> - evlist__nr_groups(evlist) == perf_pmus__num_core_pmus()); >> + evlist__nr_groups(evlist) == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles:G + :uG group modifier */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1346,9 +1360,9 @@ static int test__leader_sample1(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (3 * num_entries())); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles - sampling group leader */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1398,9 +1412,9 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (2 * num_entries())); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* instructions - sampling group leader */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1437,9 +1451,9 @@ static int test__checkevent_pinned_modifier(struct evlist *evlist) >> struct evsel *evsel = NULL; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == perf_pmus__num_core_pmus()); >> + evlist->core.nr_entries == num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> evsel = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); >> TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); >> @@ -1455,9 +1469,9 @@ static int test__pinned_group(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == (3 * num_entries())); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles - group leader */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1500,9 +1514,9 @@ static int test__exclusive_group(struct evlist *evlist) >> struct evsel *evsel = NULL, *leader; >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == 3 * num_entries()); >> >> - for (int i = 0; i < perf_pmus__num_core_pmus(); i++) { >> + for (int i = 0; i < num_entries(); i++) { >> /* cycles - group leader */ >> evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel)); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); >> @@ -1574,7 +1588,7 @@ static int test__checkevent_precise_max_modifier(struct evlist *evlist) >> struct evsel *evsel = evlist__first(evlist); >> >> TEST_ASSERT_VAL("wrong number of entries", >> - evlist->core.nr_entries == (1 + perf_pmus__num_core_pmus())); >> + evlist->core.nr_entries == 1 + num_entries()); >> TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); >> TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_TASK_CLOCK)); >> return TEST_OK; >> -- >> 2.34.1 >>