Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 9efff92 in mainline


Ignore:
Timestamp:
2010-04-21T13:58:22Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial
Children:
a721f6a
Parents:
369a5f8
Message:

simplify load calculation, the number of ready threads is available from the scheduler as an atomic variable

Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r369a5f8 r9efff92  
    344344endif
    345345
    346 
    347 
    348346$(BIN): $(RAW)
    349347        $(OBJCOPY) -O $(BFD) $< $@
  • kernel/generic/src/sysinfo/stats.c

    r369a5f8 r9efff92  
    619619 *
    620620 */
    621 static inline load_t load_calc(load_t load, load_t exp, size_t ready)
     621static inline load_t load_calc(load_t load, load_t exp, atomic_count_t ready)
    622622{
    623623        load *= exp;
    624         load += ready * (LOAD_FIXED_1 - exp);
     624        load += (ready << LOAD_FIXED_SHIFT) * (LOAD_FIXED_1 - exp);
    625625       
    626626        return (load >> LOAD_FIXED_SHIFT);
    627627}
    628628
    629 /** Count threads in ready queues
    630  *
    631  * Should be called with interrupts disabled.
    632  *
    633  */
    634 static inline size_t get_ready_count(void)
    635 {
    636         size_t i;
    637         size_t count = 0;
    638        
    639         for (i = 0; i < config.cpu_count; i++) {
    640                 spinlock_lock(&cpus[i].lock);
    641                
    642                 size_t j;
    643                 for (j = 0; j < RQ_COUNT; j++) {
    644                         spinlock_lock(&cpus[i].rq[j].lock);
    645                         count += cpus[i].rq[j].n;
    646                         spinlock_unlock(&cpus[i].rq[j].lock);
    647                 }
    648                
    649                 spinlock_unlock(&cpus[i].lock);
    650         }
    651        
    652         return count;
    653 }
    654 
    655629/** Load computation thread.
    656630 *
     
    665639       
    666640        while (true) {
     641                atomic_count_t ready = atomic_get(&nrdy);
     642               
    667643                /* Mutually exclude with get_stats_load() */
    668644                ipl_t ipl = interrupts_disable();
    669645                spinlock_lock(&load_lock);
    670                
    671                 size_t ready = get_ready_count() * LOAD_FIXED_1;
    672646               
    673647                unsigned int i;
Note: See TracChangeset for help on using the changeset viewer.