Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2543863rwd; Sun, 21 May 2023 23:56:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7lckMknAUbtWhyqZuwi30rfHMSNk5XChdDcoIFlWVGsfYFSC2rkjefBiDU5VjlhVmFX+hT X-Received: by 2002:a05:6a21:6d86:b0:10a:e556:70ec with SMTP id wl6-20020a056a216d8600b0010ae55670ecmr6051484pzb.7.1684738565539; Sun, 21 May 2023 23:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684738565; cv=none; d=google.com; s=arc-20160816; b=XvxwZ3vVHbVCZOkAlcOlkZFGWgbIV1FMrRT0BfFOfddC+rDLH2UZSbckI0+zpQusme dti7BYUF0WT2AR8kwcreO6xWTKRdut8td/gAs82C3I+FPavk+mx0Cq/Awdsuly9wuy46 er9kArOuETn1kSWIeC3K/RvgxlckbXZnLSqAhx8G86DW05GOm3/ymaU0v4eccvc2TEyW kI8dJ7DWF8yrhSKR9CBVHoReIS2V9TnouH286+SmEBbfNoVLJLfjHLWBPxS+okCXKtvt w7+fBLK56pVwbJNUbVhJQqgapxW+BHrD5+1PNiQ9M30uRB5gxvtQse9yQT0xo/vVYFaH yKEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=HtRUH772YtV0qPeVzoZd+sfJkmumkzDNUnRMC3UQCcg=; b=YyGm+hK9BSoVQynnlDm+N9l9/ZhIsm6Rv4UjXRBxKPZ5GIoS28D/TY480QvoQ2uTGK emDNSGiqh2TqedQYb5j+XnzUZWAdSOLF6MNjz8z7HnlAnzyEjhaEHCDqdAuC0+qFWedu e/AwemWf6l37tPZSiLA/wxbMgYv6SrzMmd6SKFX2vfBCtnEd5N28g6YmRoa+/SZIadsF lFjOCHcmhWMtnlaBiRL4PBLMQRVUhdGa3t/XKHZabrTyarOAOjnaVNS6U2gwBj53n5p9 fvX56tzufov7f0kyIpYIXUoZdL4VvWFKC1kzZhHC3oItD6jKCGDkC9fQv0JFQC5pb2Gn S1Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=NNBwSTFI; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x22-20020a656ab6000000b005348af160c2si4357462pgu.216.2023.05.21.23.55.50; Sun, 21 May 2023 23:56:05 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=NNBwSTFI; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjEVGoR (ORCPT + 99 others); Mon, 22 May 2023 02:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbjEVGoC (ORCPT ); Mon, 22 May 2023 02:44:02 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C03718C for ; Sun, 21 May 2023 23:43:49 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba8337a5861so7054936276.0 for ; Sun, 21 May 2023 23:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684737828; x=1687329828; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=HtRUH772YtV0qPeVzoZd+sfJkmumkzDNUnRMC3UQCcg=; b=NNBwSTFIiyCdqGqw2b4i1yq/47LRh1xsrfmZCRo5cZzQEbwSVLZ8pKnE+LfMB0Sv+i K9kzhfBKgcoOUFOTBvVHqvFFLphQylLkC/nFisqyST+/nJXcd8cwaBGE6BgBre+NgYAP WKt/wMtN9hu9fZzdFy/eNrxJVtdBJtabp/zCjiO7E+PCNJF99AkqENLV/v0zcgMAM7QT 4QZfT7Ly7tvupd9MQeK3tVfiSL6GpEJ/YT3Kmx422mU5BI2N5hxtFUvkJVBX+D7vKg9G zBBBVfrfJ4+Wj7flOcPQ3wHBqx2lSGgBPaHrBCo3TETeDdZczX21WOmwgmqPA8WVCZtc xXXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684737828; x=1687329828; 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=HtRUH772YtV0qPeVzoZd+sfJkmumkzDNUnRMC3UQCcg=; b=Vn0MIW6RZrbSZHvwTZ6qxRt3FqZRAuTqGBjp3uAsJyHEaNSIuLk5BCpemKoZRlaWYM QoJ6aK+KhGYWjH1qYLC4p6n4CGG7NYF8DJ4L8DuxJo0zHBqPNpJFSiL4/Q5/0ToCZfnk txUGJfO4oXk+uyhnYm8rjqMXHF2mhECj3NB+IKTNMruVmZdppFeW1s1F+wO1/sMpmHET XjTJwNMiWkixpafKyKLZqNdeyz47r68eMQguhC2wNxetpg5xWPnTdJcrmPDvVRpp5vKT F+jP50mS3DvRfnfxSUVkM7APrsXm6zAtVqIuHxisFXuZP1uwEkYJ+MZB0Te41hNPLZVC hKhA== X-Gm-Message-State: AC+VfDy/Q6RbEpzTg29UgoK+Sah6wWPp6JmKLGMYnjY5PzUnKTKte4kb k0L9zTUMGT9hVcHizd5li2cxAkk9T/Z9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:48d9:8c21:e099:7301]) (user=irogers job=sendgmr) by 2002:a5b:98b:0:b0:ba7:8628:93e2 with SMTP id c11-20020a5b098b000000b00ba7862893e2mr5636237ybq.4.1684737828309; Sun, 21 May 2023 23:43:48 -0700 (PDT) Date: Sun, 21 May 2023 23:43:13 -0700 In-Reply-To: <20230522064330.189127-1-irogers@google.com> Message-Id: <20230522064330.189127-7-irogers@google.com> Mime-Version: 1.0 References: <20230522064330.189127-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v2 06/23] 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 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 --- 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 729b1f166f80..0fa451c60c77 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -640,12 +640,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]; @@ -811,7 +813,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, }; @@ -1649,22 +1651,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, @@ -1718,7 +1725,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 49033bb134f3..99e0273027bf 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); -- 2.40.1.698.g37aff9b760-goog