ordered-events.h 1.4 KB

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