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> |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 5 | |
Arnaldo Carvalho de Melo | d10eb1e | 2015-03-03 12:20:38 -0300 | [diff] [blame] | 6 | struct perf_sample; |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 7 | |
| 8 | struct ordered_event { |
| 9 | u64 timestamp; |
| 10 | u64 file_offset; |
| 11 | union perf_event *event; |
| 12 | struct list_head list; |
| 13 | }; |
| 14 | |
| 15 | enum oe_flush { |
Jiri Olsa | b0a4520 | 2014-06-12 09:50:11 +0200 | [diff] [blame] | 16 | OE_FLUSH__NONE, |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 17 | OE_FLUSH__FINAL, |
| 18 | OE_FLUSH__ROUND, |
| 19 | OE_FLUSH__HALF, |
| 20 | }; |
| 21 | |
Arnaldo Carvalho de Melo | d10eb1e | 2015-03-03 12:20:38 -0300 | [diff] [blame] | 22 | struct ordered_events; |
| 23 | |
| 24 | typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, |
Arnaldo Carvalho de Melo | 9870d78 | 2015-03-31 12:48:16 -0300 | [diff] [blame] | 25 | struct ordered_event *event); |
Arnaldo Carvalho de Melo | d10eb1e | 2015-03-03 12:20:38 -0300 | [diff] [blame] | 26 | |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 27 | struct ordered_events { |
| 28 | u64 last_flush; |
| 29 | u64 next_flush; |
| 30 | u64 max_timestamp; |
| 31 | u64 max_alloc_size; |
| 32 | u64 cur_alloc_size; |
| 33 | struct list_head events; |
| 34 | struct list_head cache; |
| 35 | struct list_head to_free; |
| 36 | struct ordered_event *buffer; |
| 37 | struct ordered_event *last; |
Arnaldo Carvalho de Melo | d10eb1e | 2015-03-03 12:20:38 -0300 | [diff] [blame] | 38 | ordered_events__deliver_t deliver; |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 39 | int buffer_idx; |
| 40 | unsigned int nr_events; |
Jiri Olsa | b0a4520 | 2014-06-12 09:50:11 +0200 | [diff] [blame] | 41 | enum oe_flush last_flush_type; |
Arnaldo Carvalho de Melo | 9870d78 | 2015-03-31 12:48:16 -0300 | [diff] [blame] | 42 | u32 nr_unordered_events; |
Alexander Yarygin | 54bf53b | 2014-10-03 18:40:11 +0400 | [diff] [blame] | 43 | bool copy_on_queue; |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 44 | }; |
| 45 | |
Arnaldo Carvalho de Melo | 4a6b362 | 2015-03-03 13:02:24 -0300 | [diff] [blame] | 46 | int ordered_events__queue(struct ordered_events *oe, union perf_event *event, |
| 47 | struct perf_sample *sample, u64 file_offset); |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 48 | void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 49 | int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); |
Arnaldo Carvalho de Melo | 9870d78 | 2015-03-31 12:48:16 -0300 | [diff] [blame] | 50 | void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver); |
Jiri Olsa | adc56ed | 2014-06-10 22:50:03 +0200 | [diff] [blame] | 51 | void ordered_events__free(struct ordered_events *oe); |
Jiri Olsa | 94786b6 | 2014-06-05 11:00:20 +0200 | [diff] [blame] | 52 | |
| 53 | static inline |
| 54 | void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size) |
| 55 | { |
| 56 | oe->max_alloc_size = size; |
| 57 | } |
Alexander Yarygin | 54bf53b | 2014-10-03 18:40:11 +0400 | [diff] [blame] | 58 | |
| 59 | static inline |
| 60 | void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy) |
| 61 | { |
| 62 | oe->copy_on_queue = copy; |
| 63 | } |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 64 | #endif /* __ORDERED_EVENTS_H */ |