Changeset 8bee858 for libcfa


Ignore:
Timestamp:
Aug 15, 2022, 11:19:28 AM (21 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
d93ea1d
Parents:
41a6a78
Message:

Changed io types to have trailing $ instead of leading

Location:
libcfa/src/concurrency
Files:
9 edited

Legend:

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

    r41a6a78 r8bee858  
    8383        };
    8484
    85         static $io_context * __ioarbiter_allocate( $io_arbiter & this, __u32 idxs[], __u32 want );
    86         static void __ioarbiter_submit( $io_context * , __u32 idxs[], __u32 have, bool lazy );
    87         static void __ioarbiter_flush ( $io_context & );
    88         static inline void __ioarbiter_notify( $io_context & ctx );
     85        static io_context$ * __ioarbiter_allocate( io_arbiter$ & this, __u32 idxs[], __u32 want );
     86        static void __ioarbiter_submit( io_context$ * , __u32 idxs[], __u32 have, bool lazy );
     87        static void __ioarbiter_flush ( io_context$ & );
     88        static inline void __ioarbiter_notify( io_context$ & ctx );
    8989//=============================================================================================
    9090// I/O Polling
    9191//=============================================================================================
    92         static inline unsigned __flush( struct $io_context & );
    93         static inline __u32 __release_sqes( struct $io_context & );
     92        static inline unsigned __flush( struct io_context$ & );
     93        static inline __u32 __release_sqes( struct io_context$ & );
    9494        extern void __kernel_unpark( thread$ * thrd, unpark_hint );
    9595
    96         static void ioring_syscsll( struct $io_context & ctx, unsigned int min_comp, unsigned int flags ) {
     96        static void ioring_syscsll( struct io_context$ & ctx, unsigned int min_comp, unsigned int flags ) {
    9797                __STATS__( true, io.calls.flush++; )
    9898                int ret;
     
    132132        }
    133133
    134         static bool try_acquire( $io_context * ctx ) __attribute__((nonnull(1))) {
     134        static bool try_acquire( io_context$ * ctx ) __attribute__((nonnull(1))) {
    135135                /* paranoid */ verify( ! __preemption_enabled() );
    136136                /* paranoid */ verify( ready_schedule_islocked() );
     
    153153        }
    154154
    155         static bool __cfa_do_drain( $io_context * ctx, cluster * cltr ) __attribute__((nonnull(1, 2))) {
     155        static bool __cfa_do_drain( io_context$ * ctx, cluster * cltr ) __attribute__((nonnull(1, 2))) {
    156156                /* paranoid */ verify( ! __preemption_enabled() );
    157157                /* paranoid */ verify( ready_schedule_islocked() );
     
    213213
    214214                cluster * const cltr = proc->cltr;
    215                 $io_context * const ctx = proc->io.ctx;
     215                io_context$ * const ctx = proc->io.ctx;
    216216                /* paranoid */ verify( cltr );
    217217                /* paranoid */ verify( ctx );
     
    278278                /* paranoid */ verify( proc->io.ctx );
    279279
    280                 $io_context & ctx = *proc->io.ctx;
     280                io_context$ & ctx = *proc->io.ctx;
    281281
    282282                __ioarbiter_flush( ctx );
     
    312312        // Allocation
    313313        // for user's convenience fill the sqes from the indexes
    314         static inline void __fill(struct io_uring_sqe * out_sqes[], __u32 want, __u32 idxs[], struct $io_context * ctx)  {
     314        static inline void __fill(struct io_uring_sqe * out_sqes[], __u32 want, __u32 idxs[], struct io_context$ * ctx)  {
    315315                struct io_uring_sqe * sqes = ctx->sq.sqes;
    316316                for(i; want) {
     
    322322        // Try to directly allocate from the a given context
    323323        // Not thread-safe
    324         static inline bool __alloc(struct $io_context * ctx, __u32 idxs[], __u32 want) {
     324        static inline bool __alloc(struct io_context$ * ctx, __u32 idxs[], __u32 want) {
    325325                __sub_ring_t & sq = ctx->sq;
    326326                const __u32 mask  = *sq.mask;
     
    349349        // for convenience, return both the index and the pointer to the sqe
    350350        // sqe == &sqes[idx]
    351         struct $io_context * cfa_io_allocate(struct io_uring_sqe * sqes[], __u32 idxs[], __u32 want) libcfa_public {
     351        struct io_context$ * cfa_io_allocate(struct io_uring_sqe * sqes[], __u32 idxs[], __u32 want) libcfa_public {
    352352                // __cfadbg_print_safe(io, "Kernel I/O : attempting to allocate %u\n", want);
    353353
    354354                disable_interrupts();
    355355                processor * proc = __cfaabi_tls.this_processor;
    356                 $io_context * ctx = proc->io.ctx;
     356                io_context$ * ctx = proc->io.ctx;
    357357                /* paranoid */ verify( __cfaabi_tls.this_processor );
    358358                /* paranoid */ verify( ctx );
     
    378378                enable_interrupts();
    379379
    380                 $io_arbiter * ioarb = proc->cltr->io.arbiter;
     380                io_arbiter$ * ioarb = proc->cltr->io.arbiter;
    381381                /* paranoid */ verify( ioarb );
    382382
    383383                // __cfadbg_print_safe(io, "Kernel I/O : falling back on arbiter for allocation\n");
    384384
    385                 struct $io_context * ret = __ioarbiter_allocate(*ioarb, idxs, want);
     385                struct io_context$ * ret = __ioarbiter_allocate(*ioarb, idxs, want);
    386386
    387387                // __cfadbg_print_safe(io, "Kernel I/O : slow allocation completed from ring %d\n", ret->fd);
     
    393393        //=============================================================================================
    394394        // submission
    395         static inline void __submit_only( struct $io_context * ctx, __u32 idxs[], __u32 have) {
     395        static inline void __submit_only( struct io_context$ * ctx, __u32 idxs[], __u32 have) {
    396396                // We can proceed to the fast path
    397397                // Get the right objects
     
    414414        }
    415415
    416         static inline void __submit( struct $io_context * ctx, __u32 idxs[], __u32 have, bool lazy) {
     416        static inline void __submit( struct io_context$ * ctx, __u32 idxs[], __u32 have, bool lazy) {
    417417                __sub_ring_t & sq = ctx->sq;
    418418                __submit_only(ctx, idxs, have);
     
    428428        }
    429429
    430         void cfa_io_submit( struct $io_context * inctx, __u32 idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1))) libcfa_public {
     430        void cfa_io_submit( struct io_context$ * inctx, __u32 idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1))) libcfa_public {
    431431                // __cfadbg_print_safe(io, "Kernel I/O : attempting to submit %u (%s)\n", have, lazy ? "lazy" : "eager");
    432432
     
    434434                __STATS__( true, if(!lazy) io.submit.eagr += 1; )
    435435                processor * proc = __cfaabi_tls.this_processor;
    436                 $io_context * ctx = proc->io.ctx;
     436                io_context$ * ctx = proc->io.ctx;
    437437                /* paranoid */ verify( __cfaabi_tls.this_processor );
    438438                /* paranoid */ verify( ctx );
     
    465465        // by io_uring
    466466        // This cannot be done by multiple threads
    467         static __u32 __release_sqes( struct $io_context & ctx ) {
     467        static __u32 __release_sqes( struct io_context$ & ctx ) {
    468468                const __u32 mask = *ctx.sq.mask;
    469469
     
    538538        }
    539539
    540         static $io_context * __ioarbiter_allocate( $io_arbiter & this, __u32 idxs[], __u32 want ) {
     540        static io_context$ * __ioarbiter_allocate( io_arbiter$ & this, __u32 idxs[], __u32 want ) {
    541541                // __cfadbg_print_safe(io, "Kernel I/O : arbiter allocating\n");
    542542
     
    557557        }
    558558
    559         static void __ioarbiter_notify( $io_arbiter & this, $io_context * ctx ) {
     559        static void __ioarbiter_notify( io_arbiter$ & this, io_context$ * ctx ) {
    560560                /* paranoid */ verify( !empty(this.pending.queue) );
    561561
     
    587587        }
    588588
    589         static void __ioarbiter_notify( $io_context & ctx ) {
     589        static void __ioarbiter_notify( io_context$ & ctx ) {
    590590                if(!empty( ctx.arbiter->pending )) {
    591591                        __ioarbiter_notify( *ctx.arbiter, &ctx );
     
    594594
    595595        // Simply append to the pending
    596         static void __ioarbiter_submit( $io_context * ctx, __u32 idxs[], __u32 have, bool lazy ) {
     596        static void __ioarbiter_submit( io_context$ * ctx, __u32 idxs[], __u32 have, bool lazy ) {
    597597                __cfadbg_print_safe(io, "Kernel I/O : submitting %u from the arbiter to context %u\n", have, ctx->fd);
    598598
     
    618618        }
    619619
    620         static void __ioarbiter_flush( $io_context & ctx ) {
     620        static void __ioarbiter_flush( io_context$ & ctx ) {
    621621                if(!empty( ctx.ext_sq )) {
    622622                        __STATS__( false, io.flush.external += 1; )
     
    642642        #if defined(CFA_WITH_IO_URING_IDLE)
    643643                bool __kernel_read(processor * proc, io_future_t & future, iovec & iov, int fd) {
    644                         $io_context * ctx = proc->io.ctx;
     644                        io_context$ * ctx = proc->io.ctx;
    645645                        /* paranoid */ verify( ! __preemption_enabled() );
    646646                        /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
  • libcfa/src/concurrency/io/call.cfa.in

    r41a6a78 r8bee858  
    7575        ;
    7676
    77         extern struct $io_context * cfa_io_allocate(struct io_uring_sqe * out_sqes[], __u32 out_idxs[], __u32 want)  __attribute__((nonnull (1,2)));
    78         extern void cfa_io_submit( struct $io_context * in_ctx, __u32 in_idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1,2)));
     77        extern struct io_context$ * cfa_io_allocate(struct io_uring_sqe * out_sqes[], __u32 out_idxs[], __u32 want)  __attribute__((nonnull (1,2)));
     78        extern void cfa_io_submit( struct io_context$ * in_ctx, __u32 in_idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1,2)));
    7979#endif
    8080
     
    200200                __u32 idx;
    201201                struct io_uring_sqe * sqe;
    202                 struct $io_context * ctx = cfa_io_allocate( &sqe, &idx, 1 );
     202                struct io_context$ * ctx = cfa_io_allocate( &sqe, &idx, 1 );
    203203
    204204                sqe->opcode = IORING_OP_{op};
  • libcfa/src/concurrency/io/setup.cfa

    r41a6a78 r8bee858  
    2828        void ?{}(io_context_params & this) libcfa_public {}
    2929
    30         void  ?{}($io_context & this, struct cluster & cl) {}
    31         void ^?{}($io_context & this) {}
     30        void  ?{}(io_context$ & this, struct cluster & cl) {}
     31        void ^?{}(io_context$ & this) {}
    3232
    3333        void __cfa_io_start( processor * proc ) {}
     
    3737        void __cfa_io_stop ( processor * proc ) {}
    3838
    39         $io_arbiter * create(void) { return 0p; }
    40         void destroy($io_arbiter *) {}
     39        io_arbiter$ * create(void) { return 0p; }
     40        void destroy(io_arbiter$ *) {}
    4141
    4242#else
     
    105105
    106106
    107         static void __io_uring_setup ( $io_context & this, const io_context_params & params_in, int procfd );
    108         static void __io_uring_teardown( $io_context & this );
    109         static void __epoll_register($io_context & ctx);
    110         static void __epoll_unregister($io_context & ctx);
    111         void __ioarbiter_register( $io_arbiter & mutex, $io_context & ctx );
    112         void __ioarbiter_unregister( $io_arbiter & mutex, $io_context & ctx );
    113 
    114         void ?{}($io_context & this, processor * proc, struct cluster & cl) {
     107        static void __io_uring_setup ( io_context$ & this, const io_context_params & params_in, int procfd );
     108        static void __io_uring_teardown( io_context$ & this );
     109        static void __epoll_register(io_context$ & ctx);
     110        static void __epoll_unregister(io_context$ & ctx);
     111        void __ioarbiter_register( io_arbiter$ & mutex, io_context$ & ctx );
     112        void __ioarbiter_unregister( io_arbiter$ & mutex, io_context$ & ctx );
     113
     114        void ?{}(io_context$ & this, processor * proc, struct cluster & cl) {
    115115                /* paranoid */ verify( cl.io.arbiter );
    116116                this.proc = proc;
     
    122122        }
    123123
    124         void ^?{}($io_context & this) {
     124        void ^?{}(io_context$ & this) {
    125125                __cfadbg_print_safe(io_core, "Kernel I/O : tearing down io_context %u\n", this.fd);
    126126
     
    129129        }
    130130
    131         static void __io_uring_setup( $io_context & this, const io_context_params & params_in, int procfd ) {
     131        static void __io_uring_setup( io_context$ & this, const io_context_params & params_in, int procfd ) {
    132132                // Step 1 : call to setup
    133133                struct io_uring_params params;
     
    270270        }
    271271
    272         static void __io_uring_teardown( $io_context & this ) {
     272        static void __io_uring_teardown( io_context$ & this ) {
    273273                // Shutdown the io rings
    274274                struct __sub_ring_t & sq = this.sq;
     
    313313// I/O Context Sleep
    314314//=============================================================================================
    315         // static inline void __epoll_ctl($io_context & ctx, int op, const char * error) {
     315        // static inline void __epoll_ctl(io_context$ & ctx, int op, const char * error) {
    316316        //      struct epoll_event ev;
    317317        //      ev.events = EPOLLIN | EPOLLONESHOT;
     
    323323        // }
    324324
    325         // static void __epoll_register($io_context & ctx) {
     325        // static void __epoll_register(io_context$ & ctx) {
    326326        //      __epoll_ctl(ctx, EPOLL_CTL_ADD, "ADD");
    327327        // }
    328328
    329         // static void __epoll_unregister($io_context & ctx) {
     329        // static void __epoll_unregister(io_context$ & ctx) {
    330330        //      // Read the current epoch so we know when to stop
    331331        //      size_t curr = __atomic_load_n(&iopoll.epoch, __ATOMIC_SEQ_CST);
     
    346346        // }
    347347
    348         // void __ioctx_prepare_block($io_context & ctx) {
     348        // void __ioctx_prepare_block(io_context$ & ctx) {
    349349        //      __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Re-arming io poller %d (%p)\n", ctx.fd, &ctx);
    350350        //      __epoll_ctl(ctx, EPOLL_CTL_MOD, "REARM");
     
    355355// I/O Context Misc Setup
    356356//=============================================================================================
    357         void ?{}( $io_arbiter & this ) {
     357        void ?{}( io_arbiter$ & this ) {
    358358                this.pending.empty = true;
    359359        }
    360360
    361         void ^?{}( $io_arbiter & mutex this ) {}
    362 
    363         $io_arbiter * create(void) {
     361        void ^?{}( io_arbiter$ & mutex this ) {}
     362
     363        io_arbiter$ * create(void) {
    364364                return new();
    365365        }
    366         void destroy($io_arbiter * arbiter) {
     366        void destroy(io_arbiter$ * arbiter) {
    367367                delete(arbiter);
    368368        }
  • libcfa/src/concurrency/io/types.hfa

    r41a6a78 r8bee858  
    3333
    3434        struct processor;
    35         monitor $io_arbiter;
     35        monitor io_arbiter$;
    3636
    3737        //-----------------------------------------------------------------------
     
    125125
    126126
    127         struct __attribute__((aligned(64))) $io_context {
    128                 $io_arbiter * arbiter;
     127        struct __attribute__((aligned(64))) io_context$ {
     128                io_arbiter$ * arbiter;
    129129                processor * proc;
    130130
     
    137137        };
    138138
    139         static inline unsigned long long ts($io_context *& this) {
     139        static inline unsigned long long ts(io_context$ *& this) {
    140140                const __u32 head = *this->cq.head;
    141141                const __u32 tail = *this->cq.tail;
     
    150150                __u32 * idxs;
    151151                __u32 want;
    152                 $io_context * ctx;
     152                io_context$ * ctx;
    153153        };
    154154
    155         monitor __attribute__((aligned(64))) $io_arbiter {
     155        monitor __attribute__((aligned(64))) io_arbiter$ {
    156156                __outstanding_io_queue pending;
    157157        };
     
    186186        #endif
    187187
    188         // void __ioctx_prepare_block($io_context & ctx);
     188        // void __ioctx_prepare_block(io_context$ & ctx);
    189189#endif
  • libcfa/src/concurrency/iofwd.hfa

    r41a6a78 r8bee858  
    4949
    5050struct cluster;
    51 struct $io_context;
     51struct io_context$;
    5252
    5353struct iovec;
     
    8282//----------
    8383// underlying calls
    84 extern struct $io_context * cfa_io_allocate(struct io_uring_sqe * out_sqes[], __u32 out_idxs[], __u32 want)  __attribute__((nonnull (1,2)));
    85 extern void cfa_io_submit( struct $io_context * in_ctx, __u32 in_idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1,2)));
     84extern struct io_context$ * cfa_io_allocate(struct io_uring_sqe * out_sqes[], __u32 out_idxs[], __u32 want)  __attribute__((nonnull (1,2)));
     85extern void cfa_io_submit( struct io_context$ * in_ctx, __u32 in_idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1,2)));
    8686
    8787//----------
  • libcfa/src/concurrency/kernel.cfa

    r41a6a78 r8bee858  
    305305        RUNNING:  while(true) {
    306306                thrd_dst->preempted = __NO_PREEMPTION;
    307                 thrd_dst->state = Active;
    308307
    309308                // Update global state
    310309                kernelTLS().this_thread = thrd_dst;
     310
     311                // Update the state after setting this_thread
     312                // so that the debugger can find all active threads
     313                // in tls storage
     314                thrd_dst->state = Active;
    311315
    312316                /* paranoid */ verify( ! __preemption_enabled() );
     
    335339                /* paranoid */ verify( ! __preemption_enabled() );
    336340
    337                 // Reset global state
    338                 kernelTLS().this_thread = 0p;
    339 
    340341                // We just finished running a thread, there are a few things that could have happened.
    341342                // 1 - Regular case : the thread has blocked and now one has scheduled it yet.
     
    346347
    347348                if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) {
     349                        // Reset the this_thread now that we know
     350                        // the state isn't active anymore
     351                        kernelTLS().this_thread = 0p;
     352
    348353                        // The thread was preempted, reschedule it and reset the flag
    349354                        schedule_thread$( thrd_dst, UNPARK_LOCAL );
     
    352357
    353358                if(unlikely(thrd_dst->state == Halting)) {
     359                        // Reset the this_thread now that we know
     360                        // the state isn't active anymore
     361                        kernelTLS().this_thread = 0p;
     362
    354363                        // The thread has halted, it should never be scheduled/run again
    355364                        // finish the thread
     
    360369                /* paranoid */ verify( thrd_dst->state == Active );
    361370                thrd_dst->state = Blocked;
     371
     372                // Reset the this_thread now that we know
     373                // the state isn't active anymore
     374                kernelTLS().this_thread = 0p;
    362375
    363376                // set state of processor coroutine to active and the thread to inactive
  • libcfa/src/concurrency/kernel.hfa

    r41a6a78 r8bee858  
    3535// I/O
    3636struct cluster;
    37 struct $io_context;
    38 struct $io_arbiter;
     37struct io_context$;
     38struct io_arbiter$;
    3939
    4040struct io_context_params {
     
    113113
    114114        struct {
    115                 $io_context * ctx;
     115                io_context$ * ctx;
    116116                unsigned target;
    117117                volatile bool pending;
     
    230230                struct {
    231231                        // Array of $io_
    232                         $io_context ** data;
     232                        io_context$ ** data;
    233233
    234234                        // Time since subqueues were processed
     
    267267
    268268        struct {
    269                 $io_arbiter * arbiter;
     269                io_arbiter$ * arbiter;
    270270                io_context_params params;
    271271        } io;
  • libcfa/src/concurrency/kernel/cluster.cfa

    r41a6a78 r8bee858  
    278278
    279279#if defined(CFA_HAVE_LINUX_IO_URING_H)
    280         static void assign_io($io_context ** data, size_t count, dlist(processor) & list) {
     280        static void assign_io(io_context$ ** data, size_t count, dlist(processor) & list) {
    281281                processor * it = &list`first;
    282282                while(it) {
  • libcfa/src/concurrency/kernel/private.hfa

    r41a6a78 r8bee858  
    139139//-----------------------------------------------------------------------------
    140140// I/O
    141 $io_arbiter * create(void);
    142 void destroy($io_arbiter *);
     141io_arbiter$ * create(void);
     142void destroy(io_arbiter$ *);
    143143
    144144//=======================================================================
Note: See TracChangeset for help on using the changeset viewer.