evlist.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef __PERF_EVLIST_H
  2. #define __PERF_EVLIST_H 1
  3. #include <linux/list.h>
  4. #include <stdio.h>
  5. #include "../perf.h"
  6. #include "event.h"
  7. #include "util.h"
  8. #include <unistd.h>
  9. struct pollfd;
  10. struct thread_map;
  11. struct cpu_map;
  12. struct perf_record_opts;
  13. #define PERF_EVLIST__HLIST_BITS 8
  14. #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
  15. struct perf_evlist {
  16. struct list_head entries;
  17. struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
  18. int nr_entries;
  19. int nr_fds;
  20. int nr_mmaps;
  21. int mmap_len;
  22. struct {
  23. int cork_fd;
  24. pid_t pid;
  25. } workload;
  26. bool overwrite;
  27. union perf_event event_copy;
  28. struct perf_mmap *mmap;
  29. struct pollfd *pollfd;
  30. struct thread_map *threads;
  31. struct cpu_map *cpus;
  32. struct perf_evsel *selected;
  33. };
  34. struct perf_evsel_str_handler {
  35. const char *name;
  36. void *handler;
  37. };
  38. struct perf_evsel;
  39. struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
  40. struct thread_map *threads);
  41. void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
  42. struct thread_map *threads);
  43. void perf_evlist__exit(struct perf_evlist *evlist);
  44. void perf_evlist__delete(struct perf_evlist *evlist);
  45. void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
  46. int perf_evlist__add_default(struct perf_evlist *evlist);
  47. int perf_evlist__add_attrs(struct perf_evlist *evlist,
  48. struct perf_event_attr *attrs, size_t nr_attrs);
  49. int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
  50. const char *tracepoints[], size_t nr_tracepoints);
  51. int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist,
  52. const struct perf_evsel_str_handler *assocs,
  53. size_t nr_assocs);
  54. #define perf_evlist__add_attrs_array(evlist, array) \
  55. perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array))
  56. #define perf_evlist__add_tracepoints_array(evlist, array) \
  57. perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array))
  58. #define perf_evlist__set_tracepoints_handlers_array(evlist, array) \
  59. perf_evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))
  60. void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
  61. int cpu, int thread, u64 id);
  62. void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
  63. struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
  64. union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
  65. int perf_evlist__open(struct perf_evlist *evlist, bool group);
  66. void perf_evlist__config_attrs(struct perf_evlist *evlist,
  67. struct perf_record_opts *opts);
  68. int perf_evlist__prepare_workload(struct perf_evlist *evlist,
  69. struct perf_record_opts *opts,
  70. const char *argv[]);
  71. int perf_evlist__start_workload(struct perf_evlist *evlist);
  72. int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
  73. bool overwrite);
  74. void perf_evlist__munmap(struct perf_evlist *evlist);
  75. void perf_evlist__disable(struct perf_evlist *evlist);
  76. void perf_evlist__enable(struct perf_evlist *evlist);
  77. void perf_evlist__set_selected(struct perf_evlist *evlist,
  78. struct perf_evsel *evsel);
  79. static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
  80. struct cpu_map *cpus,
  81. struct thread_map *threads)
  82. {
  83. evlist->cpus = cpus;
  84. evlist->threads = threads;
  85. }
  86. int perf_evlist__create_maps(struct perf_evlist *evlist, const char *target_pid,
  87. const char *tid, uid_t uid, const char *cpu_list);
  88. void perf_evlist__delete_maps(struct perf_evlist *evlist);
  89. int perf_evlist__set_filters(struct perf_evlist *evlist);
  90. u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
  91. bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
  92. u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
  93. bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
  94. bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
  95. void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
  96. struct list_head *list,
  97. int nr_entries);
  98. #endif /* __PERF_EVLIST_H */