blob: e09f2433c6d6db5a83ff1e09b21a0f2bee0aec92 [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;
8struct machines;
Jiri Olsa5f86b802014-08-01 13:02:58 -03009
10struct ordered_event {
11 u64 timestamp;
12 u64 file_offset;
13 union perf_event *event;
14 struct list_head list;
15};
16
17enum oe_flush {
Jiri Olsab0a45202014-06-12 09:50:11 +020018 OE_FLUSH__NONE,
Jiri Olsa5f86b802014-08-01 13:02:58 -030019 OE_FLUSH__FINAL,
20 OE_FLUSH__ROUND,
21 OE_FLUSH__HALF,
22};
23
24struct ordered_events {
25 u64 last_flush;
26 u64 next_flush;
27 u64 max_timestamp;
28 u64 max_alloc_size;
29 u64 cur_alloc_size;
30 struct list_head events;
31 struct list_head cache;
32 struct list_head to_free;
33 struct ordered_event *buffer;
34 struct ordered_event *last;
35 int buffer_idx;
36 unsigned int nr_events;
Jiri Olsab0a45202014-06-12 09:50:11 +020037 enum oe_flush last_flush_type;
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040038 bool copy_on_queue;
Jiri Olsa5f86b802014-08-01 13:02:58 -030039};
40
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040041struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
42 union perf_event *event);
Jiri Olsa5f86b802014-08-01 13:02:58 -030043void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
Arnaldo Carvalho de Melofa713a4e2015-03-03 11:48:12 -030044int ordered_events__flush(struct ordered_events *oe, struct machines *machines,
45 struct perf_evlist *evlist, struct perf_tool *tool,
Jiri Olsa5f86b802014-08-01 13:02:58 -030046 enum oe_flush how);
Jiri Olsa36522f52014-06-10 22:47:40 +020047void ordered_events__init(struct ordered_events *oe);
Jiri Olsaadc56ed2014-06-10 22:50:03 +020048void ordered_events__free(struct ordered_events *oe);
Jiri Olsa94786b62014-06-05 11:00:20 +020049
50static inline
51void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
52{
53 oe->max_alloc_size = size;
54}
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040055
56static inline
57void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
58{
59 oe->copy_on_queue = copy;
60}
Jiri Olsa5f86b802014-08-01 13:02:58 -030061#endif /* __ORDERED_EVENTS_H */