blob: f403991e3bfd8d7c8a8d892344223316890836be [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 Melod10eb1e2015-03-03 12:20:38 -03006struct perf_sample;
Jiri Olsa5f86b802014-08-01 13:02:58 -03007
8struct ordered_event {
9 u64 timestamp;
10 u64 file_offset;
11 union perf_event *event;
12 struct list_head list;
13};
14
15enum oe_flush {
Jiri Olsab0a45202014-06-12 09:50:11 +020016 OE_FLUSH__NONE,
Jiri Olsa5f86b802014-08-01 13:02:58 -030017 OE_FLUSH__FINAL,
18 OE_FLUSH__ROUND,
19 OE_FLUSH__HALF,
20};
21
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -030022struct ordered_events;
23
24typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
Arnaldo Carvalho de Melo9870d782015-03-31 12:48:16 -030025 struct ordered_event *event);
Arnaldo Carvalho de Melod10eb1e2015-03-03 12:20:38 -030026
Jiri Olsa5f86b802014-08-01 13:02:58 -030027struct 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 Melod10eb1e2015-03-03 12:20:38 -030038 ordered_events__deliver_t deliver;
Jiri Olsa5f86b802014-08-01 13:02:58 -030039 int buffer_idx;
40 unsigned int nr_events;
Jiri Olsab0a45202014-06-12 09:50:11 +020041 enum oe_flush last_flush_type;
Arnaldo Carvalho de Melo9870d782015-03-31 12:48:16 -030042 u32 nr_unordered_events;
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040043 bool copy_on_queue;
Jiri Olsa5f86b802014-08-01 13:02:58 -030044};
45
Arnaldo Carvalho de Melo4a6b3622015-03-03 13:02:24 -030046int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
47 struct perf_sample *sample, u64 file_offset);
Jiri Olsa5f86b802014-08-01 13:02:58 -030048void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030049int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
Arnaldo Carvalho de Melo9870d782015-03-31 12:48:16 -030050void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
Jiri Olsaadc56ed2014-06-10 22:50:03 +020051void ordered_events__free(struct ordered_events *oe);
Jiri Olsa94786b62014-06-05 11:00:20 +020052
53static inline
54void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
55{
56 oe->max_alloc_size = size;
57}
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040058
59static inline
60void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
61{
62 oe->copy_on_queue = copy;
63}
Jiri Olsa5f86b802014-08-01 13:02:58 -030064#endif /* __ORDERED_EVENTS_H */