소스 검색

perf cpu_map: Add has() method

Adding cpu_map__has() to return bool of cpu presence in cpus map.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460467771-26532-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Jiri Olsa 9 년 전
부모
커밋
e632aa69c9
2개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      tools/perf/util/cpumap.c
  2. 2 0
      tools/perf/util/cpumap.h

+ 12 - 0
tools/perf/util/cpumap.c

@@ -587,3 +587,15 @@ int cpu__setup_cpunode_map(void)
 	closedir(dir1);
 	closedir(dir1);
 	return 0;
 	return 0;
 }
 }
+
+bool cpu_map__has(struct cpu_map *cpus, int cpu)
+{
+	int i;
+
+	for (i = 0; i < cpus->nr; ++i) {
+		if (cpus->map[i] == cpu)
+			return true;
+	}
+
+	return false;
+}

+ 2 - 0
tools/perf/util/cpumap.h

@@ -66,4 +66,6 @@ int cpu__get_node(int cpu);
 int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
 int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
 		       int (*f)(struct cpu_map *map, int cpu, void *data),
 		       int (*f)(struct cpu_map *map, int cpu, void *data),
 		       void *data);
 		       void *data);
+
+bool cpu_map__has(struct cpu_map *cpus, int cpu);
 #endif /* __PERF_CPUMAP_H */
 #endif /* __PERF_CPUMAP_H */