Changeset 8464edf


Ignore:
Timestamp:
May 5, 2021, 4:53:25 PM (7 weeks ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master
Children:
938885d3
Parents:
45b9b21
Message:

'print_stats_now' now pulls stats from processors.

File:
1 edited

Legend:

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

    r45b9b21 r8464edf  
    171171                preemption_scope scope = { this };
    172172
    173                 __STATS( unsigned long long last_tally = rdtscl(); )
    174 
    175173                // if we need to run some special setup, now is the time to do it.
    176174                if(this->init.thrd) {
     
    258256                        // Are we done?
    259257                        if( __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST) ) break MAIN_LOOP;
    260 
    261                         #if !defined(__CFA_NO_STATISTICS__)
    262                                 unsigned long long curr = rdtscl();
    263                                 if(curr > (last_tally + 500000000)) {
    264                                         __tally_stats(this->cltr->stats, __cfaabi_tls.this_stats);
    265                                         last_tally = curr;
    266                                 }
    267                         #endif
    268258
    269259                        if(this->io.pending && !this->io.dirty) {
     
    918908        }
    919909
     910        static void crawl_list( cluster * cltr, dlist(processor, processor) & list, unsigned count ) {
     911                /* paranoid */ verify( cltr->stats );
     912
     913                processor * it = &list`first;
     914                for(unsigned i = 0; i < count; i++) {
     915                        /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
     916                        /* paranoid */ verify( it->local_data->this_stats );
     917                        __tally_stats( cltr->stats, it->local_data->this_stats );
     918                        it = &(*it)`next;
     919                }
     920        }
     921
     922        void crawl_cluster_stats( cluster & this ) {
     923                // Stop the world, otherwise stats could get really messed-up
     924                // this doesn't solve all problems but does solve many
     925                // so it's probably good enough
     926                uint_fast32_t last_size = ready_mutate_lock();
     927
     928                        crawl_list(&this, this.procs.actives, this.procs.total - this.procs.idle);
     929                        crawl_list(&this, this.procs.idles  , this.procs.idle );
     930
     931                // Unlock the RWlock
     932                ready_mutate_unlock( last_size );
     933        }
     934
     935
    920936        void print_stats_now( cluster & this, int flags ) {
     937                crawl_cluster_stats( this );
    921938                __print_stats( this.stats, this.print_stats, "Cluster", this.name, (void*)&this );
    922939        }
Note: See TracChangeset for help on using the changeset viewer.