Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1584853
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 05/18] perf cpumap: Add cpu__max_present_cpu() |
| Date | 2017-02-20 20:20 +0100 |
| Message-ID | <td1F8-h6-39@gated-at.bofh.it> (permalink) |
| References | <td1vr-dn-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Jan Stancek <jstancek@redhat.com>
Similar to cpu__max_cpu() (which returns the max possible CPU), returns
the max present CPU.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/8ea4601b5cacc49927235b4ebac424bd6eeccb06.1487146877.git.jstancek@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/cpumap.c | 22 ++++++++++++++++++++++
tools/perf/util/cpumap.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 2c0b52264a46..8c7504939113 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -9,6 +9,7 @@
#include "asm/bug.h"
static int max_cpu_num;
+static int max_present_cpu_num;
static int max_node_num;
static int *cpunode_map;
@@ -442,6 +443,7 @@ static void set_max_cpu_num(void)
/* set up default */
max_cpu_num = 4096;
+ max_present_cpu_num = 4096;
mnt = sysfs__mountpoint();
if (!mnt)
@@ -455,6 +457,17 @@ static void set_max_cpu_num(void)
}
ret = get_max_num(path, &max_cpu_num);
+ if (ret)
+ goto out;
+
+ /* get the highest present cpu number for a sparse allocation */
+ ret = snprintf(path, PATH_MAX, "%s/devices/system/cpu/present", mnt);
+ if (ret == PATH_MAX) {
+ pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX);
+ goto out;
+ }
+
+ ret = get_max_num(path, &max_present_cpu_num);
out:
if (ret)
@@ -505,6 +518,15 @@ int cpu__max_cpu(void)
return max_cpu_num;
}
+int cpu__max_present_cpu(void)
+{
+ if (unlikely(!max_present_cpu_num))
+ set_max_cpu_num();
+
+ return max_present_cpu_num;
+}
+
+
int cpu__get_node(int cpu)
{
if (unlikely(cpunode_map == NULL)) {
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index 06bd689f5989..1a0549af8f5c 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -62,6 +62,7 @@ int cpu__setup_cpunode_map(void);
int cpu__max_node(void);
int cpu__max_cpu(void);
+int cpu__max_present_cpu(void);
int cpu__get_node(int cpu);
int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
[PATCH 16/18] perf diff: Add -q/--quiet option Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
[PATCH 12/18] perf record: Add -a as default target Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
[PATCH 15/18] perf report: Add -q/--quiet option Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
Re: [PATCH 11/18] perf stat: Add -a as default target Borislav Petkov <bp@alien8.de> - 2017-02-20 20:20 +0100
Re: [PATCH 11/18] perf stat: Add -a as default target Arnaldo Carvalho de Melo <acme@redhat.com> - 2017-02-20 21:00 +0100
Re: [PATCH 11/18] perf stat: Add -a as default target Borislav Petkov <bp@alien8.de> - 2017-02-20 21:10 +0100
Re: [PATCH 11/18] perf stat: Add -a as default target Jiri Olsa <jolsa@redhat.com> - 2017-02-21 08:50 +0100
[PATCH 11/18] perf stat: Add -a as default target Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
[PATCH 08/18] perf build: Add special fixdep cleaning rule Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
[PATCH 05/18] perf cpumap: Add cpu__max_present_cpu() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:20 +0100
Re: [GIT PULL 00/18] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-02-21 09:10 +0100
csiph-web