Changeset ec43cf9


Ignore:
Timestamp:
Apr 5, 2021, 7:06:37 PM (6 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
7039ab9, cd59d28
Parents:
a5a01fa
Message:

Kernel now keeps track of the how many threads each processor has contributed.
This isn't useful if it is not sampled regularly but it's a first step.

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

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

    ra5a01fa rec43cf9  
    357357                                break RUNNING;
    358358                        case TICKET_UNBLOCK:
     359                                #if !defined(__CFA_NO_STATISTICS__)
     360                                        __tls_stats()->ready.threads.threads++;
     361                                #endif
    359362                                // This is case 2, the racy case, someone tried to run this thread before it finished blocking
    360363                                // In this case, just run it again.
     
    370373
    371374        __cfadbg_print_safe(runtime_core, "Kernel : core %p finished running thread %p\n", this, thrd_dst);
     375
     376        #if !defined(__CFA_NO_STATISTICS__)
     377                __tls_stats()->ready.threads.threads--;
     378        #endif
    372379
    373380        /* paranoid */ verify( ! __preemption_enabled() );
     
    432439        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    433440
     441        // Dereference the thread now because once we push it, there is not guaranteed it's still valid.
     442        struct cluster * cl = thrd->curr_cluster;
     443
    434444        ready_schedule_lock();
    435                 // Dereference the thread now because once we push it, there is not guaranteed it's still valid.
    436                 struct cluster * cl = thrd->curr_cluster;
    437 
    438445                // push the thread to the cluster ready-queue
    439446                push( cl, thrd );
     
    444451                __wake_one( cl );
    445452        ready_schedule_unlock();
     453
     454        #if !defined(__CFA_NO_STATISTICS__)
     455                if( kernelTLS().this_stats ) {
     456                        __tls_stats()->ready.threads.threads++;
     457                }
     458                else {
     459                        __atomic_fetch_add(&cl->stats->ready.threads.threads, 1, __ATOMIC_RELAXED);
     460                }
     461        #endif
    446462
    447463        /* paranoid */ verify( ! __preemption_enabled() );
  • libcfa/src/concurrency/stats.cfa

    ra5a01fa rec43cf9  
    2323                stats->ready.pick.pop .lsuccess = 0;
    2424                stats->ready.threads.migration = 0;
     25                stats->ready.threads.threads   = 0;
    2526                stats->ready.sleep.halts   = 0;
    2627                stats->ready.sleep.cancels = 0;
     
    6162                __atomic_fetch_add( &cltr->ready.pick.pop .lsuccess, proc->ready.pick.pop .lsuccess, __ATOMIC_SEQ_CST ); proc->ready.pick.pop .lsuccess = 0;
    6263                __atomic_fetch_add( &cltr->ready.threads.migration , proc->ready.threads.migration , __ATOMIC_SEQ_CST ); proc->ready.threads.migration  = 0;
     64                __atomic_fetch_add( &cltr->ready.threads.threads   , proc->ready.threads.threads   , __ATOMIC_SEQ_CST ); proc->ready.threads.threads    = 0;
    6365                __atomic_fetch_add( &cltr->ready.sleep.halts       , proc->ready.sleep.halts       , __ATOMIC_SEQ_CST ); proc->ready.sleep.halts        = 0;
    6466                __atomic_fetch_add( &cltr->ready.sleep.cancels     , proc->ready.sleep.cancels     , __ATOMIC_SEQ_CST ); proc->ready.sleep.cancels      = 0;
     
    9799                        __cfaabi_bits_print_safe( STDOUT_FILENO,
    98100                                "----- %s \"%s\" (%p) - Ready Q Stats -----\n"
    99                                 "- total threads  : %'15" PRIu64 "run, %'15" PRIu64 "schd (%'" PRIu64 "ext, %'" PRIu64 "mig )\n"
     101                                "- total threads  : %'15" PRIu64 "run, %'15" PRIu64 "schd (%'" PRIu64 "ext, %'" PRIu64 "mig, %'" PRId64 " )\n"
    100102                                "- push avg probe : %'3.2lf, %'3.2lfl (%'15" PRIu64 " attempts, %'15" PRIu64 " locals)\n"
    101103                                "- ext  avg probe : %'3.2lf, %'3.2lfl (%'15" PRIu64 " attempts, %'15" PRIu64 " locals)\n"
     
    106108                                , ready.pick.pop.success
    107109                                , ready.pick.push.success + ready.pick.ext.success
    108                                 , ready.pick.ext.success, ready.threads.migration
     110                                , ready.pick.ext.success, ready.threads.migration, ready.threads.threads
    109111                                , push_len, lpush_len, ready.pick.push.attempt, ready.pick.push.local
    110112                                , ext_len , lext_len , ready.pick.ext .attempt, ready.pick.ext .local
  • libcfa/src/concurrency/stats.hfa

    ra5a01fa rec43cf9  
    6868                struct {
    6969                        volatile uint64_t migration;
     70                        volatile  int64_t threads; // number of threads in the system, includes only local change
    7071                } threads;
    7172                struct {
Note: See TracChangeset for help on using the changeset viewer.