Ignore:
Timestamp:
Jan 9, 2021, 4:27:57 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
561dd26
Parents:
35fd2c4
Message:

Added prints.
Naive implementation of cancel.
Server now shutdown cleanly.

File:
1 edited

Legend:

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

    r35fd2c4 rece0e80  
    134134                int ret = 0;
    135135                if( need_sys_to_submit || need_sys_to_complete ) {
     136                        __cfadbg_print_safe(io_core, "Kernel I/O : IO_URING enter %d %u %u\n", ring.fd, to_submit, flags);
    136137                        ret = syscall( __NR_io_uring_enter, ring.fd, to_submit, 0, flags, (sigset_t *)0p, _NSIG / 8);
    137138                        if( ret < 0 ) {
     
    230231                __cfadbg_print_safe(io_core, "Kernel I/O : IO poller %p for ring %p ready\n", &this, &this.ring);
    231232
    232                 int reset = 0;
     233                const int reset_cnt = 5;
     234                int reset = reset_cnt;
    233235                // Then loop until we need to start
     236                LOOP:
    234237                while(!__atomic_load_n(&this.done, __ATOMIC_SEQ_CST)) {
    235238                        // Drain the io
     
    239242                                [count, again] = __drain_io( *this.ring );
    240243
    241                                 if(!again) reset++;
     244                                if(!again) reset--;
    242245
    243246                                // Update statistics
     
    249252
    250253                        // If we got something, just yield and check again
    251                         if(reset < 5) {
     254                        if(reset > 1) {
    252255                                yield();
    253                         }
    254                         // We didn't get anything baton pass to the slow poller
    255                         else {
     256                                continue LOOP;
     257                        }
     258
     259                        // We alread failed to find events a few time.
     260                        if(reset == 1) {
     261                                // Rearm the context so it can block
     262                                // but don't block right away
     263                                // we need to retry one last time in case
     264                                // something completed *just now*
     265                                __ioctx_prepare_block( this, ev );
     266                                continue LOOP;
     267                        }
     268
    256269                                __STATS__( false,
    257270                                        io.complete_q.blocks += 1;
    258271                                )
    259272                                __cfadbg_print_safe(io_core, "Kernel I/O : Parking io poller %p\n", &this.self);
    260                                 reset = 0;
    261273
    262274                                // block this thread
    263                                 __ioctx_prepare_block( this, ev );
    264275                                wait( this.sem );
    265                         }
     276
     277                        // restore counter
     278                        reset = reset_cnt;
    266279                }
    267280
     
    319332                                        )
    320333
     334                                        __cfadbg_print_safe( io, "Kernel I/O : allocated [%p, %u] for %p (%p)\n", sqe, idx, active_thread(), (void*)data );
    321335
    322336                                        // Success return the data
     
    376390
    377391        void __submit( struct io_context * ctx, __u32 idx ) __attribute__((nonnull (1))) {
     392                __cfadbg_print_safe( io, "Kernel I/O : submitting %u for %p\n", idx, active_thread() );
     393
    378394                __io_data & ring = *ctx->thrd.ring;
    379395                // Get now the data we definetely need
     
    443459                                unlock(ring.submit_q.submit_lock);
    444460                        #endif
    445                         if( ret < 0 ) return;
     461                        if( ret < 0 ) {
     462                                return;
     463                        }
    446464
    447465                        // Release the consumed SQEs
     
    454472                                io.submit_q.submit_avg.cnt += 1;
    455473                        )
     474
     475                        __cfadbg_print_safe( io, "Kernel I/O : submitted %u (among %u) for %p\n", idx, ret, active_thread() );
    456476                }
    457477                else {
Note: See TracChangeset for help on using the changeset viewer.