blob: 7b8f9b011f38f34ea196b59f0641f86bf8484281 [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>
5#include "tool.h"
6
7struct perf_session;
8
9struct ordered_event {
10 u64 timestamp;
11 u64 file_offset;
12 union perf_event *event;
13 struct list_head list;
14};
15
16enum oe_flush {
Jiri Olsab0a45202014-06-12 09:50:11 +020017 OE_FLUSH__NONE,
Jiri Olsa5f86b802014-08-01 13:02:58 -030018 OE_FLUSH__FINAL,
19 OE_FLUSH__ROUND,
20 OE_FLUSH__HALF,
21};
22
23struct 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;
Jiri Olsab0a45202014-06-12 09:50:11 +020036 enum oe_flush last_flush_type;
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040037 bool copy_on_queue;
Jiri Olsa5f86b802014-08-01 13:02:58 -030038};
39
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040040struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
41 union perf_event *event);
Jiri Olsa5f86b802014-08-01 13:02:58 -030042void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
43int ordered_events__flush(struct perf_session *s, struct perf_tool *tool,
44 enum oe_flush how);
Jiri Olsa36522f52014-06-10 22:47:40 +020045void ordered_events__init(struct ordered_events *oe);
Jiri Olsaadc56ed2014-06-10 22:50:03 +020046void ordered_events__free(struct ordered_events *oe);
Jiri Olsa94786b62014-06-05 11:00:20 +020047
48static inline
49void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
50{
51 oe->max_alloc_size = size;
52}
Alexander Yarygin54bf53b2014-10-03 18:40:11 +040053
54static inline
55void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
56{
57 oe->copy_on_queue = copy;
58}
Jiri Olsa5f86b802014-08-01 13:02:58 -030059#endif /* __ORDERED_EVENTS_H */