• Anton Blanchard's avatar
    powerpc: Improve decrementer accuracy · 8d165db1
    Anton Blanchard authored
    I have been looking at sources of OS jitter and notice that after a long
    NO_HZ idle period we wakeup too early:
    
    relative time (us)    event
                          timer irq exit
        999946.405        timer irq entry
             4.835        timer irq exit
            21.685        timer irq entry
             3.540          timer (tick_sched_timer) entry
    
    Here we slept for just under a second then took a timer interrupt that did
    nothing. 21.685 us later we wake up again and do the work.
    
    We set a rather low shift value of 16 for the decrementer clockevent, which I
    think is causing this issue. On this box we have a 207MHz decrementer and see:
    
    clockevent: decrementer mult[3501] shift[16] cpu[0]
    
    For calculations of large intervals this mult/shift combination could be
    off by a significant amount. I notice the sparc code has a loop that iterates
    to find a mult/shift combination that maximises the shift value while
    keeping mult under 32bit. With the patch below we get:
    
    clockevent: decrementer mult[35015c20] shift[32] cpu[15]
    
    And we no longer see the spurious wakeups.
    Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
    Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
    8d165db1
time.c 30.8 KB