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