]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
5f86b80b JO |
2 | #ifndef __ORDERED_EVENTS_H |
3 | #define __ORDERED_EVENTS_H | |
4 | ||
5 | #include <linux/types.h> | |
5f86b80b | 6 | |
d10eb1eb | 7 | struct perf_sample; |
5f86b80b JO |
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 { | |
b0a45203 | 17 | OE_FLUSH__NONE, |
5f86b80b JO |
18 | OE_FLUSH__FINAL, |
19 | OE_FLUSH__ROUND, | |
20 | OE_FLUSH__HALF, | |
16c66bc1 | 21 | OE_FLUSH__TOP, |
68ca5d07 | 22 | OE_FLUSH__TIME, |
5f86b80b JO |
23 | }; |
24 | ||
d10eb1eb ACM |
25 | struct ordered_events; |
26 | ||
27 | typedef int (*ordered_events__deliver_t)(struct ordered_events *oe, | |
9870d780 | 28 | struct ordered_event *event); |
d10eb1eb | 29 | |
d5ceb62b JO |
30 | struct ordered_events_buffer { |
31 | struct list_head list; | |
32 | struct ordered_event event[0]; | |
33 | }; | |
34 | ||
5f86b80b | 35 | struct ordered_events { |
d5ceb62b JO |
36 | u64 last_flush; |
37 | u64 next_flush; | |
38 | u64 max_timestamp; | |
39 | u64 max_alloc_size; | |
40 | u64 cur_alloc_size; | |
41 | struct list_head events; | |
42 | struct list_head cache; | |
43 | struct list_head to_free; | |
44 | struct ordered_events_buffer *buffer; | |
45 | struct ordered_event *last; | |
46 | ordered_events__deliver_t deliver; | |
47 | int buffer_idx; | |
48 | unsigned int nr_events; | |
49 | enum oe_flush last_flush_type; | |
50 | u32 nr_unordered_events; | |
51 | bool copy_on_queue; | |
a4a6668a | 52 | void *data; |
5f86b80b JO |
53 | }; |
54 | ||
4a6b362f | 55 | int ordered_events__queue(struct ordered_events *oe, union perf_event *event, |
dc83e139 | 56 | u64 timestamp, u64 file_offset); |
5f86b80b | 57 | void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); |
b7b61cbe | 58 | int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); |
68ca5d07 | 59 | int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp); |
a4a6668a JO |
60 | void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver, |
61 | void *data); | |
adc56ed1 | 62 | void ordered_events__free(struct ordered_events *oe); |
4532f642 | 63 | void ordered_events__reinit(struct ordered_events *oe); |
83356b3d | 64 | u64 ordered_events__first_time(struct ordered_events *oe); |
94786b67 JO |
65 | |
66 | static inline | |
67 | void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size) | |
68 | { | |
69 | oe->max_alloc_size = size; | |
70 | } | |
54bf53b1 AY |
71 | |
72 | static inline | |
73 | void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy) | |
74 | { | |
75 | oe->copy_on_queue = copy; | |
76 | } | |
5f86b80b | 77 | #endif /* __ORDERED_EVENTS_H */ |