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 {
17 OE_FLUSH__NONE,
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;
36 enum oe_flush last_flush_type;
37 bool copy_on_queue;
38 };
39
40 struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
41 union perf_event *event);
42 void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
43 int ordered_events__flush(struct perf_session *s, struct perf_tool *tool,
44 enum oe_flush how);
45 void ordered_events__init(struct ordered_events *oe);
46 void ordered_events__free(struct ordered_events *oe);
47
48 static inline
ordered_events__set_alloc_size(struct ordered_events * oe,u64 size)49 void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
50 {
51 oe->max_alloc_size = size;
52 }
53
54 static inline
ordered_events__set_copy_on_queue(struct ordered_events * oe,bool copy)55 void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
56 {
57 oe->copy_on_queue = copy;
58 }
59 #endif /* __ORDERED_EVENTS_H */
60