From: Arnaldo Carvalho de Melo Date: Sat, 15 Jan 2022 20:11:10 +0000 (-0300) Subject: perf cpumap: Add is_dummy() method X-Git-Tag: v6.6.17~8376^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37be585807cb9a810f8395c39c4ee7bdbdc7b0dc;p=platform%2Fkernel%2Flinux-rpi.git perf cpumap: Add is_dummy() method Needed to check if a cpu_map is dummy, i.e. not a cpu map at all, for pid monitoring scenarios. This probably needs to move to libperf, but since perf itself is the first and so far only user, leave it at tools/perf/util/. Acked-by: Andi Kleen Acked-by: Ian Rogers Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index afc1502..0d3c200 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -2,6 +2,7 @@ #ifndef __PERF_CPUMAP_H #define __PERF_CPUMAP_H +#include #include #include #include @@ -50,6 +51,15 @@ int cpu__setup_cpunode_map(void); int cpu__max_node(void); struct perf_cpu cpu__max_cpu(void); struct perf_cpu cpu__max_present_cpu(void); + +/** + * cpu_map__is_dummy - Events associated with a pid, rather than a CPU, use a single dummy map with an entry of -1. + */ +static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus) +{ + return cpus->nr == 1 && cpus->map[0].cpu == -1; +} + /** * cpu__get_node - Returns the numa node X as read from * /sys/devices/system/node/nodeX for the given CPU.