~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/perf/include/perf/cpumap.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __LIBPERF_CPUMAP_H
  3 #define __LIBPERF_CPUMAP_H
  4 
  5 #include <perf/core.h>
  6 #include <stdio.h>
  7 #include <stdbool.h>
  8 
  9 /** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */
 10 struct perf_cpu {
 11         int cpu;
 12 };
 13 
 14 struct perf_cache {
 15         int cache_lvl;
 16         int cache;
 17 };
 18 
 19 struct perf_cpu_map;
 20 
 21 /**
 22  * perf_cpu_map__new_any_cpu - a map with a singular "any CPU"/dummy -1 value.
 23  */
 24 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new_any_cpu(void);
 25 /**
 26  * perf_cpu_map__new_online_cpus - a map read from
 27  *                                 /sys/devices/system/cpu/online if
 28  *                                 available. If reading wasn't possible a map
 29  *                                 is created using the online processors
 30  *                                 assuming the first 'n' processors are all
 31  *                                 online.
 32  */
 33 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new_online_cpus(void);
 34 /**
 35  * perf_cpu_map__new - create a map from the given cpu_list such as "0-7". If no
 36  *                     cpu_list argument is provided then
 37  *                     perf_cpu_map__new_online_cpus is returned.
 38  */
 39 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
 40 LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file);
 41 LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
 42 LIBPERF_API struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig,
 43                                                      struct perf_cpu_map *other);
 44 LIBPERF_API struct perf_cpu_map *perf_cpu_map__intersect(struct perf_cpu_map *orig,
 45                                                          struct perf_cpu_map *other);
 46 LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
 47 /**
 48  * perf_cpu_map__cpu - get the CPU value at the given index. Returns -1 if index
 49  *                     is invalid.
 50  */
 51 LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);
 52 /**
 53  * perf_cpu_map__nr - for an empty map returns 1, as perf_cpu_map__cpu returns a
 54  *                    cpu of -1 for an invalid index, this makes an empty map
 55  *                    look like it contains the "any CPU"/dummy value. Otherwise
 56  *                    the result is the number CPUs in the map plus one if the
 57  *                    "any CPU"/dummy value is present.
 58  */
 59 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
 60 /**
 61  * perf_cpu_map__has_any_cpu_or_is_empty - is map either empty or has the "any CPU"/dummy value.
 62  */
 63 LIBPERF_API bool perf_cpu_map__has_any_cpu_or_is_empty(const struct perf_cpu_map *map);
 64 /**
 65  * perf_cpu_map__is_any_cpu_or_is_empty - is map either empty or the "any CPU"/dummy value.
 66  */
 67 LIBPERF_API bool perf_cpu_map__is_any_cpu_or_is_empty(const struct perf_cpu_map *map);
 68 /**
 69  * perf_cpu_map__is_empty - does the map contain no values and it doesn't
 70  *                          contain the special "any CPU"/dummy value.
 71  */
 72 LIBPERF_API bool perf_cpu_map__is_empty(const struct perf_cpu_map *map);
 73 /**
 74  * perf_cpu_map__min - the minimum CPU value or -1 if empty or just the "any CPU"/dummy value.
 75  */
 76 LIBPERF_API struct perf_cpu perf_cpu_map__min(const struct perf_cpu_map *map);
 77 /**
 78  * perf_cpu_map__max - the maximum CPU value or -1 if empty or just the "any CPU"/dummy value.
 79  */
 80 LIBPERF_API struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map);
 81 LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_cpu cpu);
 82 LIBPERF_API bool perf_cpu_map__equal(const struct perf_cpu_map *lhs,
 83                                      const struct perf_cpu_map *rhs);
 84 /**
 85  * perf_cpu_map__any_cpu - Does the map contain the "any CPU"/dummy -1 value?
 86  */
 87 LIBPERF_API bool perf_cpu_map__has_any_cpu(const struct perf_cpu_map *map);
 88 
 89 #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)              \
 90         for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);   \
 91              (idx) < perf_cpu_map__nr(cpus);                    \
 92              (idx)++, (cpu) = perf_cpu_map__cpu(cpus, idx))
 93 
 94 #define perf_cpu_map__for_each_cpu_skip_any(_cpu, idx, cpus)    \
 95         for ((idx) = 0, (_cpu) = perf_cpu_map__cpu(cpus, idx);  \
 96              (idx) < perf_cpu_map__nr(cpus);                    \
 97              (idx)++, (_cpu) = perf_cpu_map__cpu(cpus, idx))    \
 98                 if ((_cpu).cpu != -1)
 99 
100 #define perf_cpu_map__for_each_idx(idx, cpus)                           \
101         for ((idx) = 0; (idx) < perf_cpu_map__nr(cpus); (idx)++)
102 
103 #endif /* __LIBPERF_CPUMAP_H */
104 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php