ordered-events.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. static inline
  45. void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
  46. {
  47. oe->max_alloc_size = size;
  48. }
  49. static inline
  50. void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
  51. {
  52. oe->copy_on_queue = copy;
  53. }
  54. #endif /* __ORDERED_EVENTS_H */