Changeset 47746a2


Ignore:
Timestamp:
Jul 8, 2020, 2:01:05 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:
69237cd
Parents:
b9237fe
Message:

Added stats macro to reduce typing when using stats
Added new macros for Complete polling and submit polling (not implemented yet)

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

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

    rb9237fe r47746a2  
    191191                struct io_uring_params params;
    192192                memset(&params, 0, sizeof(params));
     193                if( io_flags & CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS   ) params.flags |= IORING_SETUP_SQPOLL;
     194                if( io_flags & CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES ) params.flags |= IORING_SETUP_IOPOLL;
    193195
    194196                uint32_t nentries = entries_per_cluster();
     
    264266                        }
    265267                }
     268
     269                (sq.lock){};
    266270
    267271                if( io_flags & ( CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS | CFA_CLUSTER_IO_EAGER_SUBMITS ) ) {
     
    457461
    458462                // update statistics
    459                 #if !defined(__CFA_NO_STATISTICS__)
     463                __STATS__( true,
    460464                        if( to_submit > 0 ) {
    461                                 __tls_stats()->io.submit_q.submit_avg.rdy += to_submit;
    462                                 __tls_stats()->io.submit_q.submit_avg.csm += ret;
    463                                 __tls_stats()->io.submit_q.submit_avg.cnt += 1;
    464                         }
    465                 #endif
     465                                io.submit_q.submit_avg.rdy += to_submit;
     466                                io.submit_q.submit_avg.csm += ret;
     467                                io.submit_q.submit_avg.cnt += 1;
     468                        }
     469                )
    466470
    467471                // Drain the queue
     
    543547
    544548                                // Update statistics
    545                                 #if !defined(__CFA_NO_STATISTICS__)
    546                                         __tls_stats()->io.complete_q.completed_avg.val += count;
    547                                         __tls_stats()->io.complete_q.completed_avg.slow_cnt += 1;
    548                                 #endif
     549                                __STATS__( true,
     550                                        io.complete_q.completed_avg.val += count;
     551                                        io.complete_q.completed_avg.slow_cnt += 1;
     552                                )
    549553
    550554                                if(again) {
     
    563567
    564568                                // Update statistics
    565                                 #if !defined(__CFA_NO_STATISTICS__)
    566                                         __tls_stats()->io.complete_q.completed_avg.val += count;
    567                                         __tls_stats()->io.complete_q.completed_avg.slow_cnt += 1;
    568                                 #endif
     569                                __STATS__( true,
     570                                        io.complete_q.completed_avg.val += count;
     571                                        io.complete_q.completed_avg.slow_cnt += 1;
     572                                )
    569573                        }
    570574                }
     
    603607
    604608                                // Update statistics
    605                                 #if !defined(__CFA_NO_STATISTICS__)
    606                                         __tls_stats()->io.complete_q.completed_avg.val += count;
    607                                         __tls_stats()->io.complete_q.completed_avg.fast_cnt += 1;
    608                                 #endif
     609                                __STATS__( true,
     610                                        io.complete_q.completed_avg.val += count;
     611                                        io.complete_q.completed_avg.fast_cnt += 1;
     612                                )
    609613                        enable_interrupts( __cfaabi_dbg_ctx );
    610614
     
    683687                                {
    684688                                        // update statistics
    685                                         #if !defined(__CFA_NO_STATISTICS__)
    686                                                 disable_interrupts();
    687                                                         __tls_stats()->io.submit_q.alloc_avg.val   += len;
    688                                                         __tls_stats()->io.submit_q.alloc_avg.block += block;
    689                                                         __tls_stats()->io.submit_q.alloc_avg.cnt   += 1;
    690                                                 enable_interrupts( __cfaabi_dbg_ctx );
    691                                         #endif
     689                                        __STATS__( false,
     690                                                io.submit_q.alloc_avg.val   += len;
     691                                                io.submit_q.alloc_avg.block += block;
     692                                                io.submit_q.alloc_avg.cnt   += 1;
     693                                        )
    692694
    693695
     
    736738
    737739                // update statistics
    738                 #if !defined(__CFA_NO_STATISTICS__)
    739                         disable_interrupts();
    740                                 __tls_stats()->io.submit_q.look_avg.val   += len;
    741                                 __tls_stats()->io.submit_q.look_avg.block += block;
    742                                 __tls_stats()->io.submit_q.look_avg.cnt   += 1;
    743                         enable_interrupts( __cfaabi_dbg_ctx );
    744                 #endif
     740                __STATS__( false,
     741                        io.submit_q.look_avg.val   += len;
     742                        io.submit_q.look_avg.block += block;
     743                        io.submit_q.look_avg.cnt   += 1;
     744                )
    745745
    746746                return picked;
     
    770770                                #warning ABA problem
    771771                                if( ring.submit_q.ready[picked] != idx ) {
    772                                         #if !defined(__CFA_NO_STATISTICS__)
    773                                                 disable_interrupts();
    774                                                         __tls_stats()->io.submit_q.helped += 1;
    775                                                 enable_interrupts( __cfaabi_dbg_ctx );
    776                                         #endif
     772                                        __STATS__( false,
     773                                                io.submit_q.helped += 1;
     774                                        )
    777775                                        return;
    778776                                }
    779777
    780778                                if( try_lock(ring.submit_q.lock __cfaabi_dbg_ctx2) ) {
    781                                         #if !defined(__CFA_NO_STATISTICS__)
    782                                                 __tls_stats()->io.submit_q.leader += 1;
    783                                         #endif
     779                                        __STATS__( false,
     780                                                io.submit_q.leader += 1;
     781                                        )
    784782                                        break;
    785783                                }
    786784
    787                                 #if !defined(__CFA_NO_STATISTICS__)
    788                                         disable_interrupts();
    789                                                 __tls_stats()->io.submit_q.busy += 1;
    790                                         enable_interrupts( __cfaabi_dbg_ctx );
    791                                 #endif
     785                                __STATS__( false,
     786                                        io.submit_q.busy += 1;
     787                                )
    792788                        }
    793789
     
    817813
    818814                        // update statistics
    819                         #if !defined(__CFA_NO_STATISTICS__)
    820                                 __tls_stats()->io.submit_q.submit_avg.rdy += to_submit;
    821                                 __tls_stats()->io.submit_q.submit_avg.csm += ret;
    822                                 __tls_stats()->io.submit_q.submit_avg.cnt += 1;
    823                         #endif
     815                        __STATS__( true,
     816                                io.submit_q.submit_avg.rdy += to_submit;
     817                                io.submit_q.submit_avg.csm += ret;
     818                                io.submit_q.submit_avg.cnt += 1;
     819                        )
    824820
    825821                        unlock(ring.submit_q.lock);
     
    846842
    847843                        // update statistics
    848                         #if !defined(__CFA_NO_STATISTICS__)
    849                                 disable_interrupts();
    850                                         abort();
    851                                         __tls_stats()->io.submit_q.submit_avg.csm += 1;
    852                                         __tls_stats()->io.submit_q.submit_avg.cnt += 1;
    853                                 enable_interrupts( __cfaabi_dbg_ctx );
    854                         #endif
     844                        __STATS__( false,
     845                                io.submit_q.submit_avg.csm += 1;
     846                                io.submit_q.submit_avg.cnt += 1;
     847                        )
    855848
    856849                        ring.submit_q.sqes[ idx & mask ].user_data = 0;
  • libcfa/src/concurrency/kernel.hfa

    rb9237fe r47746a2  
    129129struct __io_data;
    130130
    131 #define CFA_CLUSTER_IO_POLLER_USER_THREAD    1 << 0 // 0x1
    132 #define CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS 1 << 1 // 0x2
    133 #define CFA_CLUSTER_IO_EAGER_SUBMITS         1 << 2 // 0x4
     131#define CFA_CLUSTER_IO_POLLER_USER_THREAD    (1 << 0) // 0x01
     132#define CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS (1 << 1) // 0x02
     133#define CFA_CLUSTER_IO_EAGER_SUBMITS         (1 << 2) // 0x04
     134#define CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS   (1 << 3) // 0x08
     135#define CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES (1 << 4) // 0x10
    134136#define CFA_CLUSTER_IO_BUFFLEN_OFFSET        16
    135137
  • libcfa/src/concurrency/kernel_private.hfa

    rb9237fe r47746a2  
    286286// Statics call at the end of each thread to register statistics
    287287#if !defined(__CFA_NO_STATISTICS__)
    288 static inline struct __stats_t * __tls_stats() {
    289         /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    290         /* paranoid */ verify( kernelTLS.this_stats );
    291         return kernelTLS.this_stats;
    292 }
     288        static inline struct __stats_t * __tls_stats() {
     289                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     290                /* paranoid */ verify( kernelTLS.this_stats );
     291                return kernelTLS.this_stats;
     292        }
     293
     294        #define __STATS__(in_kernel, ...) { \
     295                if( !(in_kernel) ) disable_interrupts(); \
     296                with( *__tls_stats() ) { \
     297                        __VA_ARGS__ \
     298                } \
     299                if( !(in_kernel) ) enable_interrupts( __cfaabi_dbg_ctx ); \
     300        }
     301#else
     302        #define __STATS__(in_kernel, ...)
    293303#endif
    294304
Note: See TracChangeset for help on using the changeset viewer.