blob: ef7d73ecb0d0c8d1b861f1fb7435f8b8197b738a [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;
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030035 struct machines *machines;
36 struct perf_evlist *evlist;
37 struct perf_tool *tool;
Jiri Olsa5f86b802014-08-01 13:02:58 -030038 int buffer_idx;
39 unsigned int nr_events;
Jiri Olsab0a45202014-06-12 09:50:11 +020040 enum oe_flush last_flush_type;
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040041 bool copy_on_queue;
Jiri Olsa5f86b802014-08-01 13:02:58 -030042};
43
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040044struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
45 union perf_event *event);
Jiri Olsa5f86b802014-08-01 13:02:58 -030046void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030047int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
48void ordered_events__init(struct ordered_events *oe, struct machines *machines,
49 struct perf_evlist *evlsit, struct perf_tool *tool);
Jiri Olsaadc56ed2014-06-10 22:50:03 +020050void ordered_events__free(struct ordered_events *oe);
Jiri Olsa94786b62014-06-05 11:00:20 +020051
52static inline
53void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
54{
55 oe->max_alloc_size = size;
56}
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040057
58static inline
59void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
60{
61 oe->copy_on_queue = copy;
62}
Jiri Olsa5f86b802014-08-01 13:02:58 -030063#endif /* __ORDERED_EVENTS_H */