0001
0002 #ifndef __ORDERED_EVENTS_H
0003 #define __ORDERED_EVENTS_H
0004
0005 #include <linux/types.h>
0006
0007 struct perf_sample;
0008
0009 struct ordered_event {
0010 u64 timestamp;
0011 u64 file_offset;
0012 const char *file_path;
0013 union perf_event *event;
0014 struct list_head list;
0015 };
0016
0017 enum oe_flush {
0018 OE_FLUSH__NONE,
0019 OE_FLUSH__FINAL,
0020 OE_FLUSH__ROUND,
0021 OE_FLUSH__HALF,
0022 OE_FLUSH__TOP,
0023 OE_FLUSH__TIME,
0024 };
0025
0026 struct ordered_events;
0027
0028 typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
0029 struct ordered_event *event);
0030
0031 struct ordered_events_buffer {
0032 struct list_head list;
0033 struct ordered_event event[];
0034 };
0035
0036 struct ordered_events {
0037 u64 last_flush;
0038 u64 next_flush;
0039 u64 max_timestamp;
0040 u64 max_alloc_size;
0041 u64 cur_alloc_size;
0042 struct list_head events;
0043 struct list_head cache;
0044 struct list_head to_free;
0045 struct ordered_events_buffer *buffer;
0046 struct ordered_event *last;
0047 ordered_events__deliver_t deliver;
0048 int buffer_idx;
0049 unsigned int nr_events;
0050 enum oe_flush last_flush_type;
0051 u32 nr_unordered_events;
0052 bool copy_on_queue;
0053 void *data;
0054 };
0055
0056 int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
0057 u64 timestamp, u64 file_offset, const char *file_path);
0058 void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
0059 int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
0060 int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp);
0061 void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
0062 void *data);
0063 void ordered_events__free(struct ordered_events *oe);
0064 void ordered_events__reinit(struct ordered_events *oe);
0065 u64 ordered_events__first_time(struct ordered_events *oe);
0066
0067 static inline
0068 void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
0069 {
0070 oe->max_alloc_size = size;
0071 }
0072
0073 static inline
0074 void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
0075 {
0076 oe->copy_on_queue = copy;
0077 }
0078
0079 static inline u64 ordered_events__last_flush_time(struct ordered_events *oe)
0080 {
0081 return oe->last_flush;
0082 }
0083
0084 #endif