Ignore:
File:
1 edited

Legend:

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

    rd3605f8 r6ddef36  
    2727extern "C" {
    2828        #include <sys/eventfd.h>
    29         #include <sys/uio.h>
    3029}
    3130
     
    126125static void __wake_one(cluster * cltr);
    127126
    128 static void idle_sleep(processor * proc, io_future_t & future, iovec & iov);
     127static void idle_sleep(processor * proc, io_future_t & future, char buf[]);
    129128static bool mark_idle (__cluster_proc_list & idles, processor & proc);
    130129static void mark_awake(__cluster_proc_list & idles, processor & proc);
     
    132131extern void __cfa_io_start( processor * );
    133132extern bool __cfa_io_drain( processor * );
    134 extern bool __cfa_io_flush( processor *, int min_comp );
     133extern bool __cfa_io_flush( processor *, bool wait );
    135134extern void __cfa_io_stop ( processor * );
    136135static inline bool __maybe_io_drain( processor * );
    137136
    138 #if defined(CFA_WITH_IO_URING_IDLE)
    139         extern bool __kernel_read(processor * proc, io_future_t & future, iovec &, int fd);
     137#if defined(IO_URING_IDLE) && defined(CFA_HAVE_LINUX_IO_URING_H)
     138        extern bool __kernel_read(processor * proc, io_future_t & future, char buf[], int fd);
    140139#endif
    141140
     
    172171        io_future_t future; // used for idle sleep when io_uring is present
    173172        future.self.ptr = 1p;  // mark it as already fulfilled so we know if there is a pending request or not
    174         eventfd_t idle_val;
    175         iovec idle_iovec = { &idle_val, sizeof(idle_val) };
     173        char buf[sizeof(uint64_t)];
    176174
    177175        __cfa_io_start( this );
     
    208206
    209207                        if( !readyThread ) {
    210                                 __cfa_io_flush( this, 0 );
     208                                __cfa_io_flush( this, false );
    211209
    212210                                readyThread = __next_thread_slow( this->cltr );
     
    239237                                }
    240238
    241                                 idle_sleep( this, future, idle_iovec );
     239                                idle_sleep( this, future, buf );
    242240
    243241                                // We were woken up, remove self from idle
     
    260258
    261259                        if(this->io.pending && !this->io.dirty) {
    262                                 __cfa_io_flush( this, 0 );
     260                                __cfa_io_flush( this, false );
    263261                        }
    264262
     
    276274
    277275                                // If we can't find a thread, might as well flush any outstanding I/O
    278                                 if(this->io.pending) { __cfa_io_flush( this, 0 ); }
     276                                if(this->io.pending) { __cfa_io_flush( this, false ); }
    279277
    280278                                // Spin a little on I/O, just in case
     
    371369
    372370                        if(this->io.pending && !this->io.dirty) {
    373                                 __cfa_io_flush( this, 0 );
     371                                __cfa_io_flush( this, false );
    374372                        }
    375373
     
    381379
    382380                __cfadbg_print_safe(runtime_core, "Kernel : core %p stopping\n", this);
    383         }
    384 
    385         for(int i = 0; !available(future); i++) {
    386                 if(i > 1000) __cfaabi_dbg_write( "ERROR: kernel has bin spinning on a flush after exit loop.\n", 60);
    387                 __cfa_io_flush( this, 1 );
    388381        }
    389382
     
    786779}
    787780
    788 static void idle_sleep(processor * this, io_future_t & future, iovec & iov) {
    789         #if !defined(CFA_WITH_IO_URING_IDLE)
     781static void idle_sleep(processor * this, io_future_t & future, char buf[]) {
     782        #if !defined(IO_URING_IDLE) || !defined(CFA_HAVE_LINUX_IO_URING_H)
    790783                #if !defined(__CFA_NO_STATISTICS__)
    791784                        if(this->print_halts) {
     
    820813                #endif
    821814        #else
     815                #if !defined(CFA_HAVE_IORING_OP_READ)
     816                        #error this is only implemented if the read is present
     817                #endif
    822818                // Do we already have a pending read
    823819                if(available(future)) {
     
    825821                        reset(future);
    826822
    827                         __kernel_read(this, future, iov, this->idle_fd );
    828                 }
    829 
    830                 __cfa_io_flush( this, 1 );
     823                        __kernel_read(this, future, buf, this->idle_fd );
     824                }
     825
     826                __cfa_io_flush( this, true );
    831827        #endif
    832828}
Note: See TracChangeset for help on using the changeset viewer.