ordered-events.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __ORDERED_EVENTS_H
  2. #define __ORDERED_EVENTS_H
  3. #include <linux/types.h>
  4. struct perf_sample;
  5. struct ordered_event {
  6. u64 timestamp;
  7. u64 file_offset;
  8. union perf_event *event;
  9. struct list_head list;
  10. };
  11. enum oe_flush {
  12. OE_FLUSH__NONE,
  13. OE_FLUSH__FINAL,
  14. OE_FLUSH__ROUND,
  15. OE_FLUSH__HALF,
  16. };
  17. struct ordered_events;
  18. typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
  19. struct ordered_event *event);
  20. struct ordered_events {
  21. u64 last_flush;
  22. u64 next_flush;
  23. u64 max_timestamp;
  24. u64 max_alloc_size;
  25. u64 cur_alloc_size;
  26. struct list_head events;
  27. struct list_head cache;
  28. struct list_head to_free;
  29. struct ordered_event *buffer;
  30. struct ordered_event *last;
  31. ordered_events__deliver_t deliver;
  32. int buffer_idx;
  33. unsigned int nr_events;
  34. enum oe_flush last_flush_type;
  35. u32 nr_unordered_events;
  36. bool copy_on_queue;
  37. };
  38. int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
  39. struct perf_sample *sample, u64 file_offset);
  40. void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
  41. int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
  42. void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
  43. void ordered_events__free(struct ordered_events *oe);
  44. void ordered_events__reinit(struct ordered_events *oe);
  45. static inline
  46. void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
  47. {
  48. oe->max_alloc_size = size;
  49. }
  50. static inline
  51. void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
  52. {
  53. oe->copy_on_queue = copy;
  54. }
  55. #endif /* __ORDERED_EVENTS_H */