diff options
Diffstat (limited to 'tools/lib/perf/include')
| -rw-r--r-- | tools/lib/perf/include/internal/cpumap.h | 18 | ||||
| -rw-r--r-- | tools/lib/perf/include/internal/evlist.h | 5 | ||||
| -rw-r--r-- | tools/lib/perf/include/internal/evsel.h | 4 | ||||
| -rw-r--r-- | tools/lib/perf/include/internal/mmap.h | 5 | ||||
| -rw-r--r-- | tools/lib/perf/include/perf/cpumap.h | 8 | ||||
| -rw-r--r-- | tools/lib/perf/include/perf/evsel.h | 14 | 
6 files changed, 37 insertions, 17 deletions
| diff --git a/tools/lib/perf/include/internal/cpumap.h b/tools/lib/perf/include/internal/cpumap.h index 840d4032587b..581f9ffb4237 100644 --- a/tools/lib/perf/include/internal/cpumap.h +++ b/tools/lib/perf/include/internal/cpumap.h @@ -4,16 +4,30 @@  #include <linux/refcount.h> +/** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */ +struct perf_cpu { +	int cpu; +}; + +/** + * A sized, reference counted, sorted array of integers representing CPU + * numbers. This is commonly used to capture which CPUs a PMU is associated + * with. The indices into the cpumap are frequently used as they avoid having + * gaps if CPU numbers were used. For events associated with a pid, rather than + * a CPU, a single dummy map with an entry of -1 is used. + */  struct perf_cpu_map {  	refcount_t	refcnt; +	/** Length of the map array. */  	int		nr; -	int		map[]; +	/** The CPU values. */ +	struct perf_cpu	map[];  };  #ifndef MAX_NR_CPUS  #define MAX_NR_CPUS	2048  #endif -int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu); +int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu);  #endif /* __LIBPERF_INTERNAL_CPUMAP_H */ diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/include/internal/evlist.h index f366dbad6a88..4cefade540bd 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -4,6 +4,7 @@  #include <linux/list.h>  #include <api/fd/array.h> +#include <internal/cpumap.h>  #include <internal/evsel.h>  #define PERF_EVLIST__HLIST_BITS 8 @@ -36,7 +37,7 @@ typedef void  typedef struct perf_mmap*  (*perf_evlist_mmap__cb_get_t)(struct perf_evlist*, bool, int);  typedef int -(*perf_evlist_mmap__cb_mmap_t)(struct perf_mmap*, struct perf_mmap_param*, int, int); +(*perf_evlist_mmap__cb_mmap_t)(struct perf_mmap*, struct perf_mmap_param*, int, struct perf_cpu);  struct perf_evlist_mmap_ops {  	perf_evlist_mmap__cb_idx_t	idx; @@ -127,5 +128,5 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist,  void perf_evlist__reset_id_hash(struct perf_evlist *evlist); -void __perf_evlist__set_leader(struct list_head *list); +void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader);  #endif /* __LIBPERF_INTERNAL_EVLIST_H */ diff --git a/tools/lib/perf/include/internal/evsel.h b/tools/lib/perf/include/internal/evsel.h index 1f3eacbad2e8..cfc9ebd7968e 100644 --- a/tools/lib/perf/include/internal/evsel.h +++ b/tools/lib/perf/include/internal/evsel.h @@ -6,8 +6,8 @@  #include <linux/perf_event.h>  #include <stdbool.h>  #include <sys/types.h> +#include <internal/cpumap.h> -struct perf_cpu_map;  struct perf_thread_map;  struct xyarray; @@ -27,7 +27,7 @@ struct perf_sample_id {  	* queue number.  	*/  	int			 idx; -	int			 cpu; +	struct perf_cpu		 cpu;  	pid_t			 tid;  	/* Holds total ID period value for PERF_SAMPLE_READ processing. */ diff --git a/tools/lib/perf/include/internal/mmap.h b/tools/lib/perf/include/internal/mmap.h index 5e3422f40ed5..5a062af8e9d8 100644 --- a/tools/lib/perf/include/internal/mmap.h +++ b/tools/lib/perf/include/internal/mmap.h @@ -6,6 +6,7 @@  #include <linux/refcount.h>  #include <linux/types.h>  #include <stdbool.h> +#include <internal/cpumap.h>  /* perf sample has 16 bits size limit */  #define PERF_SAMPLE_MAX_SIZE (1 << 16) @@ -24,7 +25,7 @@ struct perf_mmap {  	void			*base;  	int			 mask;  	int			 fd; -	int			 cpu; +	struct perf_cpu		 cpu;  	refcount_t		 refcnt;  	u64			 prev;  	u64			 start; @@ -46,7 +47,7 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map);  void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev,  		     bool overwrite, libperf_unmap_cb_t unmap_cb);  int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, -		    int fd, int cpu); +		    int fd, struct perf_cpu cpu);  void perf_mmap__munmap(struct perf_mmap *map);  void perf_mmap__get(struct perf_mmap *map);  void perf_mmap__put(struct perf_mmap *map); diff --git a/tools/lib/perf/include/perf/cpumap.h b/tools/lib/perf/include/perf/cpumap.h index 7c27766ea0bf..15b8faafd615 100644 --- a/tools/lib/perf/include/perf/cpumap.h +++ b/tools/lib/perf/include/perf/cpumap.h @@ -3,11 +3,10 @@  #define __LIBPERF_CPUMAP_H  #include <perf/core.h> +#include <perf/cpumap.h>  #include <stdio.h>  #include <stdbool.h> -struct perf_cpu_map; -  LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);  LIBPERF_API struct perf_cpu_map *perf_cpu_map__default_new(void);  LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); @@ -16,10 +15,11 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);  LIBPERF_API struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig,  						     struct perf_cpu_map *other);  LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); -LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); +LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);  LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);  LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map); -LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map); +LIBPERF_API struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map); +LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_cpu cpu);  #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)		\  	for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);	\ diff --git a/tools/lib/perf/include/perf/evsel.h b/tools/lib/perf/include/perf/evsel.h index 60eae25076d3..2a9516b42d15 100644 --- a/tools/lib/perf/include/perf/evsel.h +++ b/tools/lib/perf/include/perf/evsel.h @@ -4,6 +4,8 @@  #include <stdint.h>  #include <perf/core.h> +#include <stdbool.h> +#include <linux/types.h>  struct perf_evsel;  struct perf_event_attr; @@ -26,18 +28,20 @@ LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);  LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,  				 struct perf_thread_map *threads);  LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); -LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu); +LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu_map_idx);  LIBPERF_API int perf_evsel__mmap(struct perf_evsel *evsel, int pages);  LIBPERF_API void perf_evsel__munmap(struct perf_evsel *evsel); -LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu, int thread); -LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, +LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu_map_idx, int thread); +LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int thread,  				 struct perf_counts_values *count);  LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); -LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu); +LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx);  LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); -LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu); +LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu_map_idx);  LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);  LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);  LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel); +LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count, +					   bool scale, __s8 *pscaled);  #endif /* __LIBPERF_EVSEL_H */ |