Ignore:
File:
1 edited

Legend:

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

    r24e321c r2514f68b  
    133133        }
    134134
    135         void __cfa_io_flush( processor * proc ) {
     135        bool __cfa_io_flush( processor * proc, bool wait ) {
    136136                /* paranoid */ verify( ! __preemption_enabled() );
    137137                /* paranoid */ verify( proc );
     
    141141                $io_context & ctx = *proc->io.ctx;
    142142
    143                 // for(i; 2) {
    144                 //      unsigned idx = proc->rdq.id + i;
    145                 //      cltr->ready_queue.lanes.tscs[idx].tv = -1ull;
    146                 // }
    147 
    148143                __ioarbiter_flush( ctx );
    149144
    150145                __STATS__( true, io.calls.flush++; )
    151                 int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, 0, 0, (sigset_t *)0p, _NSIG / 8);
     146                int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, wait ? 1 : 0, 0, (sigset_t *)0p, _NSIG / 8);
    152147                if( ret < 0 ) {
    153148                        switch((int)errno) {
     
    157152                                // Update statistics
    158153                                __STATS__( false, io.calls.errors.busy ++; )
    159                                 // for(i; 2) {
    160                                 //      unsigned idx = proc->rdq.id + i;
    161                                 //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
    162                                 // }
    163                                 return;
     154                                return false;
    164155                        default:
    165156                                abort( "KERNEL ERROR: IO_URING SYSCALL - (%d) %s\n", (int)errno, strerror(errno) );
     
    182173
    183174                ctx.proc->io.pending = false;
    184 
    185175                ready_schedule_lock();
    186                 __cfa_io_drain( proc );
     176                bool ret = __cfa_io_drain( proc );
    187177                ready_schedule_unlock();
    188                 // for(i; 2) {
    189                 //      unsigned idx = proc->rdq.id + i;
    190                 //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
    191                 // }
     178                return ret;
    192179        }
    193180
     
    293280        }
    294281
    295 
    296282        //=============================================================================================
    297283        // submission
     
    311297                // Make the sqes visible to the submitter
    312298                __atomic_store_n(sq.kring.tail, tail + have, __ATOMIC_RELEASE);
    313                 sq.to_submit++;
     299                sq.to_submit += have;
    314300
    315301                ctx->proc->io.pending = true;
    316302                ctx->proc->io.dirty   = true;
    317303                if(sq.to_submit > 30 || !lazy) {
    318                         __cfa_io_flush( ctx->proc );
     304                        __cfa_io_flush( ctx->proc, false );
    319305                }
    320306        }
     
    515501                }
    516502        }
     503
     504        #if defined(IO_URING_IDLE)
     505                bool __kernel_read(processor * proc, io_future_t & future, char buf[], int fd) {
     506                        $io_context * ctx = proc->io.ctx;
     507                        /* paranoid */ verify( ! __preemption_enabled() );
     508                        /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
     509                        /* paranoid */ verify( ctx );
     510
     511                        __u32 idx;
     512                        struct io_uring_sqe * sqe;
     513
     514                        // We can proceed to the fast path
     515                        if( !__alloc(ctx, &idx, 1) ) return false;
     516
     517                        // Allocation was successful
     518                        __fill( &sqe, 1, &idx, ctx );
     519
     520                        sqe->opcode = IORING_OP_READ;
     521                        sqe->user_data = (uintptr_t)&future;
     522                        sqe->flags = 0;
     523                        sqe->ioprio = 0;
     524                        sqe->fd = 0;
     525                        sqe->off = 0;
     526                        sqe->fsync_flags = 0;
     527                        sqe->__pad2[0] = 0;
     528                        sqe->__pad2[1] = 0;
     529                        sqe->__pad2[2] = 0;
     530                        sqe->addr = (uintptr_t)buf;
     531                        sqe->len = sizeof(uint64_t);
     532
     533                        asm volatile("": : :"memory");
     534
     535                        /* paranoid */ verify( sqe->user_data == (uintptr_t)&future );
     536                        __submit( ctx, &idx, 1, true );
     537
     538                        /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
     539                        /* paranoid */ verify( ! __preemption_enabled() );
     540                }
     541        #endif
    517542#endif
Note: See TracChangeset for help on using the changeset viewer.