remarkable-linux/tools/perf/util/cpumap.h
Stephane Eranian 5ac59a8a77 perf tools: Add cpu_map processor socket level functions
This patch adds:
- cpu_map__get_socket: get socked id from cpu
- cpu_map__build_socket_map: build socket map
- cpu_map__socket: gets acutal socket from logical socket

Those functions are used by uncore and processor socket-level
aggregation modes.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1360161962-9675-2-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-02-06 18:09:26 -03:00

38 lines
862 B
C

#ifndef __PERF_CPUMAP_H
#define __PERF_CPUMAP_H
#include <stdio.h>
#include <stdbool.h>
struct cpu_map {
int nr;
int map[];
};
struct cpu_map *cpu_map__new(const char *cpu_list);
struct cpu_map *cpu_map__dummy_new(void);
void cpu_map__delete(struct cpu_map *map);
struct cpu_map *cpu_map__read(FILE *file);
size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
int cpu_map__get_socket(struct cpu_map *map, int idx);
int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp);
static inline int cpu_map__socket(struct cpu_map *sock, int s)
{
if (!sock || s > sock->nr || s < 0)
return 0;
return sock->map[s];
}
static inline int cpu_map__nr(const struct cpu_map *map)
{
return map ? map->nr : 1;
}
static inline bool cpu_map__all(const struct cpu_map *map)
{
return map ? map->map[0] == -1 : true;
}
#endif /* __PERF_CPUMAP_H */