Ignore:
Timestamp:
Apr 10, 2022, 2:53:18 PM (4 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
d8e2a09
Parents:
4559b34 (diff), 6256891 (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:

Resolve conflict

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

Legend:

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

    r4559b34 r92538ab  
    3232
    3333        void __cfa_io_start( processor * proc ) {}
    34         bool __cfa_io_flush( processor * proc, int ) { return false; }
     34        bool __cfa_io_flush( processor * proc ) { return false; }
     35        bool __cfa_io_drain( processor * proc ) __attribute__((nonnull (1))) { return false; }
     36        void __cfa_io_idle ( processor * ) __attribute__((nonnull (1))) {}
    3537        void __cfa_io_stop ( processor * proc ) {}
    3638
     
    3941
    4042#else
     43#pragma GCC diagnostic push
     44#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
    4145        #include <errno.h>
    4246        #include <stdint.h>
     
    5660
    5761        #include "bitmanip.hfa"
    58         #include "kernel_private.hfa"
     62        #include "fstream.hfa"
     63        #include "kernel/private.hfa"
     64        #include "limits.hfa"
    5965        #include "thread.hfa"
     66#pragma GCC diagnostic pop
    6067
    6168        void ?{}(io_context_params & this) {
     
    111118                this.ext_sq.empty = true;
    112119                (this.ext_sq.queue){};
    113                 __io_uring_setup( this, cl.io.params, proc->idle_fd );
     120                __io_uring_setup( this, cl.io.params, proc->idle_wctx.evfd );
    114121                __cfadbg_print_safe(io_core, "Kernel I/O : Created ring for io_context %u (%p)\n", this.fd, &this);
    115122        }
     
    121128                __cfadbg_print_safe(io_core, "Kernel I/O : Destroyed ring for io_context %u\n", this.fd);
    122129        }
    123 
    124         extern void __disable_interrupts_hard();
    125         extern void __enable_interrupts_hard();
    126130
    127131        static void __io_uring_setup( $io_context & this, const io_context_params & params_in, int procfd ) {
     
    213217
    214218                // completion queue
     219                cq.lock      = false;
     220                cq.id        = MAX;
     221                cq.ts        = rdtscl();
    215222                cq.head      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.head);
    216223                cq.tail      = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail);
     
    226233                        __cfadbg_print_safe(io_core, "Kernel I/O : registering %d for completion with ring %d\n", procfd, fd);
    227234
    228                         __disable_interrupts_hard();
    229 
    230235                        int ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &procfd, 1);
    231236                        if (ret < 0) {
    232237                                abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno));
    233238                        }
    234 
    235                         __enable_interrupts_hard();
    236239
    237240                        __cfadbg_print_safe(io_core, "Kernel I/O : registered %d for completion with ring %d\n", procfd, fd);
     
    258261                struct __sub_ring_t & sq = this.sq;
    259262                struct __cmp_ring_t & cq = this.cq;
     263                {
     264                        __u32 fhead = sq.free_ring.head;
     265                        __u32 ftail = sq.free_ring.tail;
     266
     267                        __u32 total = *sq.num;
     268                        __u32 avail = ftail - fhead;
     269
     270                        if(avail != total) abort | "Processor (" | (void*)this.proc | ") tearing down ring with" | (total - avail) | "entries allocated but not submitted, out of" | total;
     271                }
    260272
    261273                // unmap the submit queue entries
  • libcfa/src/concurrency/io/types.hfa

    r4559b34 r92538ab  
    2323#include "bits/locks.hfa"
    2424#include "bits/queue.hfa"
     25#include "iofwd.hfa"
    2526#include "kernel/fwd.hfa"
     27#include "limits.hfa"
    2628
    2729#if defined(CFA_HAVE_LINUX_IO_URING_H)
     
    7779
    7880        struct __cmp_ring_t {
     81                volatile bool lock;
     82
     83                unsigned id;
     84
     85                unsigned long long ts;
     86
    7987                // Head and tail of the ring
    8088                volatile __u32 * head;
     
    128136        };
    129137
     138        static inline unsigned long long ts($io_context *& this) {
     139                const __u32 head = *this->cq.head;
     140                const __u32 tail = *this->cq.tail;
     141
     142                if(head == tail) return MAX;
     143
     144                return this->cq.ts;
     145        }
     146
    130147        struct __pending_alloc {
    131148                inline __outstanding_io;
     
    170187        // void __ioctx_prepare_block($io_context & ctx);
    171188#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.