summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/cpumap.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-01-15 21:11:10 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-01-15 21:41:25 +0100
commit37be585807cb9a810f8395c39c4ee7bdbdc7b0dc (patch)
tree4cef1343ee394264a1190bbb9b6d7b6b4e84fd4b /tools/perf/util/cpumap.h
parentperf metric: Fix metric_leader (diff)
downloadlinux-37be585807cb9a810f8395c39c4ee7bdbdc7b0dc.tar.xz
linux-37be585807cb9a810f8395c39c4ee7bdbdc7b0dc.zip
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 <andi@firstfloor.org> Acked-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/cpumap.h')
-rw-r--r--tools/perf/util/cpumap.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index afc15027d678..0d3c2006a15d 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 <stdbool.h>
#include <stdio.h>
#include <stdbool.h>
#include <internal/cpumap.h>
@@ -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.