Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1302608
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/3] perf tools: Fix cpu conversion in cpu_map__from_entries |
| Date | 2016-01-06 12:00 +0100 |
| Message-ID | <qNTYU-8si-45@gated-at.bofh.it> (permalink) |
| References | <qNTYS-8si-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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).
Link: http://lkml.kernel.org/n/tip-6t5lp407ca76zlikz9rl2lcm@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
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 a0717b93d8f5..fa935093a599 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;
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
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