From patchwork Fri May 26 21:53:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13257423 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 0F5F6C77B73 for ; Fri, 26 May 2023 23:05:57 +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=nFcN+Vr4lbNOvT44fzOb1/VeDbMQlWLhc7x8srOXeMs=; b=buKnGG3AZpj8P+ EOQRAY6bAmmnzmcxTrITfQOz0GyiCNc4c+HzbJve4THBtmqVgwwx4lvP6ZuapNiEexDno9GfqX8sJ o6CgcAuDcAr/n9P7uWEaPHxNH8qG7CNfD7xFAlLin1rkTjLOc2RfRm/KEfYO0fBTwKX2/Er3N04hn qXdDZLQDzVy4ryYGhWwKGhjLL74dm46x1pOhY9ByVWM8s23DcJ1j7ldTFiIXtiymllPUA/IUfz5cJ y+gxG17ptyP68mvfrnxNvnYJZzXxAWJb4byOGjK0wNchSjAXtBABzIj4KDOSMBoDx9yf+whUNMYy7 lDVVsa03wktfK6vhvjZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2gVD-004EpP-1U; Fri, 26 May 2023 23:05:43 +0000 Received: from mail-yb1-f201.google.com ([209.85.219.201]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2fOI-0042zH-0H for linux-arm-kernel@lists.infradead.org; Fri, 26 May 2023 21:54:31 +0000 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-ba8c3186735so2605245276.3 for ; Fri, 26 May 2023 14:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138065; x=1687730065; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=zl5H/LAaMs6H1Jjaws3sJN4knTClvax7RvoNDB4HmA4=; b=lkHeOxJXxITrtWC/Otgvuj9osz7kLh5qCEQEF4jM+7E0xr2PpA+cOLlZ9b5Zyiw2P2 vAM/ZhA1uVAMDxMCpPMV6dcien+7D8BM/xk665SM5OmYVqMbSjf9RPqOsQYL8e4Znqe8 Rah+SvNQxwtRUgbCM80haR4iLZ7L1oNvi7WXO61FLRifnetM4F7pxAb+K3HI0JCt1EVB Bobn3+3JPiDocFSoyZcej7VImVFmRSS4ZYOOP+owc3u5eF32Y/8J+5K21zy0BN/C/jxR hms9z9Dglo/Flf37yW09lDCcRBJ521AFqIPTPDNI4nq4H//bTKrg7NRLKlxNOwP0Ldpu 0CSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138065; x=1687730065; 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=zl5H/LAaMs6H1Jjaws3sJN4knTClvax7RvoNDB4HmA4=; b=AXU8gaEMeHvQQTXVUDUEj6XCMDl6PUTT3k7qyW6iGxOVHHf8py7E5F0RwVGaFB39xV BU2dYYCx24DDBxpoxPKZ+ZT7MqF15iRp8ECLw96zEnqYZ1kosfsLmrDplvJkcm3km0oO nRTQxXo63IaS0/Dg2ZjwdJzfQSU9r7YsktAEyF3FhKc8AFMKRg+BbYt1lIN9yzXAYBya hOQxZ3pRfVl96ghzC5i46iFppKU2EWL3iVEfJmsMXay3YmG3rvMJXL7nzTrcgERKJAwq vWEojNXEBzE/6kZbbNU6QGdCAgiYJaSr8Bb8CgMtPQ7+2hBGR9KRHAvTk30L4B0WfxVW lzww== X-Gm-Message-State: AC+VfDxXaqacleiB4l14yMiM4ceSltBM8AqrB6c4hm50ullaDmzYsz29 Krho8ETP+my9VfY5ubTpQP3FCEfbAx8V X-Google-Smtp-Source: ACHHUZ6Yw0OVQSwW5J0Snbt6TPuLc2in9MIppxGHwbx359iQrDoRDhBWkjN3g+LvKkjO3+0H/mlYB2Ay03zj X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:9191:0:b0:bab:a1e6:c87d with SMTP id w17-20020a259191000000b00baba1e6c87dmr1249182ybl.4.1685138065583; Fri, 26 May 2023 14:54:25 -0700 (PDT) Date: Fri, 26 May 2023 14:53:40 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-6-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 05/35] perf pmu: Detect ARM and hybrid PMUs with sysfs 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-20230526_145430_123597_85F481F1 X-CRM114-Status: GOOD ( 17.22 ) 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 is_arm_pmu_core detects a core PMU via the presence of a "cpus" file rather than a "cpumask" file. This pattern holds for hybrid PMUs so rename the function and remove redundant perf_pmu__is_hybrid tests. Add a new helper is_pmu_hybrid similar to is_pmu_core. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/pmu.c | 29 ++++++++++++++++++----------- tools/perf/util/pmu.h | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index f4f0afbc391c..7392cec725bf 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -643,12 +643,14 @@ static char *pmu_id(const char *name) return str; } -/* - * PMU CORE devices have different name other than cpu in sysfs on some - * platforms. - * Looking for possible sysfs files to identify the arm core device. +/** + * is_sysfs_pmu_core() - PMU CORE devices have different name other than cpu in + * sysfs on some platforms like ARM or Intel hybrid. Looking for + * possible the cpus file in sysfs files to identify whether this is a + * core device. + * @name: The PMU name such as "cpu_atom". */ -static int is_arm_pmu_core(const char *name) +static int is_sysfs_pmu_core(const char *name) { char path[PATH_MAX]; @@ -814,7 +816,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu, struct pmu_add_cpu_aliases_map_data data = { .head = head, .name = pmu->name, - .cpu_name = is_arm_pmu_core(pmu->name) ? pmu->name : "cpu", + .cpu_name = is_sysfs_pmu_core(pmu->name) ? pmu->name : "cpu", .pmu = pmu, }; @@ -1647,22 +1649,27 @@ static int cmp_sevent(const void *a, const void *b) bool is_pmu_core(const char *name) { - return !strcmp(name, "cpu") || is_arm_pmu_core(name); + return !strcmp(name, "cpu") || is_sysfs_pmu_core(name); +} + +bool is_pmu_hybrid(const char *name) +{ + return !strcmp(name, "cpu_atom") || !strcmp(name, "cpu_core"); } bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu) { - return is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name); + return is_pmu_core(pmu->name); } bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu) { - return is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name); + return is_pmu_core(pmu->name); } bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu) { - return !perf_pmu__is_hybrid(pmu->name); + return !is_pmu_hybrid(pmu->name); } static bool pmu_alias_is_duplicate(struct sevent *alias_a, @@ -1716,7 +1723,7 @@ void print_pmu_events(const struct print_callbacks *print_cb, void *print_state) pmu = NULL; j = 0; while ((pmu = perf_pmu__scan(pmu)) != NULL) { - bool is_cpu = is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name); + bool is_cpu = is_pmu_core(pmu->name); list_for_each_entry(event, &pmu->aliases, list) { aliases[j].event = event; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 0e0cb6283594..f50919f1b34c 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -220,6 +220,7 @@ void perf_pmu__del_formats(struct list_head *formats); struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); bool is_pmu_core(const char *name); +bool is_pmu_hybrid(const char *name); bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu); bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu); bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu);