From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Kan Liang <kan.liang@intel.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 26/26] perf cpumap: Auto initialize cpu__max_{node,cpu}
Date: Tue, 26 Jan 2016 16:19:15 -0300 [thread overview]
Message-ID: <1453835955-14224-27-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1453835955-14224-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
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 <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20160125212955.GG22501@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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 fa935093a599..9bcf2bed3a6d 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -8,6 +8,10 @@
#include <linux/bitmap.h>
#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 71c41b9efabb..81a2562aaa2b 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),
--
2.5.0
prev parent reply other threads:[~2016-01-26 19:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 19:18 [PATCH 00/26] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 01/26] perf pmu: Fix misleadingly indented assignment (whitespace) Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 02/26] perf symbols: Do not read symbols/data from device files Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 03/26] perf stat: Making several helper functions static Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 04/26] perf hists: Remove parent filter check in DSO filter function Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 05/26] perf hists: Cleanup filtering functions Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 06/26] perf tools: Document the perf sysctls Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 07/26] perf annotate: Rename 'colors.code' to 'colors.jump_arrows' Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 08/26] perf config: Document variables for 'colors' section in man page Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 09/26] perf config: Document variables for 'tui' and 'gtk' sections " Arnaldo Carvalho de Melo
2016-01-26 19:18 ` [PATCH 10/26] perf config: Document 'buildid.dir' variable " Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 11/26] perf config: Document variables for 'annotate' section " Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 12/26] perf config: Document 'hist.percentage' variable " Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 13/26] perf sort: Provide a way to find out if per-thread bucketing is in place Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 14/26] perf hists browser: Only 'Zoom into thread' only when sort order has 'pid' Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 15/26] perf hists browser: Only offer symbol scripting when a symbol is under the cursor Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 16/26] perf hists browser: Offer 'Zoom into DSO'/'Map details' only when sort order has 'dso' Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 17/26] perf hists browser: Be a bit more strict about presenting CPU socket zoom Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 18/26] perf hists browser: Offer non-symbol specific menu options for --sort without 'sym' Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 19/26] perf machine: Introduce machine__find_kernel_symbol_by_name() Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 20/26] perf test: Fixup aliases checking in the 'vmlinux matches kallsyms' test Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 21/26] perf test: Add libbpf relocation checker Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 22/26] perf bpf: Check relocation target section Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 23/26] tools build: Allow subprojects select all feature checkers Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 24/26] perf build: Select all feature checkers for feature-dump Arnaldo Carvalho de Melo
2016-01-26 19:19 ` [PATCH 25/26] perf hists browser: Skip scripting when perf.data file not available Arnaldo Carvalho de Melo
2016-01-26 19:19 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453835955-14224-27-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=bp@suse.de \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).