aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/cpumap.c13
1 files 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)
188 if (map) { 188 if (map) {
189 unsigned i; 189 unsigned i;
190 190
191 for (i = 0; i < cpus->nr; i++) 191 for (i = 0; i < cpus->nr; i++) {
192 map->map[i] = (int)cpus->cpu[i]; 192 /*
193 * Special treatment for -1, which is not real cpu number,
194 * and we need to use (int) -1 to initialize map[i],
195 * otherwise it would become 65535.
196 */
197 if (cpus->cpu[i] == (u16) -1)
198 map->map[i] = -1;
199 else
200 map->map[i] = (int) cpus->cpu[i];
201 }
193 } 202 }
194 203
195 return map; 204 return map;