[8834751] | 1 | #pragma once
|
---|
| 2 |
|
---|
[73f4d08] | 3 | // #define CFA_STATS_ARRAY 10000
|
---|
| 4 |
|
---|
[8834751] | 5 | #include <stdint.h>
|
---|
| 6 |
|
---|
[b7664a03] | 7 | enum {
|
---|
| 8 | CFA_STATS_READY_Q = 0x01,
|
---|
| 9 | CFA_STATS_IO = 0x02,
|
---|
| 10 | };
|
---|
| 11 |
|
---|
[8834751] | 12 | #if defined(__CFA_NO_STATISTICS__)
|
---|
| 13 | struct __stats_t;
|
---|
| 14 | static inline void __init_stats( struct __stats_t * ) {}
|
---|
| 15 | static inline void __tally_stats( struct __stats_t *, struct __stats_t * ) {}
|
---|
[1b033b8] | 16 | static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {}
|
---|
[8834751] | 17 | #else
|
---|
[69fbc61] | 18 |
|
---|
[8834751] | 19 | struct __attribute__((aligned(64))) __stats_readQ_t {
|
---|
| 20 | struct {
|
---|
| 21 | // Push statistic
|
---|
| 22 | struct {
|
---|
| 23 | // number of attemps at pushing something
|
---|
| 24 | volatile uint64_t attempt;
|
---|
| 25 |
|
---|
| 26 | // number of successes at pushing
|
---|
| 27 | volatile uint64_t success;
|
---|
[52769ba] | 28 |
|
---|
| 29 | // number of attemps at pushing something to preferred queues
|
---|
| 30 | volatile uint64_t local;
|
---|
| 31 |
|
---|
| 32 | // number of successes at pushing to preferred queues
|
---|
| 33 | volatile uint64_t lsuccess;
|
---|
[8834751] | 34 | } push;
|
---|
| 35 |
|
---|
[fd1f65e] | 36 | struct {
|
---|
| 37 | // number of attemps at pushing something
|
---|
| 38 | volatile uint64_t attempt;
|
---|
| 39 |
|
---|
| 40 | // number of successes at pushing
|
---|
| 41 | volatile uint64_t success;
|
---|
| 42 |
|
---|
| 43 | // number of attemps at pushing something to preferred queues
|
---|
| 44 | volatile uint64_t local;
|
---|
| 45 |
|
---|
| 46 | // number of successes at pushing to preferred queues
|
---|
| 47 | volatile uint64_t lsuccess;
|
---|
| 48 | } ext;
|
---|
| 49 |
|
---|
[8834751] | 50 | // Pop statistic
|
---|
| 51 | struct {
|
---|
| 52 | // number of reads of the mask
|
---|
| 53 | // picking an empty __cfa_readyQ_mask_t counts here
|
---|
| 54 | // but not as an attempt
|
---|
| 55 | volatile uint64_t probe;
|
---|
| 56 |
|
---|
| 57 | // number of attemps at poping something
|
---|
| 58 | volatile uint64_t attempt;
|
---|
| 59 |
|
---|
| 60 | // number of successes at poping
|
---|
| 61 | volatile uint64_t success;
|
---|
[52769ba] | 62 |
|
---|
| 63 | // number of attemps at poping something to preferred queues
|
---|
| 64 | volatile uint64_t local;
|
---|
| 65 |
|
---|
| 66 | // number of successes at poping to preferred queues
|
---|
| 67 | volatile uint64_t lsuccess;
|
---|
[8834751] | 68 | } pop;
|
---|
| 69 | } pick;
|
---|
[29cb302] | 70 | struct {
|
---|
| 71 | volatile uint64_t migration;
|
---|
[ec43cf9] | 72 | volatile int64_t threads; // number of threads in the system, includes only local change
|
---|
[29cb302] | 73 | } threads;
|
---|
[68f36f4] | 74 | struct {
|
---|
| 75 | volatile uint64_t halts;
|
---|
| 76 | volatile uint64_t cancels;
|
---|
| 77 | volatile uint64_t wakes;
|
---|
| 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;
|
---|
| 94 | } submit;
|
---|
| 95 | struct {
|
---|
| 96 | volatile uint64_t external;
|
---|
| 97 | } flush;
|
---|
| 98 | struct {
|
---|
[dddb3dd0] | 99 | volatile uint64_t drain;
|
---|
[d60d30e] | 100 | volatile uint64_t completed;
|
---|
[dddb3dd0] | 101 | volatile uint64_t flush;
|
---|
| 102 | volatile uint64_t submitted;
|
---|
[d60d30e] | 103 | struct {
|
---|
| 104 | volatile uint64_t busy;
|
---|
| 105 | } errors;
|
---|
| 106 | } calls;
|
---|
[150d21a] | 107 | struct {
|
---|
| 108 | volatile uint64_t sleeps;
|
---|
| 109 | } poller;
|
---|
[8834751] | 110 | };
|
---|
| 111 | #endif
|
---|
| 112 |
|
---|
[73f4d08] | 113 | #if defined(CFA_STATS_ARRAY)
|
---|
| 114 | struct __stats_elem_t {
|
---|
| 115 | long long int ts;
|
---|
| 116 | int64_t value;
|
---|
| 117 | };
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
[37ba662] | 120 | struct __attribute__((aligned(128))) __stats_t {
|
---|
[8834751] | 121 | __stats_readQ_t ready;
|
---|
[5751a56] | 122 | #if defined(CFA_HAVE_LINUX_IO_URING_H)
|
---|
[8834751] | 123 | __stats_io_t io;
|
---|
| 124 | #endif
|
---|
[73f4d08] | 125 |
|
---|
| 126 | #if defined(CFA_STATS_ARRAY)
|
---|
| 127 | struct {
|
---|
| 128 | __stats_elem_t * values;
|
---|
| 129 | volatile size_t cnt;
|
---|
| 130 | } array;
|
---|
| 131 | #endif
|
---|
| 132 |
|
---|
[8834751] | 133 | };
|
---|
| 134 |
|
---|
| 135 | void __init_stats ( struct __stats_t * );
|
---|
| 136 | void __tally_stats( struct __stats_t *, struct __stats_t * );
|
---|
[1b033b8] | 137 | void __print_stats( struct __stats_t *, int, const char *, const char *, void * );
|
---|
[73f4d08] | 138 | #if defined(CFA_STATS_ARRAY)
|
---|
| 139 | void __push_stat ( struct __stats_t *, int64_t value, bool external, const char * name, void * handle);
|
---|
| 140 | void __flush_stat( struct __stats_t *, const char *, void * );
|
---|
| 141 | #else
|
---|
| 142 | static inline void __push_stat ( struct __stats_t *, int64_t, bool, const char *, void * ) {}
|
---|
| 143 | static inline void __flush_stat( struct __stats_t *, const char *, void * ) {}
|
---|
| 144 | #endif
|
---|
[8834751] | 145 | #endif
|
---|
| 146 |
|
---|