Skip to contentSkip to conversation

perf cpumap: Migrate to libperf cpumap api

PATCH New tangmeng 1 participant 1 message Feb 17, 2022 perf events

lore
Share & tools
lore

tangmeng

author
#0 lore raw

PATCH 1/1 perf cpumap: Migrate to libperf cpumap api

Switch from directly accessing the perf_cpu_map__cpu to using the appropriate libperf API when possible. Using the API simplifies the job of refactoring use of perf_cpu_map__cpu.

---
 tools/perf/util/cpumap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/cpumap.c +4 -3
index 12b2243222b0..986d580d8984 100644
@@ -508,17 +508,18 @@ size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size)
 						"%s%d", COMMA,
 						map->map[i].cpu);
 			}
-		} else if (((i - start) != (cpu.cpu - map->map[start].cpu)) || last) {
+		} else if (((i - start) != (cpu.cpu - perf_cpu_map__cpu(map, start).cpu)) || last) {
 			int end = i - 1;
 
 			if (start == end) {
 				ret += snprintf(buf + ret, size - ret,
 						"%s%d", COMMA,
-						map->map[start].cpu);
+						perf_cpu_map__cpu(map, start).cpu);
 			} else {
 				ret += snprintf(buf + ret, size - ret,
 						"%s%d-%d", COMMA,
-						map->map[start].cpu, map->map[end].cpu);
+						perf_cpu_map__cpu(map, start).cpu,
+						perf_cpu_map__cpu(map, end).cpu);
 			}
 			first = false;
 			start = i;
Signature · 1 line
2.20.1