Ignore:
Timestamp:
Aug 14, 2020, 12:33:26 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7fdae38
Parents:
b353a49
Message:

I/O now uses onshot semaphore instead of raw park/unpark.
I/O now uses linux/types.h types instead of stdint.h types

Location:
libcfa/src/concurrency/io
Files:
2 edited

Legend:

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

    rb353a49 r4998155  
    298298                if( params_in.poll_complete ) params.flags |= IORING_SETUP_IOPOLL;
    299299
    300                 uint32_t nentries = params_in.num_entries != 0 ? params_in.num_entries : 256;
     300                __u32 nentries = params_in.num_entries != 0 ? params_in.num_entries : 256;
    301301                if( !is_pow2(nentries) ) {
    302302                        abort("ERROR: I/O setup 'num_entries' must be a power of 2\n");
     
    362362                // Get the pointers from the kernel to fill the structure
    363363                // submit queue
    364                 sq.head    = (volatile uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.head);
    365                 sq.tail    = (volatile uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.tail);
    366                 sq.mask    = (   const uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.ring_mask);
    367                 sq.num     = (   const uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.ring_entries);
    368                 sq.flags   = (         uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.flags);
    369                 sq.dropped = (         uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.dropped);
    370                 sq.array   = (         uint32_t *)(((intptr_t)sq.ring_ptr) + params.sq_off.array);
     364                sq.head    = (volatile __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.head);
     365                sq.tail    = (volatile __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.tail);
     366                sq.mask    = (   const __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.ring_mask);
     367                sq.num     = (   const __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.ring_entries);
     368                sq.flags   = (         __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.flags);
     369                sq.dropped = (         __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.dropped);
     370                sq.array   = (         __u32 *)(((intptr_t)sq.ring_ptr) + params.sq_off.array);
    371371                sq.prev_head = *sq.head;
    372372
    373373                {
    374                         const uint32_t num = *sq.num;
     374                        const __u32 num = *sq.num;
    375375                        for( i; num ) {
    376376                                sq.sqes[i].user_data = 0ul64;
     
    395395
    396396                // completion queue
    397                 cq.head     = (volatile uint32_t *)(((intptr_t)cq.ring_ptr) + params.cq_off.head);
    398                 cq.tail     = (volatile uint32_t *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail);
    399                 cq.mask     = (   const uint32_t *)(((intptr_t)cq.ring_ptr) + params.cq_off.ring_mask);
    400                 cq.num      = (   const uint32_t *)(((intptr_t)cq.ring_ptr) + params.cq_off.ring_entries);
    401                 cq.overflow = (         uint32_t *)(((intptr_t)cq.ring_ptr) + params.cq_off.overflow);
    402                 cq.cqes   = (struct io_uring_cqe *)(((intptr_t)cq.ring_ptr) + params.cq_off.cqes);
     397                cq.head      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.head);
     398                cq.tail      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail);
     399                cq.mask      = (   const __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.ring_mask);
     400                cq.num       = (   const __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.ring_entries);
     401                cq.overflow  = (         __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.overflow);
     402                cq.cqes = (struct io_uring_cqe *)(((intptr_t)cq.ring_ptr) + params.cq_off.cqes);
    403403
    404404                // some paranoid checks
     
    448448        void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev) {
    449449                ev.events = EPOLLIN | EPOLLONESHOT;
    450                 ev.data.u64 = (uint64_t)&ctx;
     450                ev.data.u64 = (__u64)&ctx;
    451451                int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_ADD, ctx.ring->fd, &ev);
    452452                if (ret < 0) {
  • libcfa/src/concurrency/io/types.hfa

    rb353a49 r4998155  
    1717
    1818#if defined(CFA_HAVE_LINUX_IO_URING_H)
     19        extern "C" {
     20                #include <linux/types.h>
     21        }
     22
    1923      #include "bits/locks.hfa"
    2024
     
    2327      struct __submition_data {
    2428                // Head and tail of the ring (associated with array)
    25                 volatile uint32_t * head;
    26                 volatile uint32_t * tail;
    27                 volatile uint32_t prev_head;
     29                volatile __u32 * head;
     30                volatile __u32 * tail;
     31                volatile __u32 prev_head;
    2832
    2933                // The actual kernel ring which uses head/tail
    3034                // indexes into the sqes arrays
    31                 uint32_t * array;
     35                __u32 * array;
    3236
    3337                // number of entries and mask to go with it
    34                 const uint32_t * num;
    35                 const uint32_t * mask;
     38                const __u32 * num;
     39                const __u32 * mask;
    3640
    3741                // Submission flags (Not sure what for)
    38                 uint32_t * flags;
     42                __u32 * flags;
    3943
    4044                // number of sqes not submitted (whatever that means)
    41                 uint32_t * dropped;
     45                __u32 * dropped;
    4246
    4347                // Like head/tail but not seen by the kernel
    44                 volatile uint32_t * ready;
    45                 uint32_t ready_cnt;
     48                volatile __u32 * ready;
     49                __u32 ready_cnt;
    4650
    4751                __spinlock_t lock;
     
    5862        struct __completion_data {
    5963                // Head and tail of the ring
    60                 volatile uint32_t * head;
    61                 volatile uint32_t * tail;
     64                volatile __u32 * head;
     65                volatile __u32 * tail;
    6266
    6367                // number of entries and mask to go with it
    64                 const uint32_t * mask;
    65                 const uint32_t * num;
     68                const __u32 * mask;
     69                const __u32 * num;
    6670
    6771                // number of cqes not submitted (whatever that means)
    68                 uint32_t * overflow;
     72                __u32 * overflow;
    6973
    7074                // the kernel ring
     
    7983                struct __submition_data submit_q;
    8084                struct __completion_data completion_q;
    81                 uint32_t ring_flags;
     85                __u32 ring_flags;
    8286                int fd;
    8387                bool eager_submits:1;
     
    8993        // IO user data
    9094        struct __io_user_data_t {
    91                 int32_t result;
    92                 $thread * thrd;
     95                __s32 result;
     96                oneshot sem;
    9397        };
    9498
Note: See TracChangeset for help on using the changeset viewer.