From patchwork Thu Dec 30 07:19:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12701276 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 ECC13C433F5 for ; Thu, 30 Dec 2021 07:31:11 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1lnbOxs7zXuObDPeUzzSbluHGt7cT9FuRCHoEU970Xo=; b=HI+ARM6G8+7mB+2hIRLDHrRlAr WJE/tiJNh6TJZBZQ+8jKT3dRu1rqrKvgz3vyydK7xVD0BgdxzIR+ya78+HRlSEgFj7tT5ZRLfd4XC UnyLZHTxgL+T8LbUhyNRv+QVHY31B4Z9k28zoHNEMVg/Csd+ANfL29zxAG1RVFZLUIHLb90C5iUbR 5WUWyOfjrCMVIegJjdJW3sAoJKXjXN8znL3a3b1+yIHdho/BZ2vXFyWzfNpK+h5BORyBiP8Pp+iGM AUdhziecNT5zbuRR6vsYLWSte9KdtY8pSO5nyujikVEherepRlWVIgdX1IlYvuX3AJcb32sCTa9nX oUWktpWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2psT-003n1w-Kr; Thu, 30 Dec 2021 07:29:34 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2pkV-003jgZ-Sh for linux-arm-kernel@lists.infradead.org; Thu, 30 Dec 2021 07:21:21 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id q81-20020a252a54000000b0060af1d7e063so28809122ybq.17 for ; Wed, 29 Dec 2021 23:21:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=AifZMWGIyf5BgdMB7L7Gxo1hfuqMZZOHTMlvW2tmWZk=; b=EMrauUzDbodQXwVdpajk++8ACumfHsWw5rnrHEA7W2d3tPfcEG+YABoeFwpYO6R8xD OAYOtmihvhRP8ucbPpYNf/Tk2uO30MPBjWuulUKEgCnNgJ9jM7b8fGpF5RaWioZlsnJU mjWVS+a/ICbzBZAn/PJYynTNsrKaHUAxfM/JoS1qbFl3T3KuvA7GYzN4eMfS1PKlcUU4 PCiHpnwRx/hQe/gqNRKKOpmNjZOpkx6h5UgIGsfY9iZl+75ojkXtaNMSIX56awzBkwUl XzKEpYranyKk9o8NN8RevLYYDm56BjHEfS9nKt0K2NxDzQTWviiw2LGkvUAroUFcSGs9 tXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AifZMWGIyf5BgdMB7L7Gxo1hfuqMZZOHTMlvW2tmWZk=; b=hLl19+a6OJWUBZJdMVCvPpf1AP58ZUBNZXHnxwO1gxvzGTwBNQN8BFjgTEKbgkUdJC 3HqUEwC5BY4ljz+3WGQEfBBZjE4H/hTfaVPnt7WGRj1/5fcloYU+g8MXxZ2Z7QHCNpvg I+8My4ut9wDkgDqqmw3s2qZVV4bknDimbOOmm/FRnC2KrUurJ6h2IEe9abAYh5qM4XNX vU/WzuEjXOjoGrW0yNm3fdTIRAseBzye6NqItr/bCoPDXtJ/Nm05zw+DWoFx/yhtWWt3 OiO2LxYYvf2i9MGKsPSb+tQgn2EvgbJkW0hnCjbe1gFgMYLOpIRLHOIAjzjUGmIYmaao hKdQ== X-Gm-Message-State: AOAM533XSk0wb/4jN9pxg1l7JTrOdxqX+hJWEUrIJPLouw0DEHSkEeRQ 89/YIQOeFeo12uU7IwvpaVbIzwfSzXKs X-Google-Smtp-Source: ABdhPJx5b7oGLyLSZ34IJBsIh09xOeq4tVXz+P/kHZaEMUthp6EESwZO6wRsfj1XpyJiLhMx1UViLAGDXLSS X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:31c4:9539:dba1:a82b]) (user=irogers job=sendgmr) by 2002:a05:6902:4f1:: with SMTP id w17mr2969824ybs.647.1640848878567; Wed, 29 Dec 2021 23:21:18 -0800 (PST) Date: Wed, 29 Dec 2021 23:19:58 -0800 In-Reply-To: <20211230072030.302559-1-irogers@google.com> Message-Id: <20211230072030.302559-18-irogers@google.com> Mime-Version: 1.0 References: <20211230072030.302559-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH v3 16/48] perf cpumap: Remove map from function names that don't use a map. From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, zhengjun.xing@intel.com Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211229_232119_969834_D046F895 X-CRM114-Status: GOOD ( 17.81 ) 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 Move to the cpu name and document for consistency. Reviewed-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 12 ++++++------ tools/perf/util/cpumap.h | 19 ++++++++++++++++--- tools/perf/util/env.c | 6 +++--- tools/perf/util/stat.c | 4 ++-- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 1626b0991408..e0d7f1da5858 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -126,7 +126,7 @@ static int cpu__get_topology_int(int cpu, const char *name, int *value) return sysfs__read_int(path, value); } -int cpu_map__get_socket_id(int cpu) +int cpu__get_socket_id(int cpu) { int value, ret = cpu__get_topology_int(cpu, "physical_package_id", &value); return ret ?: value; @@ -136,7 +136,7 @@ struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data __maybe_u { struct aggr_cpu_id id = aggr_cpu_id__empty(); - id.socket = cpu_map__get_socket_id(cpu); + id.socket = cpu__get_socket_id(cpu); return id; } @@ -190,7 +190,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, return 0; } -int cpu_map__get_die_id(int cpu) +int cpu__get_die_id(int cpu) { int value, ret = cpu__get_topology_int(cpu, "die_id", &value); @@ -202,7 +202,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data) struct aggr_cpu_id id; int die; - die = cpu_map__get_die_id(cpu); + die = cpu__get_die_id(cpu); /* There is no die_id on legacy system. */ if (die == -1) die = 0; @@ -220,7 +220,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data) return id; } -int cpu_map__get_core_id(int cpu) +int cpu__get_core_id(int cpu) { int value, ret = cpu__get_topology_int(cpu, "core_id", &value); return ret ?: value; @@ -229,7 +229,7 @@ int cpu_map__get_core_id(int cpu) struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data) { struct aggr_cpu_id id; - int core = cpu_map__get_core_id(cpu); + int core = cpu__get_core_id(cpu); /* cpu_map__get_die returns a struct with socket and die set*/ id = cpu_map__get_die_aggr_by_cpu(cpu, data); diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index f849f01c5860..a053bf31a3f0 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -39,11 +39,8 @@ struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data); size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp); -int cpu_map__get_socket_id(int cpu); struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data); -int cpu_map__get_die_id(int cpu); struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data); -int cpu_map__get_core_id(int cpu); struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data); struct aggr_cpu_id cpu_map__get_node_aggr_by_cpu(int cpu, void *data); int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp); @@ -62,6 +59,22 @@ int cpu__max_present_cpu(void); * /sys/devices/system/node/nodeX for the given CPU. */ int cpu__get_node(int cpu); +/** + * cpu__get_socket_id - Returns the socket number as read from + * /sys/devices/system/cpu/cpuX/topology/physical_package_id for the given CPU. + */ +int cpu__get_socket_id(int cpu); +/** + * cpu__get_die_id - Returns the die id as read from + * /sys/devices/system/cpu/cpuX/topology/die_id for the given CPU. + */ +int cpu__get_die_id(int cpu); +/** + * cpu__get_core_id - Returns the core id as read from + * /sys/devices/system/cpu/cpuX/topology/core_id for the given CPU. + */ +int cpu__get_core_id(int cpu); + int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, struct aggr_cpu_id (*f)(int cpu, void *data), diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index b9904896eb97..fd12c0dcaefb 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -302,9 +302,9 @@ int perf_env__read_cpu_topology_map(struct perf_env *env) return -ENOMEM; for (cpu = 0; cpu < nr_cpus; ++cpu) { - env->cpu[cpu].core_id = cpu_map__get_core_id(cpu); - env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu); - env->cpu[cpu].die_id = cpu_map__get_die_id(cpu); + env->cpu[cpu].core_id = cpu__get_core_id(cpu); + env->cpu[cpu].socket_id = cpu__get_socket_id(cpu); + env->cpu[cpu].die_id = cpu__get_die_id(cpu); } env->nr_cpus_avail = nr_cpus; diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 5ed99bcfe91e..5c24aca0968c 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -328,7 +328,7 @@ static int check_per_pkg(struct evsel *counter, if (!(vals->run && vals->ena)) return 0; - s = cpu_map__get_socket_id(cpu); + s = cpu__get_socket_id(cpu); if (s < 0) return -1; @@ -336,7 +336,7 @@ static int check_per_pkg(struct evsel *counter, * On multi-die system, die_id > 0. On no-die system, die_id = 0. * We use hashmap(socket, die) to check the used socket+die pair. */ - d = cpu_map__get_die_id(cpu); + d = cpu__get_die_id(cpu); if (d < 0) return -1;