[PATCH] perf cpumap: Migrate to libperf cpumap api

tangmeng posted 1 patch 4 years, 4 months ago
tools/perf/util/cpumap.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
[PATCH] perf cpumap: Migrate to libperf cpumap api
Posted by tangmeng 4 years, 4 months ago
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.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 tools/perf/util/cpumap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 12b2243222b0..986d580d8984 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -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;
-- 
2.20.1