Skip to content

Commit

Permalink
perf cpumap: Add is_dummy() method
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 15, 2022
1 parent d3e2bb4 commit 37be585
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/perf/util/cpumap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 37be585

Please sign in to comment.