Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 1 | #ifndef __ORDERED_EVENTS_H |
| 2 | #define __ORDERED_EVENTS_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include "tool.h" |
| 6 | |
| 7 | struct perf_session; |
| 8 | |
| 9 | struct ordered_event { |
| 10 | u64 timestamp; |
| 11 | u64 file_offset; |
| 12 | union perf_event *event; |
| 13 | struct list_head list; |
| 14 | }; |
| 15 | |
| 16 | enum oe_flush { |
Jiri Olsa | b0a4520 | 2014-06-12 09:50:11 +0200 | [diff] [blame] | 17 | OE_FLUSH__NONE, |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 18 | OE_FLUSH__FINAL, |
| 19 | OE_FLUSH__ROUND, |
| 20 | OE_FLUSH__HALF, |
| 21 | }; |
| 22 | |
| 23 | struct ordered_events { |
| 24 | u64 last_flush; |
| 25 | u64 next_flush; |
| 26 | u64 max_timestamp; |
| 27 | u64 max_alloc_size; |
| 28 | u64 cur_alloc_size; |
| 29 | struct list_head events; |
| 30 | struct list_head cache; |
| 31 | struct list_head to_free; |
| 32 | struct ordered_event *buffer; |
| 33 | struct ordered_event *last; |
| 34 | int buffer_idx; |
| 35 | unsigned int nr_events; |
Jiri Olsa | b0a4520 | 2014-06-12 09:50:11 +0200 | [diff] [blame] | 36 | enum oe_flush last_flush_type; |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp); |
| 40 | void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); |
| 41 | int ordered_events__flush(struct perf_session *s, struct perf_tool *tool, |
| 42 | enum oe_flush how); |
Jiri Olsa | 36522f5 | 2014-06-10 22:47:40 +0200 | [diff] [blame] | 43 | void ordered_events__init(struct ordered_events *oe); |
Jiri Olsa | adc56ed | 2014-06-10 22:50:03 +0200 | [diff] [blame] | 44 | void ordered_events__free(struct ordered_events *oe); |
Jiri Olsa | 94786b6 | 2014-06-05 11:00:20 +0200 | [diff] [blame] | 45 | |
| 46 | static inline |
| 47 | void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size) |
| 48 | { |
| 49 | oe->max_alloc_size = size; |
| 50 | } |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 51 | #endif /* __ORDERED_EVENTS_H */ |