linux/tools/perf/util/ordered-events.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef __ORDERED_EVENTS_H
   3#define __ORDERED_EVENTS_H
   4
   5#include <linux/types.h>
   6
   7struct perf_sample;
   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 {
  17        OE_FLUSH__NONE,
  18        OE_FLUSH__FINAL,
  19        OE_FLUSH__ROUND,
  20        OE_FLUSH__HALF,
  21};
  22
  23struct ordered_events;
  24
  25typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
  26                                         struct ordered_event *event);
  27
  28struct ordered_events {
  29        u64                     last_flush;
  30        u64                     next_flush;
  31        u64                     max_timestamp;
  32        u64                     max_alloc_size;
  33        u64                     cur_alloc_size;
  34        struct list_head        events;
  35        struct list_head        cache;
  36        struct list_head        to_free;
  37        struct ordered_event    *buffer;
  38        struct ordered_event    *last;
  39        ordered_events__deliver_t deliver;
  40        int                     buffer_idx;
  41        unsigned int            nr_events;
  42        enum oe_flush           last_flush_type;
  43        u32                     nr_unordered_events;
  44        bool                    copy_on_queue;
  45};
  46
  47int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
  48                          u64 timestamp, u64 file_offset);
  49void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
  50int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
  51void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver);
  52void ordered_events__free(struct ordered_events *oe);
  53void ordered_events__reinit(struct ordered_events *oe);
  54
  55static inline
  56void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
  57{
  58        oe->max_alloc_size = size;
  59}
  60
  61static inline
  62void ordered_events__set_copy_on_queue(struct ordered_events *oe, bool copy)
  63{
  64        oe->copy_on_queue = copy;
  65}
  66#endif /* __ORDERED_EVENTS_H */
  67