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 8183AC4332F for ; Thu, 30 Dec 2021 07:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236946AbhL3HU6 (ORCPT ); Thu, 30 Dec 2021 02:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237046AbhL3HUy (ORCPT ); Thu, 30 Dec 2021 02:20:54 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8748DC06173E for ; Wed, 29 Dec 2021 23:20:54 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id b144-20020a253496000000b0060bddc72114so24590858yba.4 for ; Wed, 29 Dec 2021 23:20:54 -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=0PQ2wkiHIZCukUmO6iPoQYJEB6vBau09xCeEdVn1F2A=; b=qNZLdZrEdI08X5vGbvkJOSqp0tbLm3QgzHLR6GG/e8QeH+QcM84H0tjMudV5532Zga 92Xr/S4p8ncKx4fHOBi+9R6pyEcMj9vfpyTPZ2S0tJBfarzgCILF7E4mvNTVt6IVx80x elvnyxEzK64OyjlN+ltkIwhaRW+J7YHTuLnSxT4HeSd6BnqVbt2oyKfn+QlACdBIIEhz T8gFHyQzKIQ8845mWYK2OOdcy08xO1ucxB234FksPqc0rGTKwSRjCQOLAgjstbIOg5c/ ZVtU6GQFlakYUutxT/bdOh4HZ5PqS1oSuL1wo6zaRMJR0GDLu7BqE5dWmvm4uFfH+zNP oZGw== 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=0PQ2wkiHIZCukUmO6iPoQYJEB6vBau09xCeEdVn1F2A=; b=ByDa3HlP2STBLHckwiWx0FTGgSEaUKV8Esi4P/rx7VHYdC1DSNwvc21YPoSJDHWmFf dqrGTF2UQ73tuVZ+2YY1xcQ1g79dAR0ZK/wz1FR67M7u+77RXCLcq/NqFoI5A2Q8JIHT fWGYvBK3NnpUdx/FoVEvrj4/FthyrTIKDwwWrovJnUJq1PMnVWdKMMmeHi0viJHXYP7M Fi22WE9MuqxDZTYNp2yI9L6P4obtYBWARAUo4OW7wQIjXGKt3e+FIB/IozSycZqc+mD8 cCZkLMYuVjjiFdn0sXT4dmPyYpUPrjdcniB1d9nPovEKGgVhjh5axchdsugskgBUkU5E EUYA== X-Gm-Message-State: AOAM5320BNL0QpflWarjxDqLz+H8BK1aTdNt7+T9DYEVPORgRyfJat2S pDhyVa/gGNSG4ctJftXitzVpXcSLEsUN X-Google-Smtp-Source: ABdhPJyk7eLr3v7GGHVTj3b0Fg8b8rE03/8EKwtkrKbbkLlkeWKRJLo0uuewYi/mOmaPzFLOBfVLnCEveLRm X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:31c4:9539:dba1:a82b]) (user=irogers job=sendgmr) by 2002:a05:6902:1501:: with SMTP id q1mr44908502ybu.580.1640848853774; Wed, 29 Dec 2021 23:20:53 -0800 (PST) Date: Wed, 29 Dec 2021 23:19:48 -0800 In-Reply-To: <20211230072030.302559-1-irogers@google.com> Message-Id: <20211230072030.302559-8-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 06/48] perf cpumap: Switch cpu_map__build_map to cpu function 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid error prone cpu_map + idx variant. Remove now unused functions. Reviewed-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 28 ++++------------------------ tools/perf/util/cpumap.c | 12 ++++++------ tools/perf/util/cpumap.h | 2 +- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 9791ae9b1a53..6b985abaa2d2 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1504,11 +1504,6 @@ static struct aggr_cpu_id perf_env__get_socket_aggr_by_cpu(int cpu, void *data) return id; } -static struct aggr_cpu_id perf_env__get_socket(struct perf_cpu_map *map, int idx, void *data) -{ - return perf_env__get_socket_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data); -} - static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data) { struct perf_env *env = data; @@ -1527,11 +1522,6 @@ static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data) return id; } -static struct aggr_cpu_id perf_env__get_die(struct perf_cpu_map *map, int idx, void *data) -{ - return perf_env__get_die_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data); -} - static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data) { struct perf_env *env = data; @@ -1551,11 +1541,6 @@ static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data) return id; } -static struct aggr_cpu_id perf_env__get_core(struct perf_cpu_map *map, int idx, void *data) -{ - return perf_env__get_core_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data); -} - static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data) { struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id(); @@ -1564,33 +1549,28 @@ static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data) return id; } -static struct aggr_cpu_id perf_env__get_node(struct perf_cpu_map *map, int idx, void *data) -{ - return perf_env__get_node_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data); -} - static int perf_env__build_socket_map(struct perf_env *env, struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp) { - return cpu_map__build_map(cpus, sockp, perf_env__get_socket, env); + return cpu_map__build_map(cpus, sockp, perf_env__get_socket_aggr_by_cpu, env); } static int perf_env__build_die_map(struct perf_env *env, struct perf_cpu_map *cpus, struct cpu_aggr_map **diep) { - return cpu_map__build_map(cpus, diep, perf_env__get_die, env); + return cpu_map__build_map(cpus, diep, perf_env__get_die_aggr_by_cpu, env); } static int perf_env__build_core_map(struct perf_env *env, struct perf_cpu_map *cpus, struct cpu_aggr_map **corep) { - return cpu_map__build_map(cpus, corep, perf_env__get_core, env); + return cpu_map__build_map(cpus, corep, perf_env__get_core_aggr_by_cpu, env); } static int perf_env__build_node_map(struct perf_env *env, struct perf_cpu_map *cpus, struct cpu_aggr_map **nodep) { - return cpu_map__build_map(cpus, nodep, perf_env__get_node, env); + return cpu_map__build_map(cpus, nodep, perf_env__get_node_aggr_by_cpu, env); } static struct aggr_cpu_id perf_stat__get_socket_file(struct perf_stat_config *config __maybe_unused, diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 49fba2c53822..feaf34b25efc 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -163,7 +163,7 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer) } int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, - struct aggr_cpu_id (*f)(struct perf_cpu_map *map, int cpu, void *data), + struct aggr_cpu_id (*f)(int cpu, void *data), void *data) { int nr = cpus->nr; @@ -178,7 +178,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, c->nr = 0; for (cpu = 0; cpu < nr; cpu++) { - s1 = f(cpus, cpu, data); + s1 = f(cpu, data); for (s2 = 0; s2 < c->nr; s2++) { if (cpu_map__compare_aggr_cpu_id(s1, c->map[s2])) break; @@ -290,22 +290,22 @@ struct aggr_cpu_id cpu_map__get_node(struct perf_cpu_map *map, int idx, void *da int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp) { - return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL); + return cpu_map__build_map(cpus, sockp, cpu_map__get_socket_aggr_by_cpu, NULL); } int cpu_map__build_die_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **diep) { - return cpu_map__build_map(cpus, diep, cpu_map__get_die, NULL); + return cpu_map__build_map(cpus, diep, cpu_map__get_die_aggr_by_cpu, NULL); } int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **corep) { - return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL); + return cpu_map__build_map(cpus, corep, cpu_map__get_core_aggr_by_cpu, NULL); } int cpu_map__build_node_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **numap) { - return cpu_map__build_map(cpus, numap, cpu_map__get_node, NULL); + return cpu_map__build_map(cpus, numap, cpu_map__get_node_aggr_by_cpu, NULL); } /* setup simple routines to easily access node numbers given a cpu number */ diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index c62d67704425..9648816c4255 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -63,7 +63,7 @@ int cpu__max_present_cpu(void); int cpu__get_node(int cpu); int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, - struct aggr_cpu_id (*f)(struct perf_cpu_map *map, int cpu, void *data), + struct aggr_cpu_id (*f)(int cpu, void *data), void *data); int cpu_map__cpu(struct perf_cpu_map *cpus, int idx); -- 2.34.1.448.ga2b2bfdf31-goog