mmap.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __PERF_MMAP_H
  2. #define __PERF_MMAP_H 1
  3. #include <internal/mmap.h>
  4. #include <linux/compiler.h>
  5. #include <linux/refcount.h>
  6. #include <linux/types.h>
  7. #include <linux/ring_buffer.h>
  8. #include <stdbool.h>
  9. #include <pthread.h> // for cpu_set_t
  10. #ifdef HAVE_AIO_SUPPORT
  11. #include <aio.h>
  12. #endif
  13. #include "auxtrace.h"
  14. #include "event.h"
  15. struct aiocb;
  16. struct mmap_cpu_mask {
  17. unsigned long *bits;
  18. size_t nbits;
  19. };
  20. #define MMAP_CPU_MASK_BYTES(m) \
  21. (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long))
  22. /**
  23. * struct mmap - perf's ring buffer mmap details
  24. *
  25. * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
  26. */
  27. struct mmap {
  28. struct perf_mmap core;
  29. struct auxtrace_mmap auxtrace_mmap;
  30. #ifdef HAVE_AIO_SUPPORT
  31. struct {
  32. void **data;
  33. struct aiocb *cblocks;
  34. struct aiocb **aiocb;
  35. int nr_cblocks;
  36. } aio;
  37. #endif
  38. struct mmap_cpu_mask affinity_mask;
  39. void *data;
  40. int comp_level;
  41. };
  42. struct mmap_params {
  43. struct perf_mmap_param core;
  44. int nr_cblocks, affinity, flush, comp_level;
  45. struct auxtrace_mmap_params auxtrace_mp;
  46. };
  47. int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
  48. void mmap__munmap(struct mmap *map);
  49. union perf_event *perf_mmap__read_forward(struct mmap *map);
  50. int perf_mmap__push(struct mmap *md, void *to,
  51. int push(struct mmap *map, void *to, void *buf, size_t size));
  52. size_t mmap__mmap_len(struct mmap *map);
  53. void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
  54. #endif /*__PERF_MMAP_H */