blob: c6cf0bafbb2c10e84a921ef5e52e049f9fd87c56 [file] [log] [blame]
Jiri Olsa5f86b802014-08-01 13:02:58 -03001#ifndef __ORDERED_EVENTS_H
2#define __ORDERED_EVENTS_H
3
4#include <linux/types.h>
Jiri Olsa5f86b802014-08-01 13:02:58 -03005
Arnaldo Carvalho de Melofa713a4e2015-03-03 11:48:12 -03006struct perf_tool;
7struct perf_evlist;
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -03008struct perf_sample;
Arnaldo Carvalho de Melofa713a4e2015-03-03 11:48:12 -03009struct machines;
Jiri Olsa5f86b802014-08-01 13:02:58 -030010
11struct ordered_event {
12 u64 timestamp;
13 u64 file_offset;
14 union perf_event *event;
15 struct list_head list;
16};
17
18enum oe_flush {
Jiri Olsab0a45202014-06-12 09:50:11 +020019 OE_FLUSH__NONE,
Jiri Olsa5f86b802014-08-01 13:02:58 -030020 OE_FLUSH__FINAL,
21 OE_FLUSH__ROUND,
22 OE_FLUSH__HALF,
23};
24
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -030025struct ordered_events;
26
27typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
28 struct ordered_event *event,
29 struct perf_sample *sample);
30
Jiri Olsa5f86b802014-08-01 13:02:58 -030031struct 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 Melob7b61cb2015-03-03 11:58:45 -030042 struct machines *machines;
43 struct perf_evlist *evlist;
44 struct perf_tool *tool;
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -030045 ordered_events__deliver_t deliver;
Jiri Olsa5f86b802014-08-01 13:02:58 -030046 int buffer_idx;
47 unsigned int nr_events;
Jiri Olsab0a45202014-06-12 09:50:11 +020048 enum oe_flush last_flush_type;
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040049 bool copy_on_queue;
Jiri Olsa5f86b802014-08-01 13:02:58 -030050};
51
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040052struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
53 union perf_event *event);
Jiri Olsa5f86b802014-08-01 13:02:58 -030054void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030055int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
56void ordered_events__init(struct ordered_events *oe, struct machines *machines,
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -030057 struct perf_evlist *evlsit, struct perf_tool *tool,
58 ordered_events__deliver_t deliver);
Jiri Olsaadc56ed2014-06-10 22:50:03 +020059void ordered_events__free(struct ordered_events *oe);
Jiri Olsa94786b62014-06-05 11:00:20 +020060
61static inline
62void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
63{
64 oe->max_alloc_size = size;
65}
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040066
67static inline
68void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
69{
70 oe->copy_on_queue = copy;
71}
Jiri Olsa5f86b802014-08-01 13:02:58 -030072#endif /* __ORDERED_EVENTS_H */