Skip to content

Commit 37be585

Browse files
committed
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 <[email protected]> Acked-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d3e2bb4 commit 37be585

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/perf/util/cpumap.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef __PERF_CPUMAP_H
33
#define __PERF_CPUMAP_H
44

5+
#include <stdbool.h>
56
#include <stdio.h>
67
#include <stdbool.h>
78
#include <internal/cpumap.h>
@@ -50,6 +51,15 @@ int cpu__setup_cpunode_map(void);
5051
int cpu__max_node(void);
5152
struct perf_cpu cpu__max_cpu(void);
5253
struct perf_cpu cpu__max_present_cpu(void);
54+
55+
/**
56+
* cpu_map__is_dummy - Events associated with a pid, rather than a CPU, use a single dummy map with an entry of -1.
57+
*/
58+
static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus)
59+
{
60+
return cpus->nr == 1 && cpus->map[0].cpu == -1;
61+
}
62+
5363
/**
5464
* cpu__get_node - Returns the numa node X as read from
5565
* /sys/devices/system/node/nodeX for the given CPU.

0 commit comments

Comments
 (0)