From patchwork Wed May 24 22:18:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13254569 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 75A5FC77B7C for ; Wed, 24 May 2023 22:41:12 +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:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qqcrazpvLE2YKf5W64xBcdzMJG2Bbv+ETDdaha6DGcE=; b=BBgXkGpO3NfNUh kDo4itjUycEJ0K122dGrt8ajmDSeOR9tzuM/p41IjoM/pgdOVhIUJ/SqPI+XZ+5hwQXyQSAFSl3Dp OH+HE8MBpa+/MLm2U6wLaz15sMhXNk1SGNeI1UJh1dGzccVmMIDU6/KxWHz9OOGYWACrqbjExBz5y 8haeqFJOuBXtvyDOsDZjFdjL/GXbVGawx3hmSXoiWIz5oiixCXqRAineStc/HYOwIduutjh8k+Ho9 fB6Iqe0xqYA6aNWDW3nt++xz19UfRJcodaKrozqIoDLDoosGLRTK53hEU63YDnpJJveLA5PFKB+Hs D5+b/uy66z9gVB0BzlUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1xA1-00EpDF-1B; Wed, 24 May 2023 22:40:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1x9m-00Ep7S-2E for linux-arm-kernel@bombadil.infradead.org; Wed, 24 May 2023 22:40:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cjAbWq1xZ7aD31R1h5+Cy8ZSDZyyIBasEI10DVMtL4M=; b=jCCGvh70tLm5jc6Pbe/7vUrb28 VOb7AWvFWSjGuOyle82JF7BKi9CZlO4u2SXBgr6Tl8F9P2wiY+OiMlmCCAyY5I0jQCZgrv2GlPfjo 7kXsIYUJ2dmNbx/VFqD2vKP+OplNTcEyyD93eYoEYSgT6V9LWbC84N5mI1R8eaVbENp+YNJmIfOEI 3D3/rx9wUDf2N3TyWqnLkOFVi8kMCsc/7M0roWhNEyX1P3Vb4HZI6rJGEN5ARob6dI80SClkFBadk TYJ0MnIGHnoDEYv30sXTM/JbQ6+jcXm53ruTNhFQykIDSK7Swa8dEV4MwGn7M374d3Jvc0oTpCupK qXz/oayg==; Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1wpE-0056ct-02 for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 22:19:25 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-564f529a663so17144397b3.1 for ; Wed, 24 May 2023 15:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966757; x=1687558757; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cjAbWq1xZ7aD31R1h5+Cy8ZSDZyyIBasEI10DVMtL4M=; b=p0AhpgXvZl8O7RhTTMtAr534BDXoiK4d/HxTufbtoGDKujmUAJho6GTXP8kd6FAbKl HVIdVGezNvfTcmbLbZIj2zZRsM4FsEy6iN6IWt+evEgx8S8XI1x1ZtfRltJRmPu30hd2 kkIFB/josxZHZWjTz//UdEi3TZqb4OnOn0EaVu0FhPE27c1gkvWp2B//EcHGDg8e3ThF 18xvAzudf0X9+XnMuE1fC9PiNi2n3flAM7q+czmWCENi/N7vYvEuMdKO9wSmKo2uIPTt qNVxvbOW/fw4VVdd7cR50euAcg7TmYSqKPksPwCwGrzvRiekbPTPwzxLgP+w+CclTopP dvhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966757; x=1687558757; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cjAbWq1xZ7aD31R1h5+Cy8ZSDZyyIBasEI10DVMtL4M=; b=HctwXJe33qZlMF2HyT5MojSKeVvmWGsCshnvnA3u7AFzvN/WVaiiXccDRd7yqnsGVS z3s/B7urDomiOlbG1QzQE6wIucgqrQ8fs+UxAKAGNjG8jq2PBuzX62Yty68JhyABIrO7 5tojRduU34Gcwih1lLHVEMGtAiUPioAyVJcbJkUZuBefmR5XVQM7+mjr3ko8ZVKNvPzC 9ZKWHRlKUxNzvbEx7Tt3W0ixzunn5L23wcywlncgnCboTUr/TGdl9yyjgJFMumGoxOQI 6VS23yGtJOSQZ6DgH5BltEN6F+6juHgOVNab241CCvmvflSi7FQxmHdKQkGY+ymV8EF4 mMPw== X-Gm-Message-State: AC+VfDwUIGcPixaksDbWCbbXZVnigNQvLIJX/g+jH0gKyWRMfhDxjQal 8XX5p29f1TWmKMyk1rbjbKYwp4+nGxpN X-Google-Smtp-Source: ACHHUZ7A/zgz61i+jDQae5egqZTZUd2asN0Lc32kLdqF4kB08b2NQcqeXPmsMs8FXQsh8XavrY8B6mFmujRA X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a81:a749:0:b0:565:51b:c6f0 with SMTP id e70-20020a81a749000000b00565051bc6f0mr7187150ywh.6.1684966757019; Wed, 24 May 2023 15:19:17 -0700 (PDT) Date: Wed, 24 May 2023 15:18:14 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-19-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 18/35] perf x86: Iterate hybrid PMUs as core PMUs From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230524_231923_650013_B0CFF9B7 X-CRM114-Status: GOOD ( 19.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 Rather than iterating over a separate hybrid list, iterate all PMUs with the hybrid ones having is_core as true. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/tests/hybrid.c | 2 +- tools/perf/arch/x86/util/evlist.c | 25 +++++++++++++++++-------- tools/perf/arch/x86/util/perf_regs.c | 14 ++++++++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/tools/perf/arch/x86/tests/hybrid.c b/tools/perf/arch/x86/tests/hybrid.c index 941a9edfed4e..944bd1b4bab6 100644 --- a/tools/perf/arch/x86/tests/hybrid.c +++ b/tools/perf/arch/x86/tests/hybrid.c @@ -3,7 +3,7 @@ #include "debug.h" #include "evlist.h" #include "evsel.h" -#include "pmu-hybrid.h" +#include "pmu.h" #include "tests/tests.h" static bool test_config(const struct evsel *evsel, __u64 expected_config) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/evlist.c index 1b6065841fb0..03f7eb4cf0a4 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -4,7 +4,6 @@ #include "util/evlist.h" #include "util/parse-events.h" #include "util/event.h" -#include "util/pmu-hybrid.h" #include "topdown.h" #include "evsel.h" @@ -12,9 +11,6 @@ static int ___evlist__add_default_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs) { - struct perf_cpu_map *cpus; - struct evsel *evsel, *n; - struct perf_pmu *pmu; LIST_HEAD(head); size_t i = 0; @@ -25,15 +21,24 @@ static int ___evlist__add_default_attrs(struct evlist *evlist, return evlist__add_attrs(evlist, attrs, nr_attrs); for (i = 0; i < nr_attrs; i++) { + struct perf_pmu *pmu = NULL; + if (attrs[i].type == PERF_TYPE_SOFTWARE) { - evsel = evsel__new(attrs + i); + struct evsel *evsel = evsel__new(attrs + i); + if (evsel == NULL) goto out_delete_partial_list; list_add_tail(&evsel->core.node, &head); continue; } - perf_pmu__for_each_hybrid_pmu(pmu) { + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + struct perf_cpu_map *cpus; + struct evsel *evsel; + + if (!pmu->is_core) + continue; + evsel = evsel__new(attrs + i); if (evsel == NULL) goto out_delete_partial_list; @@ -51,8 +56,12 @@ static int ___evlist__add_default_attrs(struct evlist *evlist, return 0; out_delete_partial_list: - __evlist__for_each_entry_safe(&head, n, evsel) - evsel__delete(evsel); + { + struct evsel *evsel, *n; + + __evlist__for_each_entry_safe(&head, n, evsel) + evsel__delete(evsel); + } return -1; } diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 0ed177991ad0..26abc159fc0e 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -10,7 +10,6 @@ #include "../../../util/debug.h" #include "../../../util/event.h" #include "../../../util/pmu.h" -#include "../../../util/pmu-hybrid.h" const struct sample_reg sample_reg_masks[] = { SMPL_REG(AX, PERF_REG_X86_AX), @@ -286,7 +285,6 @@ uint64_t arch__intr_reg_mask(void) .disabled = 1, .exclude_kernel = 1, }; - struct perf_pmu *pmu; int fd; /* * In an unnamed union, init it here to build on older gcc versions @@ -294,12 +292,20 @@ uint64_t arch__intr_reg_mask(void) attr.sample_period = 1; if (perf_pmu__has_hybrid()) { + struct perf_pmu *pmu = NULL; + __u64 type = PERF_TYPE_RAW; + /* * The same register set is supported among different hybrid PMUs. * Only check the first available one. */ - pmu = list_first_entry(&perf_pmu__hybrid_pmus, typeof(*pmu), hybrid_list); - attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT; + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (pmu->is_core) { + type = pmu->type; + break; + } + } + attr.config |= type << PERF_PMU_TYPE_SHIFT; } event_attr_init(&attr);