Ignore:
File:
1 edited

Legend:

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

    rd3605f8 re8ac228  
    3333                #include <sys/syscall.h>
    3434                #include <sys/eventfd.h>
    35                 #include <sys/uio.h>
    3635
    3736                #include <linux/io_uring.h>
     
    134133        }
    135134
    136         bool __cfa_io_flush( processor * proc, int min_comp ) {
     135        void __cfa_io_flush( processor * proc ) {
    137136                /* paranoid */ verify( ! __preemption_enabled() );
    138137                /* paranoid */ verify( proc );
     
    142141                $io_context & ctx = *proc->io.ctx;
    143142
     143                // for(i; 2) {
     144                //      unsigned idx = proc->rdq.id + i;
     145                //      cltr->ready_queue.lanes.tscs[idx].tv = -1ull;
     146                // }
     147
    144148                __ioarbiter_flush( ctx );
    145149
    146150                __STATS__( true, io.calls.flush++; )
    147                 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);
     151                int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, 0, 0, (sigset_t *)0p, _NSIG / 8);
    148152                if( ret < 0 ) {
    149153                        switch((int)errno) {
     
    153157                                // Update statistics
    154158                                __STATS__( false, io.calls.errors.busy ++; )
    155                                 return false;
     159                                // for(i; 2) {
     160                                //      unsigned idx = proc->rdq.id + i;
     161                                //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
     162                                // }
     163                                return;
    156164                        default:
    157165                                abort( "KERNEL ERROR: IO_URING SYSCALL - (%d) %s\n", (int)errno, strerror(errno) );
     
    174182
    175183                ctx.proc->io.pending = false;
    176                 ready_schedule_lock();
    177                 bool ret = __cfa_io_drain( proc );
    178                 ready_schedule_unlock();
    179                 return ret;
     184
     185                __cfa_io_drain( proc );
     186                // for(i; 2) {
     187                //      unsigned idx = proc->rdq.id + i;
     188                //      cltr->ready_queue.lanes.tscs[idx].tv = rdtscl();
     189                // }
    180190        }
    181191
     
    281291        }
    282292
     293
    283294        //=============================================================================================
    284295        // submission
     
    303314                ctx->proc->io.dirty   = true;
    304315                if(sq.to_submit > 30 || !lazy) {
    305                         __cfa_io_flush( ctx->proc, 0 );
     316                        ready_schedule_lock();
     317                        __cfa_io_flush( ctx->proc );
     318                        ready_schedule_unlock();
    306319                }
    307320        }
     
    502515                }
    503516        }
    504 
    505         #if defined(CFA_WITH_IO_URING_IDLE)
    506                 bool __kernel_read(processor * proc, io_future_t & future, iovec & iov, int fd) {
    507                         $io_context * ctx = proc->io.ctx;
    508                         /* paranoid */ verify( ! __preemption_enabled() );
    509                         /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
    510                         /* paranoid */ verify( ctx );
    511 
    512                         __u32 idx;
    513                         struct io_uring_sqe * sqe;
    514 
    515                         // We can proceed to the fast path
    516                         if( !__alloc(ctx, &idx, 1) ) return false;
    517 
    518                         // Allocation was successful
    519                         __fill( &sqe, 1, &idx, ctx );
    520 
    521                         sqe->user_data = (uintptr_t)&future;
    522                         sqe->flags = 0;
    523                         sqe->fd = fd;
    524                         sqe->off = 0;
    525                         sqe->ioprio = 0;
    526                         sqe->fsync_flags = 0;
    527                         sqe->__pad2[0] = 0;
    528                         sqe->__pad2[1] = 0;
    529                         sqe->__pad2[2] = 0;
    530 
    531                         #if defined(CFA_HAVE_IORING_OP_READ)
    532                                 sqe->opcode = IORING_OP_READ;
    533                                 sqe->addr = (uint64_t)iov.iov_base;
    534                                 sqe->len = iov.iov_len;
    535                         #elif defined(CFA_HAVE_READV) && defined(CFA_HAVE_IORING_OP_READV)
    536                                 sqe->opcode = IORING_OP_READV;
    537                                 sqe->addr = (uintptr_t)&iov;
    538                                 sqe->len = 1;
    539                         #else
    540                                 #error CFA_WITH_IO_URING_IDLE but none of CFA_HAVE_READV, CFA_HAVE_IORING_OP_READV or CFA_HAVE_IORING_OP_READ defined
    541                         #endif
    542 
    543                         asm volatile("": : :"memory");
    544 
    545                         /* paranoid */ verify( sqe->user_data == (uintptr_t)&future );
    546                         __submit( ctx, &idx, 1, true );
    547 
    548                         /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
    549                         /* paranoid */ verify( ! __preemption_enabled() );
    550                 }
    551         #endif
    552517#endif
Note: See TracChangeset for help on using the changeset viewer.