| [8834751] | 1 | #pragma once
 | 
|---|
 | 2 | 
 | 
|---|
| [73f4d08] | 3 | // #define CFA_STATS_ARRAY 10000
 | 
|---|
| [78ea291] | 4 | // #define __CFA_NO_STATISTICS__
 | 
|---|
| [73f4d08] | 5 | 
 | 
|---|
| [8834751] | 6 | #include <stdint.h>
 | 
|---|
 | 7 | 
 | 
|---|
| [b7664a03] | 8 | enum {
 | 
|---|
 | 9 |         CFA_STATS_READY_Q  = 0x01,
 | 
|---|
 | 10 |         CFA_STATS_IO = 0x02,
 | 
|---|
 | 11 | };
 | 
|---|
 | 12 | 
 | 
|---|
| [8834751] | 13 | #if defined(__CFA_NO_STATISTICS__)
 | 
|---|
 | 14 |         struct __stats_t;
 | 
|---|
 | 15 |         static inline void __init_stats( struct __stats_t * ) {}
 | 
|---|
 | 16 |         static inline void __tally_stats( struct __stats_t *, struct __stats_t * ) {}
 | 
|---|
| [1b033b8] | 17 |         static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {}
 | 
|---|
| [8834751] | 18 | #else
 | 
|---|
| [d2fadeb] | 19 |         struct __stats_readyQ_pop_t {
 | 
|---|
 | 20 |                 // number of attemps at poping something
 | 
|---|
 | 21 |                 volatile uint64_t attempt;
 | 
|---|
| [69fbc61] | 22 | 
 | 
|---|
| [d2fadeb] | 23 |                 // number of successes at poping
 | 
|---|
 | 24 |                 volatile uint64_t success;
 | 
|---|
 | 25 |         };
 | 
|---|
| [8834751] | 26 | 
 | 
|---|
| [d2fadeb] | 27 |         struct __attribute__((aligned(64))) __stats_readyQ_t {
 | 
|---|
 | 28 |                 // Push statistic
 | 
|---|
 | 29 |                 struct {
 | 
|---|
| [fd1f65e] | 30 |                         struct {
 | 
|---|
| [d2fadeb] | 31 |                                 // number of attemps at pushing something to preferred queues
 | 
|---|
| [fd1f65e] | 32 |                                 volatile uint64_t attempt;
 | 
|---|
 | 33 | 
 | 
|---|
| [d2fadeb] | 34 |                                 // number of successes at pushing to preferred queues
 | 
|---|
| [fd1f65e] | 35 |                                 volatile uint64_t success;
 | 
|---|
| [d2fadeb] | 36 |                         }
 | 
|---|
 | 37 |                         // Stats for local queue within cluster
 | 
|---|
 | 38 |                         local,
 | 
|---|
| [fd1f65e] | 39 | 
 | 
|---|
| [d2fadeb] | 40 |                         // Stats for non-local queues within cluster
 | 
|---|
 | 41 |                         share,
 | 
|---|
| [fd1f65e] | 42 | 
 | 
|---|
| [d2fadeb] | 43 |                         // Stats from outside cluster
 | 
|---|
 | 44 |                         extrn;
 | 
|---|
 | 45 |                 } push;
 | 
|---|
| [fd1f65e] | 46 | 
 | 
|---|
| [d2fadeb] | 47 |                 // Pop statistic
 | 
|---|
 | 48 |                 struct {
 | 
|---|
 | 49 |                         // pop from local queue
 | 
|---|
 | 50 |                         __stats_readyQ_pop_t local;
 | 
|---|
| [8834751] | 51 | 
 | 
|---|
| [d2fadeb] | 52 |                         // pop before looking at local queue
 | 
|---|
 | 53 |                         __stats_readyQ_pop_t help;
 | 
|---|
| [8834751] | 54 | 
 | 
|---|
| [d2fadeb] | 55 |                         // pop from some other queue
 | 
|---|
 | 56 |                         __stats_readyQ_pop_t steal;
 | 
|---|
| [52769ba] | 57 | 
 | 
|---|
| [d2fadeb] | 58 |                         // pop when searching queues sequentially
 | 
|---|
 | 59 |                         __stats_readyQ_pop_t search;
 | 
|---|
 | 60 |                 } pop;
 | 
|---|
| [52769ba] | 61 | 
 | 
|---|
| [29cb302] | 62 |                 struct {
 | 
|---|
 | 63 |                         volatile uint64_t migration;
 | 
|---|
| [3bd4293] | 64 |                         volatile uint64_t extunpark;
 | 
|---|
| [78ea291] | 65 |                         volatile  int64_t threads;  // number of threads in the system, includes only local change
 | 
|---|
 | 66 |                         volatile  int64_t cthreads; // number of threads in the system, includes only local change
 | 
|---|
| [941e14a] | 67 |                         struct {
 | 
|---|
 | 68 |                                 volatile uint64_t yield;
 | 
|---|
 | 69 |                                 volatile uint64_t rllfwd;
 | 
|---|
 | 70 |                         } preempt;
 | 
|---|
| [29cb302] | 71 |                 } threads;
 | 
|---|
| [68f36f4] | 72 |                 struct {
 | 
|---|
 | 73 |                         volatile uint64_t halts;
 | 
|---|
 | 74 |                         volatile uint64_t cancels;
 | 
|---|
| [7cf3b1d] | 75 |                         volatile uint64_t early;
 | 
|---|
| [68f36f4] | 76 |                         volatile uint64_t wakes;
 | 
|---|
| [7cf3b1d] | 77 |                         volatile uint64_t seen;
 | 
|---|
| [68f36f4] | 78 |                         volatile uint64_t exits;
 | 
|---|
 | 79 |                 } sleep;
 | 
|---|
| [8834751] | 80 |         };
 | 
|---|
 | 81 | 
 | 
|---|
| [5751a56] | 82 |         #if defined(CFA_HAVE_LINUX_IO_URING_H)
 | 
|---|
| [8834751] | 83 |                 struct __attribute__((aligned(64))) __stats_io_t{
 | 
|---|
 | 84 |                         struct {
 | 
|---|
| [d60d30e] | 85 |                                 volatile uint64_t fast;
 | 
|---|
 | 86 |                                 volatile uint64_t slow;
 | 
|---|
 | 87 |                                 volatile uint64_t fail;
 | 
|---|
 | 88 |                                 volatile uint64_t revoke;
 | 
|---|
 | 89 |                                 volatile uint64_t block;
 | 
|---|
 | 90 |                         } alloc;
 | 
|---|
| [8834751] | 91 |                         struct {
 | 
|---|
| [d60d30e] | 92 |                                 volatile uint64_t fast;
 | 
|---|
 | 93 |                                 volatile uint64_t slow;
 | 
|---|
| [7ce8873] | 94 |                                 volatile uint64_t eagr;
 | 
|---|
 | 95 |                                 volatile uint64_t nblk;
 | 
|---|
| [d60d30e] | 96 |                         } submit;
 | 
|---|
 | 97 |                         struct {
 | 
|---|
 | 98 |                                 volatile uint64_t external;
 | 
|---|
| [70b4aeb9] | 99 |                                 volatile uint64_t dirty;
 | 
|---|
 | 100 |                                 volatile uint64_t full;
 | 
|---|
 | 101 |                                 volatile uint64_t idle;
 | 
|---|
 | 102 |                                 volatile uint64_t eager;
 | 
|---|
| [d60d30e] | 103 |                         } flush;
 | 
|---|
 | 104 |                         struct {
 | 
|---|
| [dddb3dd0] | 105 |                                 volatile uint64_t drain;
 | 
|---|
| [d60d30e] | 106 |                                 volatile uint64_t completed;
 | 
|---|
| [54c1196] | 107 |                                 volatile uint64_t locked;
 | 
|---|
 | 108 |                                 volatile uint64_t helped;
 | 
|---|
| [dddb3dd0] | 109 |                                 volatile uint64_t flush;
 | 
|---|
 | 110 |                                 volatile uint64_t submitted;
 | 
|---|
| [d60d30e] | 111 |                                 struct {
 | 
|---|
 | 112 |                                         volatile uint64_t busy;
 | 
|---|
 | 113 |                                 } errors;
 | 
|---|
 | 114 |                         } calls;
 | 
|---|
| [150d21a] | 115 |                         struct {
 | 
|---|
 | 116 |                                 volatile uint64_t sleeps;
 | 
|---|
 | 117 |                         } poller;
 | 
|---|
| [db614d0] | 118 |                         struct {
 | 
|---|
 | 119 |                                 volatile uint64_t sockread;
 | 
|---|
 | 120 |                                 volatile uint64_t epllread;
 | 
|---|
 | 121 |                                 volatile uint64_t sockwrite;
 | 
|---|
 | 122 |                                 volatile uint64_t epllwrite;
 | 
|---|
 | 123 |                         } ops;
 | 
|---|
| [8834751] | 124 |                 };
 | 
|---|
 | 125 |         #endif
 | 
|---|
 | 126 | 
 | 
|---|
| [73f4d08] | 127 |         #if defined(CFA_STATS_ARRAY)
 | 
|---|
 | 128 |                 struct __stats_elem_t {
 | 
|---|
 | 129 |                         long long int ts;
 | 
|---|
 | 130 |                         int64_t value;
 | 
|---|
 | 131 |                 };
 | 
|---|
 | 132 |         #endif
 | 
|---|
 | 133 | 
 | 
|---|
| [2af1943] | 134 |         struct __attribute__((aligned(64))) __stats_t {
 | 
|---|
| [d2fadeb] | 135 |                 __stats_readyQ_t ready;
 | 
|---|
| [5751a56] | 136 |                 #if defined(CFA_HAVE_LINUX_IO_URING_H)
 | 
|---|
| [8834751] | 137 |                         __stats_io_t    io;
 | 
|---|
 | 138 |                 #endif
 | 
|---|
| [73f4d08] | 139 | 
 | 
|---|
 | 140 |                 #if defined(CFA_STATS_ARRAY)
 | 
|---|
 | 141 |                         struct {
 | 
|---|
 | 142 |                                 __stats_elem_t * values;
 | 
|---|
 | 143 |                                 volatile size_t cnt;
 | 
|---|
 | 144 |                         } array;
 | 
|---|
 | 145 |                 #endif
 | 
|---|
 | 146 | 
 | 
|---|
| [8834751] | 147 |         };
 | 
|---|
 | 148 | 
 | 
|---|
 | 149 |         void __init_stats ( struct __stats_t * );
 | 
|---|
 | 150 |         void __tally_stats( struct __stats_t *, struct __stats_t * );
 | 
|---|
| [1b033b8] | 151 |         void __print_stats( struct __stats_t *, int, const char *, const char *, void * );
 | 
|---|
| [73f4d08] | 152 |         #if defined(CFA_STATS_ARRAY)
 | 
|---|
 | 153 |                 void __push_stat ( struct __stats_t *, int64_t value, bool external, const char * name, void * handle);
 | 
|---|
 | 154 |                 void __flush_stat( struct __stats_t *, const char *, void * );
 | 
|---|
 | 155 |         #else
 | 
|---|
 | 156 |                 static inline void __push_stat ( struct __stats_t *, int64_t, bool, const char *, void * ) {}
 | 
|---|
 | 157 |                 static inline void __flush_stat( struct __stats_t *, const char *, void * ) {}
 | 
|---|
 | 158 |         #endif
 | 
|---|
| [8834751] | 159 | #endif
 | 
|---|
 | 160 | 
 | 
|---|