aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-04-12 09:29:25 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-13 09:11:50 -0400
commite632aa69c919462a7f93c8799b97c8a9ddd48fc2 (patch)
tree270631decb16effe6e052ac82785737227d92e15
parent3407df8bbc3a91d9aa4910130026ab6b3a261b87 (diff)
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>
-rw-r--r--tools/perf/util/cpumap.c12
-rw-r--r--tools/perf/util/cpumap.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 9bcf2bed3a6d..02d801670f30 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -587,3 +587,15 @@ int cpu__setup_cpunode_map(void)
587 closedir(dir1); 587 closedir(dir1);
588 return 0; 588 return 0;
589} 589}
590
591bool cpu_map__has(struct cpu_map *cpus, int cpu)
592{
593 int i;
594
595 for (i = 0; i < cpus->nr; ++i) {
596 if (cpus->map[i] == cpu)
597 return true;
598 }
599
600 return false;
601}
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index 81a2562aaa2b..1a0a35073ce1 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -66,4 +66,6 @@ int cpu__get_node(int cpu);
66int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, 66int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
67 int (*f)(struct cpu_map *map, int cpu, void *data), 67 int (*f)(struct cpu_map *map, int cpu, void *data),
68 void *data); 68 void *data);
69
70bool cpu_map__has(struct cpu_map *cpus, int cpu);
69#endif /* __PERF_CPUMAP_H */ 71#endif /* __PERF_CPUMAP_H */