From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396AbcBCKPz (ORCPT ); Wed, 3 Feb 2016 05:15:55 -0500 Received: from terminus.zytor.com ([198.137.202.10]:54617 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752921AbcBCKPv (ORCPT ); Wed, 3 Feb 2016 05:15:51 -0500 Date: Wed, 3 Feb 2016 02:15:29 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: linux-kernel@vger.kernel.org, fweisbec@gmail.com, dsahern@gmail.com, hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org, acme@redhat.com, kan.liang@intel.com, wangnan0@huawei.com, mingo@kernel.org, bp@suse.de, adrian.hunter@intel.com, eranian@google.com, mathieu.poirier@linaro.org, jolsa@kernel.org Reply-To: mathieu.poirier@linaro.org, jolsa@kernel.org, adrian.hunter@intel.com, eranian@google.com, mingo@kernel.org, bp@suse.de, wangnan0@huawei.com, acme@redhat.com, kan.liang@intel.com, tglx@linutronix.de, hpa@zytor.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, dsahern@gmail.com, fweisbec@gmail.com In-Reply-To: <20160125212955.GG22501@kernel.org> References: <20160125212955.GG22501@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cpumap: Auto initialize cpu__max_{node,cpu} Git-Commit-ID: 5ac76283b32b116c58e362e99542182ddcfc8262 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5ac76283b32b116c58e362e99542182ddcfc8262 Gitweb: http://git.kernel.org/tip/5ac76283b32b116c58e362e99542182ddcfc8262 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 26 Jan 2016 15:51:46 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jan 2016 16:08:36 -0300 perf cpumap: Auto initialize cpu__max_{node,cpu} Since it was always checking if the initialization was done, use that branch to do the initialization if not done already. With this we reduce the number of exported globals from these files. Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Kan Liang Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Stephane Eranian Cc: Wang Nan Link: http://lkml.kernel.org/r/20160125212955.GG22501@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cpumap.c | 30 ++++++++++++++++++++++++++++++ tools/perf/util/cpumap.h | 32 +++----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index fa93509..9bcf2be 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -8,6 +8,10 @@ #include #include "asm/bug.h" +static int max_cpu_num; +static int max_node_num; +static int *cpunode_map; + static struct cpu_map *cpu_map__default_new(void) { struct cpu_map *cpus; @@ -486,6 +490,32 @@ out: pr_err("Failed to read max nodes, using default of %d\n", max_node_num); } +int cpu__max_node(void) +{ + if (unlikely(!max_node_num)) + set_max_node_num(); + + return max_node_num; +} + +int cpu__max_cpu(void) +{ + if (unlikely(!max_cpu_num)) + set_max_cpu_num(); + + return max_cpu_num; +} + +int cpu__get_node(int cpu) +{ + if (unlikely(cpunode_map == NULL)) { + pr_debug("cpu_map not initialized\n"); + return -1; + } + + return cpunode_map[cpu]; +} + static int init_cpunode_map(void) { int i; diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 71c41b9..81a2562 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -57,37 +57,11 @@ static inline bool cpu_map__empty(const struct cpu_map *map) return map ? map->map[0] == -1 : true; } -int max_cpu_num; -int max_node_num; -int *cpunode_map; - int cpu__setup_cpunode_map(void); -static inline int cpu__max_node(void) -{ - if (unlikely(!max_node_num)) - pr_debug("cpu_map not initialized\n"); - - return max_node_num; -} - -static inline int cpu__max_cpu(void) -{ - if (unlikely(!max_cpu_num)) - pr_debug("cpu_map not initialized\n"); - - return max_cpu_num; -} - -static inline int cpu__get_node(int cpu) -{ - if (unlikely(cpunode_map == NULL)) { - pr_debug("cpu_map not initialized\n"); - return -1; - } - - return cpunode_map[cpu]; -} +int cpu__max_node(void); +int cpu__max_cpu(void); +int cpu__get_node(int cpu); int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, int (*f)(struct cpu_map *map, int cpu, void *data),