Changeset d0c82c5 in mainline for kernel/generic/src/time/clock.c


Ignore:
Timestamp:
2010-06-16T19:44:53Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5387807
Parents:
5954241
Message:

perfect CPU cycles accounting, cherry-picked and adopted from lp:~ersin/helenos/measure2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/time/clock.c

    r5954241 rd0c82c5  
    5757#include <mm/frame.h>
    5858#include <ddi/ddi.h>
     59#include <arch/cycle.h>
    5960
    6061/* Pointer to variable with uptime */
     
    125126}
    126127
     128static void cpu_update_accounting(void)
     129{
     130        irq_spinlock_lock(&CPU->lock, false);
     131        uint64_t now = get_cycle();
     132        CPU->busy_cycles += now - CPU->last_cycle;
     133        CPU->last_cycle = now;
     134        irq_spinlock_unlock(&CPU->lock, false);
     135}
     136
    127137/** Clock routine
    128138 *
     
    136146        size_t missed_clock_ticks = CPU->missed_clock_ticks;
    137147       
    138         /* Account lost ticks to CPU usage */
    139         if (CPU->idle)
    140                 CPU->idle_ticks += missed_clock_ticks + 1;
    141         else
    142                 CPU->busy_ticks += missed_clock_ticks + 1;
    143        
    144         CPU->idle = false;
     148        /* Account CPU usage */
     149        cpu_update_accounting();
    145150       
    146151        /*
     
    151156        size_t i;
    152157        for (i = 0; i <= missed_clock_ticks; i++) {
     158                /* Update counters and accounting */
    153159                clock_update_counters();
     160                cpu_update_accounting();
     161               
    154162                irq_spinlock_lock(&CPU->timeoutlock, false);
    155163               
Note: See TracChangeset for help on using the changeset viewer.