Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    r71c8b7e rf6660520  
    3838void  ?{}(semaphore & this, int count = 1);
    3939void ^?{}(semaphore & this);
    40 bool   P (semaphore & this);
     40void   P (semaphore & this);
    4141bool   V (semaphore & this);
    4242bool   V (semaphore & this, unsigned count);
     
    114114//-----------------------------------------------------------------------------
    115115// I/O
    116 struct __io_data;
    117 
    118 #define CFA_CLUSTER_IO_POLLER_USER_THREAD 1 << 0
    119 // #define CFA_CLUSTER_IO_POLLER_KERNEL_SIDE 1 << 1
     116#if defined(HAVE_LINUX_IO_URING_H)
     117struct io_uring_sq {
     118        // Head and tail of the ring (associated with array)
     119        volatile uint32_t * head;
     120        volatile uint32_t * tail;
     121
     122        // The actual kernel ring which uses head/tail
     123        // indexes into the sqes arrays
     124        uint32_t * array;
     125
     126        // number of entries and mask to go with it
     127        const uint32_t * num;
     128        const uint32_t * mask;
     129
     130        // Submission flags (Not sure what for)
     131        uint32_t * flags;
     132
     133        // number of sqes not submitted (whatever that means)
     134        uint32_t * dropped;
     135
     136        // Like head/tail but not seen by the kernel
     137        volatile uint32_t alloc;
     138        volatile uint32_t ready;
     139
     140        __spinlock_t lock;
     141
     142        // A buffer of sqes (not the actual ring)
     143        struct io_uring_sqe * sqes;
     144
     145        // The location and size of the mmaped area
     146        void * ring_ptr;
     147        size_t ring_sz;
     148
     149        // Statistics
     150        #if !defined(__CFA_NO_STATISTICS__)
     151                struct {
     152                        struct {
     153                                unsigned long long int val;
     154                                unsigned long long int cnt;
     155                        } submit_avg;
     156                } stats;
     157        #endif
     158};
     159
     160struct io_uring_cq {
     161        // Head and tail of the ring
     162        volatile uint32_t * head;
     163        volatile uint32_t * tail;
     164
     165        // number of entries and mask to go with it
     166        const uint32_t * mask;
     167        const uint32_t * num;
     168
     169        // number of cqes not submitted (whatever that means)
     170        uint32_t * overflow;
     171
     172        // the kernel ring
     173        struct io_uring_cqe * cqes;
     174
     175        // The location and size of the mmaped area
     176        void * ring_ptr;
     177        size_t ring_sz;
     178
     179        // Statistics
     180        #if !defined(__CFA_NO_STATISTICS__)
     181                struct {
     182                        struct {
     183                                unsigned long long int val;
     184                                unsigned long long int cnt;
     185                        } completed_avg;
     186                } stats;
     187        #endif
     188};
     189
     190#if defined(__CFA_IO_POLLING_USER__)
     191        struct __io_poller_fast {
     192                struct io_ring * ring;
     193                $thread thrd;
     194        };
     195#endif
     196
     197struct io_ring {
     198        struct io_uring_sq submit_q;
     199        struct io_uring_cq completion_q;
     200        uint32_t flags;
     201        int fd;
     202        semaphore submit;
     203        volatile bool done;
     204        struct {
     205                struct {
     206                        void * stack;
     207                        pthread_t kthrd;
     208                } slow;
     209                #if defined(__CFA_IO_POLLING_USER__)
     210                        __io_poller_fast fast;
     211                        __bin_sem_t sem;
     212                #endif
     213        } poller;
     214};
     215#endif
    120216
    121217//-----------------------------------------------------------------------------
     
    151247        } node;
    152248
    153         struct __io_data * io;
     249        #if defined(HAVE_LINUX_IO_URING_H)
     250                struct io_ring io;
     251        #endif
    154252
    155253        #if !defined(__CFA_NO_STATISTICS__)
     
    159257extern Duration default_preemption();
    160258
    161 void ?{} (cluster & this, const char name[], Duration preemption_rate, int flags);
     259void ?{} (cluster & this, const char name[], Duration preemption_rate);
    162260void ^?{}(cluster & this);
    163261
    164 static inline void ?{} (cluster & this)                                      { this{"Anonymous Cluster", default_preemption(), 0}; }
    165 static inline void ?{} (cluster & this, Duration preemption_rate)            { this{"Anonymous Cluster", preemption_rate, 0}; }
    166 static inline void ?{} (cluster & this, const char name[])                   { this{name, default_preemption(), 0}; }
    167 static inline void ?{} (cluster & this, int flags)                           { this{"Anonymous Cluster", default_preemption(), flags}; }
    168 static inline void ?{} (cluster & this, Duration preemption_rate, int flags) { this{"Anonymous Cluster", preemption_rate, flags}; }
    169 static inline void ?{} (cluster & this, const char name[], int flags)        { this{name, default_preemption(), flags}; }
     262static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
     263static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
     264static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
    170265
    171266static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; }
Note: See TracChangeset for help on using the changeset viewer.