Ignore:
Timestamp:
Nov 22, 2021, 1:07:05 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
6ddef36, ddd2ec9
Parents:
059ad16
Message:

First attempt at using io_uring_enter for idle sleep.

File:
1 edited

Legend:

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

    r059ad16 r7ef162b2  
    173173
    174174                ctx.proc->io.pending = false;
    175 
    176                 return __cfa_io_drain( proc );
     175                ready_schedule_lock();
     176                bool ret = __cfa_io_drain( proc );
     177                ready_schedule_unlock();
     178                return ret;
    177179        }
    178180
     
    278280        }
    279281
    280 
    281282        //=============================================================================================
    282283        // submission
     
    301302                ctx->proc->io.dirty   = true;
    302303                if(sq.to_submit > 30 || !lazy) {
    303                         ready_schedule_lock();
    304304                        __cfa_io_flush( ctx->proc, false );
    305                         ready_schedule_unlock();
    306305                }
    307306        }
     
    502501                }
    503502        }
     503
     504        bool __kernel_read(processor * proc, io_future_t & future, char buf[], int fd) {
     505                $io_context * ctx = proc->io.ctx;
     506                /* paranoid */ verify( ! __preemption_enabled() );
     507                /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
     508                /* paranoid */ verify( ctx );
     509
     510                __u32 idx;
     511                struct io_uring_sqe * sqe;
     512
     513                // We can proceed to the fast path
     514                if( !__alloc(ctx, &idx, 1) ) return false;
     515
     516                // Allocation was successful
     517                __fill( &sqe, 1, &idx, ctx );
     518
     519                sqe->opcode = IORING_OP_READ;
     520                sqe->user_data = (uintptr_t)&future;
     521                sqe->flags = 0;
     522                sqe->ioprio = 0;
     523                sqe->fd = 0;
     524                sqe->off = 0;
     525                sqe->fsync_flags = 0;
     526                sqe->__pad2[0] = 0;
     527                sqe->__pad2[1] = 0;
     528                sqe->__pad2[2] = 0;
     529                sqe->addr = (uintptr_t)buf;
     530                sqe->len = sizeof(uint64_t);
     531
     532                asm volatile("": : :"memory");
     533
     534                /* paranoid */ verify( sqe->user_data == (uintptr_t)&future );
     535                __submit( ctx, &idx, 1, true );
     536
     537                /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
     538                /* paranoid */ verify( ! __preemption_enabled() );
     539        }
    504540#endif
Note: See TracChangeset for help on using the changeset viewer.