Changeset 941e14a


Ignore:
Timestamp:
Feb 2, 2022, 8:25:52 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
9dc0836, becb85b9
Parents:
17cb385
Message:

Added statistics for preemption

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

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

    r17cb385 r941e14a  
    661661
    662662        // Check if it is safe to preempt here
    663         if( !preemption_ready( ip ) ) { return; }
     663        if( !preemption_ready( ip ) ) {
     664                #if !defined(__CFA_NO_STATISTICS__)
     665                        __cfaabi_tls.this_stats->ready.threads.preempt.rllfwd++;
     666                #endif
     667                return;
     668        }
    664669
    665670        __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", __cfaabi_tls.this_processor, __cfaabi_tls.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) );
     
    680685
    681686        // Preemption can occur here
     687
     688        #if !defined(__CFA_NO_STATISTICS__)
     689                __cfaabi_tls.this_stats->ready.threads.preempt.yield++;
     690        #endif
    682691
    683692        force_yield( __ALARM_PREEMPTION ); // Do the actual __cfactx_switch
  • libcfa/src/concurrency/stats.cfa

    r17cb385 r941e14a  
    2929                stats->ready.threads.threads   = 0;
    3030                stats->ready.threads.cthreads  = 0;
     31                stats->ready.threads.preempt.yield  = 0;
     32                stats->ready.threads.preempt.rllfwd = 0;
    3133                stats->ready.sleep.halts   = 0;
    3234                stats->ready.sleep.cancels = 0;
     
    7779
    7880        void __tally_stats( struct __stats_t * cltr, struct __stats_t * proc ) {
    79                 tally_one( &cltr->ready.push.local.attempt, &proc->ready.push.local.attempt );
    80                 tally_one( &cltr->ready.push.local.success, &proc->ready.push.local.success );
    81                 tally_one( &cltr->ready.push.share.attempt, &proc->ready.push.share.attempt );
    82                 tally_one( &cltr->ready.push.share.success, &proc->ready.push.share.success );
    83                 tally_one( &cltr->ready.push.extrn.attempt, &proc->ready.push.extrn.attempt );
    84                 tally_one( &cltr->ready.push.extrn.success, &proc->ready.push.extrn.success );
    85                 tally_one( &cltr->ready.pop.local .attempt, &proc->ready.pop.local .attempt );
    86                 tally_one( &cltr->ready.pop.local .success, &proc->ready.pop.local .success );
    87                 tally_one( &cltr->ready.pop.help  .attempt, &proc->ready.pop.help  .attempt );
    88                 tally_one( &cltr->ready.pop.help  .success, &proc->ready.pop.help  .success );
    89                 tally_one( &cltr->ready.pop.steal .attempt, &proc->ready.pop.steal .attempt );
    90                 tally_one( &cltr->ready.pop.steal .success, &proc->ready.pop.steal .success );
    91                 tally_one( &cltr->ready.pop.search.attempt, &proc->ready.pop.search.attempt );
    92                 tally_one( &cltr->ready.pop.search.success, &proc->ready.pop.search.success );
    93                 tally_one( &cltr->ready.threads.migration , &proc->ready.threads.migration  );
    94                 tally_one( &cltr->ready.threads.extunpark , &proc->ready.threads.extunpark  );
    95                 tally_one( &cltr->ready.threads.threads   , &proc->ready.threads.threads    );
    96                 tally_one( &cltr->ready.threads.cthreads  , &proc->ready.threads.cthreads   );
    97                 tally_one( &cltr->ready.sleep.halts       , &proc->ready.sleep.halts        );
    98                 tally_one( &cltr->ready.sleep.cancels     , &proc->ready.sleep.cancels      );
    99                 tally_one( &cltr->ready.sleep.early       , &proc->ready.sleep.early        );
    100                 tally_one( &cltr->ready.sleep.wakes       , &proc->ready.sleep.wakes        );
    101                 tally_one( &cltr->ready.sleep.seen        , &proc->ready.sleep.wakes        );
    102                 tally_one( &cltr->ready.sleep.exits       , &proc->ready.sleep.exits        );
     81                tally_one( &cltr->ready.push.local.attempt    , &proc->ready.push.local.attempt     );
     82                tally_one( &cltr->ready.push.local.success    , &proc->ready.push.local.success     );
     83                tally_one( &cltr->ready.push.share.attempt    , &proc->ready.push.share.attempt     );
     84                tally_one( &cltr->ready.push.share.success    , &proc->ready.push.share.success     );
     85                tally_one( &cltr->ready.push.extrn.attempt    , &proc->ready.push.extrn.attempt     );
     86                tally_one( &cltr->ready.push.extrn.success    , &proc->ready.push.extrn.success     );
     87                tally_one( &cltr->ready.pop.local .attempt    , &proc->ready.pop.local .attempt     );
     88                tally_one( &cltr->ready.pop.local .success    , &proc->ready.pop.local .success     );
     89                tally_one( &cltr->ready.pop.help  .attempt    , &proc->ready.pop.help  .attempt     );
     90                tally_one( &cltr->ready.pop.help  .success    , &proc->ready.pop.help  .success     );
     91                tally_one( &cltr->ready.pop.steal .attempt    , &proc->ready.pop.steal .attempt     );
     92                tally_one( &cltr->ready.pop.steal .success    , &proc->ready.pop.steal .success     );
     93                tally_one( &cltr->ready.pop.search.attempt    , &proc->ready.pop.search.attempt     );
     94                tally_one( &cltr->ready.pop.search.success    , &proc->ready.pop.search.success     );
     95                tally_one( &cltr->ready.threads.migration     , &proc->ready.threads.migration      );
     96                tally_one( &cltr->ready.threads.extunpark     , &proc->ready.threads.extunpark      );
     97                tally_one( &cltr->ready.threads.threads       , &proc->ready.threads.threads        );
     98                tally_one( &cltr->ready.threads.cthreads      , &proc->ready.threads.cthreads       );
     99                tally_one( &cltr->ready.threads.preempt.yield , &proc->ready.threads.preempt.yield  );
     100                tally_one( &cltr->ready.threads.preempt.rllfwd, &proc->ready.threads.preempt.rllfwd );
     101                tally_one( &cltr->ready.sleep.halts           , &proc->ready.sleep.halts            );
     102                tally_one( &cltr->ready.sleep.cancels         , &proc->ready.sleep.cancels          );
     103                tally_one( &cltr->ready.sleep.early           , &proc->ready.sleep.early            );
     104                tally_one( &cltr->ready.sleep.wakes           , &proc->ready.sleep.wakes            );
     105                tally_one( &cltr->ready.sleep.seen            , &proc->ready.sleep.wakes            );
     106                tally_one( &cltr->ready.sleep.exits           , &proc->ready.sleep.exits            );
    103107
    104108                #if defined(CFA_HAVE_LINUX_IO_URING_H)
     
    168172                             | eng3(ready.sleep.wakes + ready.sleep.early) | '(' | eng3(ready.sleep.early) | ',' | eng3(ready.sleep.seen) | ')' | " wake(early, seen),"
    169173                             | eng3(ready.sleep.exits) | "exit";
     174                        sstr | "- Preemption : " | eng3(ready.threads.preempt.yield) | "yields," | eng3(ready.threads.preempt.rllfwd) | "delayed";
    170175                        sstr | nl;
    171176                }
  • libcfa/src/concurrency/stats.hfa

    r17cb385 r941e14a  
    6565                        volatile  int64_t threads;  // number of threads in the system, includes only local change
    6666                        volatile  int64_t cthreads; // number of threads in the system, includes only local change
     67                        struct {
     68                                volatile uint64_t yield;
     69                                volatile uint64_t rllfwd;
     70                        } preempt;
    6771                } threads;
    6872                struct {
Note: See TracChangeset for help on using the changeset viewer.