Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1305301
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [tip:perf/core] perf cpumap: Fix cpu conversion in cpu_map__from_entries |
| Date | 2016-01-09 17:40 +0100 |
| Message-ID | <qP4Iz-87R-51@gated-at.bofh.it> (permalink) |
| References | <qNTYU-8si-45@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Commit-ID: 15d2b9956b41ffb5961b897bf61cdc09f722dfbf
Gitweb: http://git.kernel.org/tip/15d2b9956b41ffb5961b897bf61cdc09f722dfbf
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 6 Jan 2016 11:49:55 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:16 -0300
perf cpumap: Fix cpu conversion in cpu_map__from_entries
We can't convert u16 cpu_map_entries::cpu[x] value directly to int,
because it could hold -1, which would be converted as 65535.
Adding special treatment for -1, which is not real cpu number, to be
converted to (int -1).
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452077397-31958-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/cpumap.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index a0717b9..fa93509 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -188,8 +188,17 @@ static struct cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus)
if (map) {
unsigned i;
- for (i = 0; i < cpus->nr; i++)
- map->map[i] = (int)cpus->cpu[i];
+ for (i = 0; i < cpus->nr; i++) {
+ /*
+ * Special treatment for -1, which is not real cpu number,
+ * and we need to use (int) -1 to initialize map[i],
+ * otherwise it would become 65535.
+ */
+ if (cpus->cpu[i] == (u16) -1)
+ map->map[i] = -1;
+ else
+ map->map[i] = (int) cpus->cpu[i];
+ }
}
return map;
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv9 0/3] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2016-01-06 12:00 +0100
[PATCH 1/3] perf tools: Fix cpu conversion in cpu_map__from_entries Jiri Olsa <jolsa@kernel.org> - 2016-01-06 12:00 +0100
[tip:perf/core] perf cpumap: Fix cpu conversion in cpu_map__from_entries tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100
[PATCH 2/3] perf script: Display stat events by default Jiri Olsa <jolsa@kernel.org> - 2016-01-06 12:00 +0100
[tip:perf/core] perf script: Display stat events by default tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100
[PATCH 3/3] perf script: Add stat-cpi.py script Jiri Olsa <jolsa@kernel.org> - 2016-01-06 12:00 +0100
[tip:perf/core] perf script: Add stat-cpi.py script tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100
Re: [PATCHv9 0/3] perf stat: Add scripting support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-06 15:20 +0100
Re: [PATCHv9 0/3] perf stat: Add scripting support Jiri Olsa <jolsa@redhat.com> - 2016-01-06 15:40 +0100
Re: [PATCHv9 0/3] perf stat: Add scripting support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-06 16:10 +0100
Re: [PATCHv9 0/3] perf stat: Add scripting support Jiri Olsa <jolsa@redhat.com> - 2016-01-06 16:40 +0100
csiph-web