From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E25D8EB64DB for ; Thu, 22 Jun 2023 05:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbjFVFDs (ORCPT ); Thu, 22 Jun 2023 01:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbjFVFDq (ORCPT ); Thu, 22 Jun 2023 01:03:46 -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 17B1E199D for ; Wed, 21 Jun 2023 22:03:46 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bd5b8a9d82cso7798640276.0 for ; Wed, 21 Jun 2023 22:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687410225; x=1690002225; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=x8Rsb54/MYGUaB2iRhrucGZnS8r6HVo39FnjfvBr1XU=; b=GpRUf2G0Kjjc8MioX56rzakjdiz2XaTj+A/amagDGFOs4eS0bJAORFDFntoapgIt9K AG9Q/X7yigaaRwdGjSNTjAD9vPnnSxMGLlrDwOfydk+lxX43+Guai4OsLplPRJ882O6D hHm5Nyacar5+Hrp3AlLhQxZZgk7HvmvdUlUp7jO5mnkcrpvZjGChdxImGgdCsRWG/8L+ a/+D/g91D+Ogsp4+zYrQ9Ybr4jFz+2mH3f50sHqjcJyRTvzOgkHFOtKloGIXG63IWMdm UrJnTgT+980It2KL1Jz0B0WyhMN8wzB4eUtrzBWh2Z7n3RAjVYS5xFeDb8ZdUpotebjH 0WAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687410225; x=1690002225; 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=x8Rsb54/MYGUaB2iRhrucGZnS8r6HVo39FnjfvBr1XU=; b=GN2Cf5nWP2HZ4T/nrOHJgUV4f74iI8KMr/HdeA/5cdsgqmb7Pl2fI86fmr1FD7YvsI eL+DapNIP8N5n2QfSwVx5PbmXyorqejep0Y9FPOHUlB3PTepGCs1oR8FzzZsBoNBo5Wj 3IEFKPbdUydL4b4r+eqC+ihoxiwuRI0Ba7OqynutWzWUzFxHK3Wdk49eQMpGEf26XU+A XruEP5fkfk77+iPK6ER0Tg/U2wOTYlx5mATR0NyEXG5xKVNcxKfljI3WuzFVWJ4yUSxU R5IcM3uwsuyXQKd2ahBSwcXa5gO/00X2LAg98dNhdllpdO3K4ISjgE8DOMkU9R8WiT5Q xecg== X-Gm-Message-State: AC+VfDxXR5paaD3x23E2uTpcg/bu6z1uv1aFfdbjCaAyVww9lEENb0T6 nQZkm/7kgoNWs2OQf9iSrc1oNy+V3ZPg X-Google-Smtp-Source: ACHHUZ7ARfJoVAEvnUkQb8tQpVCFdx+usSVxdKSOM+7ibrCp77WpcmrZhsekCA+OnSG5YZJ3g4/sqKxl+fRn X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:91f3:1da5:6427:50d6]) (user=irogers job=sendgmr) by 2002:a25:7346:0:b0:bfe:9259:8f1d with SMTP id o67-20020a257346000000b00bfe92598f1dmr2318249ybc.6.1687410225349; Wed, 21 Jun 2023 22:03:45 -0700 (PDT) Date: Wed, 21 Jun 2023 22:03:29 -0700 In-Reply-To: <20230622050330.3733114-1-irogers@google.com> Message-Id: <20230622050330.3733114-2-irogers@google.com> Mime-Version: 1.0 References: <20230622050330.3733114-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v1 2/2] perf pmu: Remove a hard coded cpu PMU assumption From: Ian Rogers To: Thomas Richter , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org The property of "cpu" when it has no cpu map is true on S390 with the PMU cpum_cf. Rather than maintain a list of such PMUs, reuse the is_core test result from the caller. Signed-off-by: Ian Rogers --- tools/perf/util/pmu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 963c12f910c5..64fa568a5426 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -551,7 +551,7 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias, * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) * may have a "cpus" file. */ -static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name) +static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name, bool is_core) { struct perf_cpu_map *cpus; const char *templates[] = { @@ -575,7 +575,8 @@ static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name) return cpus; } - return !strcmp(name, "cpu") ? perf_cpu_map__get(cpu_map__online()) : NULL; + /* Nothing found, for core PMUs assume this means all CPUs. */ + return is_core ? perf_cpu_map__get(cpu_map__online()) : NULL; } static bool pmu_is_uncore(int dirfd, const char *name) @@ -886,7 +887,8 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char if (!pmu) return NULL; - pmu->cpus = pmu_cpumask(dirfd, name); + pmu->is_core = is_pmu_core(name); + pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core); pmu->name = strdup(name); if (!pmu->name) goto err; @@ -903,7 +905,6 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char } pmu->type = type; - pmu->is_core = is_pmu_core(name); pmu->is_uncore = pmu_is_uncore(dirfd, name); if (pmu->is_uncore) pmu->id = pmu_id(name); -- 2.41.0.162.gfafddb0af9-goog