#pragma once #include #if defined(__CFA_NO_STATISTICS__) struct __stats_t; static inline void __init_stats( struct __stats_t * ) {} static inline void __tally_stats( struct __stats_t *, struct __stats_t * ) {} static inline void __print_stats( struct __stats_t *, int, bool, const char *, void * ) {} #else enum { CFA_STATS_READY_Q = 0x01, #if defined(CFA_HAVE_LINUX_IO_URING_H) CFA_STATS_IO = 0x02, #endif }; struct __attribute__((aligned(64))) __stats_readQ_t { struct { // Push statistic struct { // number of attemps at pushing something volatile uint64_t attempt; // number of successes at pushing volatile uint64_t success; // number of attemps at pushing something to preferred queues volatile uint64_t local; // number of successes at pushing to preferred queues volatile uint64_t lsuccess; } push; // Pop statistic struct { // number of reads of the mask // picking an empty __cfa_readyQ_mask_t counts here // but not as an attempt volatile uint64_t probe; // number of attemps at poping something volatile uint64_t attempt; // number of successes at poping volatile uint64_t success; // number of attemps at poping something to preferred queues volatile uint64_t local; // number of successes at poping to preferred queues volatile uint64_t lsuccess; } pop; } pick; struct { volatile uint64_t migration; } threads; struct { volatile uint64_t halts; volatile uint64_t cancels; volatile uint64_t wakes; volatile uint64_t exits; } sleep; }; #if defined(CFA_HAVE_LINUX_IO_URING_H) struct __attribute__((aligned(64))) __stats_io_t{ struct { struct { volatile uint64_t rdy; volatile uint64_t csm; volatile uint64_t avl; volatile uint64_t cnt; } submit_avg; struct { volatile uint64_t val; volatile uint64_t cnt; volatile uint64_t block; } look_avg; struct { volatile uint64_t val; volatile uint64_t cnt; volatile uint64_t block; } alloc_avg; volatile uint64_t helped; volatile uint64_t leader; volatile uint64_t busy; } submit_q; struct { struct { volatile uint64_t val; volatile uint64_t cnt; } completed_avg; volatile uint64_t blocks; } complete_q; }; #endif struct __attribute__((aligned(128))) __stats_t { __stats_readQ_t ready; #if defined(CFA_HAVE_LINUX_IO_URING_H) __stats_io_t io; #endif }; void __init_stats ( struct __stats_t * ); void __tally_stats( struct __stats_t *, struct __stats_t * ); void __print_stats( struct __stats_t *, int, bool, const char *, void * ); #endif