cpumap.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __PERF_CPUMAP_H
  3. #define __PERF_CPUMAP_H
  4. #include <stdio.h>
  5. #include <stdbool.h>
  6. #include <internal/cpumap.h>
  7. #include <perf/cpumap.h>
  8. struct perf_record_cpu_map_data;
  9. struct perf_cpu_map *perf_cpu_map__empty_new(int nr);
  10. struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data);
  11. size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
  12. size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size);
  13. size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp);
  14. int cpu_map__get_socket_id(int cpu);
  15. int cpu_map__get_socket(struct perf_cpu_map *map, int idx, void *data);
  16. int cpu_map__get_die_id(int cpu);
  17. int cpu_map__get_die(struct perf_cpu_map *map, int idx, void *data);
  18. int cpu_map__get_core_id(int cpu);
  19. int cpu_map__get_core(struct perf_cpu_map *map, int idx, void *data);
  20. int cpu_map__get_node_id(int cpu);
  21. int cpu_map__get_node(struct perf_cpu_map *map, int idx, void *data);
  22. int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct perf_cpu_map **sockp);
  23. int cpu_map__build_die_map(struct perf_cpu_map *cpus, struct perf_cpu_map **diep);
  24. int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct perf_cpu_map **corep);
  25. int cpu_map__build_node_map(struct perf_cpu_map *cpus, struct perf_cpu_map **nodep);
  26. const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */
  27. static inline int cpu_map__socket(struct perf_cpu_map *sock, int s)
  28. {
  29. if (!sock || s > sock->nr || s < 0)
  30. return 0;
  31. return sock->map[s];
  32. }
  33. static inline int cpu_map__id_to_socket(int id)
  34. {
  35. return id >> 24;
  36. }
  37. static inline int cpu_map__id_to_die(int id)
  38. {
  39. return (id >> 16) & 0xff;
  40. }
  41. static inline int cpu_map__id_to_cpu(int id)
  42. {
  43. return id & 0xffff;
  44. }
  45. int cpu__setup_cpunode_map(void);
  46. int cpu__max_node(void);
  47. int cpu__max_cpu(void);
  48. int cpu__max_present_cpu(void);
  49. int cpu__get_node(int cpu);
  50. int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res,
  51. int (*f)(struct perf_cpu_map *map, int cpu, void *data),
  52. void *data);
  53. int cpu_map__cpu(struct perf_cpu_map *cpus, int idx);
  54. bool cpu_map__has(struct perf_cpu_map *cpus, int cpu);
  55. #endif /* __PERF_CPUMAP_H */