Ignore:
Timestamp:
Mar 21, 2022, 1:44:06 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
a76202d
Parents:
ef3c383 (diff), dbe2533 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

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

Legend:

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

    ref3c383 rd672350  
    3939
    4040#else
     41#pragma GCC diagnostic push
     42#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
    4143        #include <errno.h>
    4244        #include <stdint.h>
     
    5658
    5759        #include "bitmanip.hfa"
    58         #include "kernel_private.hfa"
     60        #include "fstream.hfa"
     61        #include "kernel/private.hfa"
    5962        #include "thread.hfa"
     63#pragma GCC diagnostic pop
    6064
    6165        void ?{}(io_context_params & this) {
     
    111115                this.ext_sq.empty = true;
    112116                (this.ext_sq.queue){};
    113                 __io_uring_setup( this, cl.io.params, proc->idle_fd );
     117                __io_uring_setup( this, cl.io.params, proc->idle_wctx.evfd );
    114118                __cfadbg_print_safe(io_core, "Kernel I/O : Created ring for io_context %u (%p)\n", this.fd, &this);
    115119        }
     
    121125                __cfadbg_print_safe(io_core, "Kernel I/O : Destroyed ring for io_context %u\n", this.fd);
    122126        }
    123 
    124         extern void __disable_interrupts_hard();
    125         extern void __enable_interrupts_hard();
    126127
    127128        static void __io_uring_setup( $io_context & this, const io_context_params & params_in, int procfd ) {
     
    213214
    214215                // completion queue
     216                cq.lock      = 0;
    215217                cq.head      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.head);
    216218                cq.tail      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail);
     
    226228                        __cfadbg_print_safe(io_core, "Kernel I/O : registering %d for completion with ring %d\n", procfd, fd);
    227229
    228                         __disable_interrupts_hard();
    229 
    230230                        int ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &procfd, 1);
    231231                        if (ret < 0) {
    232232                                abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno));
    233233                        }
    234 
    235                         __enable_interrupts_hard();
    236234
    237235                        __cfadbg_print_safe(io_core, "Kernel I/O : registered %d for completion with ring %d\n", procfd, fd);
     
    258256                struct __sub_ring_t & sq = this.sq;
    259257                struct __cmp_ring_t & cq = this.cq;
     258                {
     259                        __u32 fhead = sq.free_ring.head;
     260                        __u32 ftail = sq.free_ring.tail;
     261
     262                        __u32 total = *sq.num;
     263                        __u32 avail = ftail - fhead;
     264
     265                        if(avail != total) abort | "Processor (" | (void*)this.proc | ") tearing down ring with" | (total - avail) | "entries allocated but not submitted, out of" | total;
     266                }
    260267
    261268                // unmap the submit queue entries
  • libcfa/src/concurrency/io/types.hfa

    ref3c383 rd672350  
    2323#include "bits/locks.hfa"
    2424#include "bits/queue.hfa"
     25#include "iofwd.hfa"
    2526#include "kernel/fwd.hfa"
    2627
     
    7778
    7879        struct __cmp_ring_t {
     80                volatile bool lock;
     81
    7982                // Head and tail of the ring
    8083                volatile __u32 * head;
     
    170173        // void __ioctx_prepare_block($io_context & ctx);
    171174#endif
    172 
    173 //-----------------------------------------------------------------------
    174 // IO user data
    175 struct io_future_t {
    176         future_t self;
    177         __s32 result;
    178 };
    179 
    180 static inline {
    181         thread$ * fulfil( io_future_t & this, __s32 result, bool do_unpark = true ) {
    182                 this.result = result;
    183                 return fulfil(this.self, do_unpark);
    184         }
    185 
    186         // Wait for the future to be fulfilled
    187         bool wait     ( io_future_t & this ) { return wait     (this.self); }
    188         void reset    ( io_future_t & this ) { return reset    (this.self); }
    189         bool available( io_future_t & this ) { return available(this.self); }
    190 }
Note: See TracChangeset for help on using the changeset viewer.