Changeset c7b2215 for libcfa/src


Ignore:
Timestamp:
Nov 29, 2021, 12:50:31 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
a1f3d93
Parents:
ddd2ec9
Message:

Fix implementation of io_uring_enter instead of eventfds.

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

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

    rddd2ec9 rc7b2215  
    133133        }
    134134
    135         bool __cfa_io_flush( processor * proc, bool wait ) {
     135        bool __cfa_io_flush( processor * proc, int min_comp ) {
    136136                /* paranoid */ verify( ! __preemption_enabled() );
    137137                /* paranoid */ verify( proc );
     
    144144
    145145                __STATS__( true, io.calls.flush++; )
    146                 int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, wait ? 1 : 0, 0, (sigset_t *)0p, _NSIG / 8);
     146                int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, min_comp, min_comp > 0 ? IORING_ENTER_GETEVENTS : 0, (sigset_t *)0p, _NSIG / 8);
    147147                if( ret < 0 ) {
    148148                        switch((int)errno) {
     
    302302                ctx->proc->io.dirty   = true;
    303303                if(sq.to_submit > 30 || !lazy) {
    304                         __cfa_io_flush( ctx->proc, false );
     304                        __cfa_io_flush( ctx->proc, 0 );
    305305                }
    306306        }
     
    521521                sqe->flags = 0;
    522522                sqe->ioprio = 0;
    523                 sqe->fd = 0;
     523                sqe->fd = fd;
    524524                sqe->off = 0;
    525525                sqe->fsync_flags = 0;
  • libcfa/src/concurrency/io/setup.cfa

    rddd2ec9 rc7b2215  
    3232
    3333        void __cfa_io_start( processor * proc ) {}
    34         bool __cfa_io_flush( processor * proc, bool ) {}
     34        bool __cfa_io_flush( processor * proc, int ) {}
    3535        void __cfa_io_stop ( processor * proc ) {}
    3636
  • libcfa/src/concurrency/kernel.cfa

    rddd2ec9 rc7b2215  
    125125static void __wake_one(cluster * cltr);
    126126
    127 static void idle_sleep(processor * proc, io_future_t & future, char buf[]);
     127static void idle_sleep(processor * proc, io_future_t & future, eventfd_t & val);
    128128static bool mark_idle (__cluster_proc_list & idles, processor & proc);
    129129static void mark_awake(__cluster_proc_list & idles, processor & proc);
     
    131131extern void __cfa_io_start( processor * );
    132132extern bool __cfa_io_drain( processor * );
    133 extern bool __cfa_io_flush( processor *, bool wait );
     133extern bool __cfa_io_flush( processor *, int min_comp );
    134134extern void __cfa_io_stop ( processor * );
    135135static inline bool __maybe_io_drain( processor * );
     
    169169        io_future_t future; // used for idle sleep when io_uring is present
    170170        future.self.ptr = 1p;  // mark it as already fulfilled so we know if there is a pending request or not
    171         char buf[sizeof(uint64_t)];
     171        eventfd_t idle_val;
    172172
    173173        __cfa_io_start( this );
     
    204204
    205205                        if( !readyThread ) {
    206                                 __cfa_io_flush( this, false );
     206                                __cfa_io_flush( this, 0 );
    207207
    208208                                readyThread = __next_thread_slow( this->cltr );
     
    235235                                }
    236236
    237                                 idle_sleep( this, future, buf );
     237                                idle_sleep( this, future, idle_val );
    238238
    239239                                // We were woken up, remove self from idle
     
    256256
    257257                        if(this->io.pending && !this->io.dirty) {
    258                                 __cfa_io_flush( this, false );
     258                                __cfa_io_flush( this, 0 );
    259259                        }
    260260
     
    272272
    273273                                // If we can't find a thread, might as well flush any outstanding I/O
    274                                 if(this->io.pending) { __cfa_io_flush( this, false ); }
     274                                if(this->io.pending) { __cfa_io_flush( this, 0 ); }
    275275
    276276                                // Spin a little on I/O, just in case
     
    367367
    368368                        if(this->io.pending && !this->io.dirty) {
    369                                 __cfa_io_flush( this, false );
     369                                __cfa_io_flush( this, 0 );
    370370                        }
    371371
     
    777777}
    778778
    779 static void idle_sleep(processor * this, io_future_t & future, char buf[]) {
     779static void idle_sleep(processor * this, io_future_t & future, eventfd_t & val) {
    780780        #if !defined(IO_URING_IDLE) || !defined(CFA_HAVE_LINUX_IO_URING_H)
    781781                #if !defined(__CFA_NO_STATISTICS__)
     
    819819                        reset(future);
    820820
    821                         __kernel_read(this, future, buf, this->idle_fd );
    822                 }
    823 
    824                 __cfa_io_flush( this, true );
     821                        __kernel_read(this, future, (char *)&val, this->idle_fd );
     822                }
     823
     824                __cfa_io_flush( this, 1 );
    825825        #endif
    826826}
Note: See TracChangeset for help on using the changeset viewer.