From patchwork Sat May 27 07:21: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: 13257548 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 A9D1FC7EE2F for ; Sat, 27 May 2023 07:23: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: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=kmB8IWyMrAFT4F m1dT/oL4YrMv8sPRgpRG3Cn43ajmBfrFR1w4vD1BuT/7jhuSy23Td4MxrJfB1lzFAZ6QxQz3lj5cT E1fg4h0qezmUZFBORpv+2jDlK4C92zMwPmrbObV3MJwzNQalFIeGl34p8DCWykZ6+NRBsmXOwNbMn 5as9kPy8di/NUT20oazoIP75Shpm/6M5pzB8w793Z7O3oS0Cz8AdeJC94wM1baqJ+LCKZktAmX09S PXWivwbCD+gzwFfAdcrdsYwoKfQIcHh9lNRLcyUvmAV4BC3/htoADHek4CWLmcZWe+XUZkmr1ydS5 +burIxC44x2RSXpfWMZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2oGK-0057EX-0j; Sat, 27 May 2023 07:22:52 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2oGB-005792-01 for linux-arm-kernel@lists.infradead.org; Sat, 27 May 2023 07:22:45 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5657f376d8dso37822307b3.2 for ; Sat, 27 May 2023 00:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685172162; x=1687764162; 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=izxX1osE27tCWV0OzJi+hTySjyCv62aYDAMrZ/xEIVznRxWgrSVPb/40HLjHaotabb Y1WjfQ7m5cMnGVw7wfQMFD6XKxOaVEsO0jaFcpdgK3I0s5s1oi9nXiY0xuFW2jouex1B zaG96feJeImRD/nTuaKK4IhLCRAE+xhc09+5DaikPJeJ/ihMTbPvES4HrtmLFbAqkerf wJM8gmOzsOp7QKKfQW0BSdUH64EaoUNK24pUUQPfdZ4NweR8BBmZ5XWYdxSHCTAUPd/x OoDofjKzLiLtwlxatWHQzSM9OK3TARBzT3U7bNEYiLLAqqdifF+OUQK+B6POjIcMlLIm pBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685172162; x=1687764162; 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=NTX/YyKWgW7a63hIS6eIItZVYn3o7rHQytWFpfPg90MFik3QerIP5yakcBdFwmVQFi 2ObNhiyirESldSjs83FYVHhOL8lEaaw4yVlXh9UUeSGL4B/Ir6LUIVLVPY3aMx+BC5uR u7yRigJmThx9ZEhs2E6+dIW0Sv1RWqpv4hpoCNW+LwWx5TLEOf3IHF3SyO+kZy6IR+vx QKM8q0LCl9J3w9JxZxPKYVgwJTnHtuum0QPEMUSZLKLrnlGW2colXWZ9fPh/oRauLVMH J4LFSO7vu4ZM3tspHiZkk+SXIK7+3Yu7s65sYWIBk6qrnYE2UtZHh1z12LPzBlQ1CvLd QwOA== X-Gm-Message-State: AC+VfDxbRZMeiYhHJx0AD5h1Yy1Lx1LNfEY9k3IFG9A1v4hUi5OEsnkK xazxGYtDoq8btD+IuRhojav/PsFgXh4A X-Google-Smtp-Source: ACHHUZ5G9WGtp0OnJwUzf+KtanBkWlscLf5i0qI04IEzVz12+3i0Lf2rmeQtbSTG9y2ZWnRCWuyDq8prE3K4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:8211:0:b0:ba6:e7ee:bb99 with SMTP id q17-20020a258211000000b00ba6e7eebb99mr2344524ybk.12.1685172161878; Sat, 27 May 2023 00:22:41 -0700 (PDT) Date: Sat, 27 May 2023 00:21:40 -0700 In-Reply-To: <20230527072210.2900565-1-irogers@google.com> Message-Id: <20230527072210.2900565-5-irogers@google.com> Mime-Version: 1.0 References: <20230527072210.2900565-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v5 04/34] 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-20230527_002243_044429_91E1D83D X-CRM114-Status: GOOD ( 16.70 ) 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);