Ignore:
Timestamp:
May 5, 2020, 11:35:45 AM (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:
4e74466
Parents:
f90d10f
Message:

Added the option to dynamically (at cluster creation time) enable/disable the user thread polling of I/O

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    rf90d10f rb6f2b21  
    2020
    2121#if !defined(HAVE_LINUX_IO_URING_H)
    22         void __kernel_io_startup( cluster &, bool ) {
     22        void __kernel_io_startup( cluster &, int, bool ) {
    2323                // Nothing to do without io_uring
    2424        }
     
    182182                struct __submition_data submit_q;
    183183                struct __completion_data completion_q;
    184                 uint32_t flags;
     184                uint32_t ring_flags;
     185                int cltr_flags;
    185186                int fd;
    186187                semaphore submit;
     
    199200// I/O Startup / Shutdown logic
    200201//=============================================================================================
    201         void __kernel_io_startup( cluster & this, bool main_cluster ) {
     202        void __kernel_io_startup( cluster & this, int io_flags, bool main_cluster ) {
    202203                this.io = malloc();
    203204
     
    294295
    295296                // Update the global ring info
    296                 this.io->flags = params.flags;
    297                 this.io->fd    = fd;
    298                 this.io->done  = false;
     297                this.io->ring_flags = params.flags;
     298                this.io->cltr_flags = io_flags;
     299                this.io->fd         = fd;
     300                this.io->done       = false;
    299301                (this.io->submit){ min(*sq.num, *cq.num) };
    300302
     
    314316
    315317        void __kernel_io_finish_start( cluster & this ) {
    316                 __cfadbg_print_safe(io_core, "Kernel I/O : Creating fast poller for cluter %p\n", &this);
    317                 (this.io->poller.fast){ this };
    318                 __thrd_start( this.io->poller.fast, main );
     318                if( this.io->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) {
     319                        __cfadbg_print_safe(io_core, "Kernel I/O : Creating fast poller for cluter %p\n", &this);
     320                        (this.io->poller.fast){ this };
     321                        __thrd_start( this.io->poller.fast, main );
     322                }
    319323
    320324                // Create the poller thread
     
    339343                __cfadbg_print_safe(io_core, "Kernel I/O : Slow poller stopped for cluster\n", &this);
    340344
    341                 #if defined(__CFA_IO_POLLING_USER__)
     345                if( this.io->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) {
    342346                        verify( this.io->poller.fast.waiting );
    343347                        verify( this.io->poller.fast.thrd.state == Blocked );
     
    351355
    352356                        __cfadbg_print_safe(io_core, "Kernel I/O : Fast poller stopped for cluster\n", &this);
    353                 #endif
     357                }
    354358        }
    355359
     
    473477                __cfadbg_print_safe(io_core, "Kernel I/O : Slow poller for ring %p ready\n", &ring);
    474478
    475                 while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) {
    476                         #if defined(__CFA_IO_POLLING_USER__)
    477 
     479                if( ring.cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) {
     480                        while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) {
    478481                                // In the user-thread approach drain and if anything was drained,
    479482                                // batton pass to the user-thread
     
    491494                                        wait( ring.poller.sem );
    492495                                }
    493 
    494                         #else
    495 
     496                        }
     497                }
     498                else {
     499                        while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) {
    496500                                //In the naive approach, just poll the io completion queue directly
    497501                                int count = __drain_io( ring, &mask, 1, true );
     
    502506                                        ring.completion_q.stats.completed_avg.slow_cnt += 1;
    503507                                #endif
    504 
    505                         #endif
     508                        }
    506509                }
    507510
     
    512515
    513516        void main( __io_poller_fast & this ) {
     517                verify( this.ring->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD );
     518
    514519                // Start parked
    515520                park( __cfaabi_dbg_ctx );
  • libcfa/src/concurrency/kernel.cfa

    rf90d10f rb6f2b21  
    254254}
    255255
    256 void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) {
     256void ?{}(cluster & this, const char name[], Duration preemption_rate, int io_flags) with( this ) {
    257257        this.name = name;
    258258        this.preemption_rate = preemption_rate;
     
    268268        threads{ __get };
    269269
    270         __kernel_io_startup( this, &this == mainCluster );
     270        __kernel_io_startup( this, io_flags, &this == mainCluster );
    271271
    272272        doregister(this);
  • libcfa/src/concurrency/kernel.hfa

    rf90d10f rb6f2b21  
    116116struct __io_data;
    117117
     118#define CFA_CLUSTER_IO_POLLER_USER_THREAD 1 << 0
     119// #define CFA_CLUSTER_IO_POLLER_KERNEL_SIDE 1 << 1
     120
    118121//-----------------------------------------------------------------------------
    119122// Cluster
     
    156159extern Duration default_preemption();
    157160
    158 void ?{} (cluster & this, const char name[], Duration preemption_rate);
     161void ?{} (cluster & this, const char name[], Duration preemption_rate, int flags);
    159162void ^?{}(cluster & this);
    160163
    161 static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    162 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    163 static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
     164static inline void ?{} (cluster & this)                                      { this{"Anonymous Cluster", default_preemption(), 0}; }
     165static inline void ?{} (cluster & this, Duration preemption_rate)            { this{"Anonymous Cluster", preemption_rate, 0}; }
     166static inline void ?{} (cluster & this, const char name[])                   { this{name, default_preemption(), 0}; }
     167static inline void ?{} (cluster & this, int flags)                           { this{"Anonymous Cluster", default_preemption(), flags}; }
     168static inline void ?{} (cluster & this, Duration preemption_rate, int flags) { this{"Anonymous Cluster", preemption_rate, flags}; }
     169static inline void ?{} (cluster & this, const char name[], int flags)        { this{name, default_preemption(), flags}; }
    164170
    165171static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; }
  • libcfa/src/concurrency/kernel_private.hfa

    rf90d10f rb6f2b21  
    7777//-----------------------------------------------------------------------------
    7878// I/O
    79 void __kernel_io_startup     ( cluster &, bool );
     79void __kernel_io_startup     ( cluster &, int, bool );
    8080void __kernel_io_finish_start( cluster & );
    8181void __kernel_io_prepare_stop( cluster & );
Note: See TracChangeset for help on using the changeset viewer.