Stupid question regarding bogomips and udelay()
    Aleksander Alekseev 
    afiskon at devzen.ru
       
    Mon Aug  1 01:36:07 EDT 2016
    
    
  
Hello
Currently I'm reading Linux Kernel Development, 3rd Edition by Robert
Love. Chapter 11 describes timers and udelay() procedure in
particular. According to the book (if I didn't get anything wrong):
* bogomips value (see `cat /proc/cpuinfo`) is determined only once
  during system boot
* udelay() is implemented as busy loop where number of loops is
  calculated based on bogomips value [1][2]
* udelay() guarantees that delay will be _at_least_ given number of
  usecs
It's my understanding that it shouldn't work. CPU frequency actually
changes manually (see cpufrequtils) and/or automatically depending for
instance on laptop's current battery charge. There is also such a nasty
thing as Intel Turbo Boost. In other words actual MIPS could be higher
or lower than measured MIPS. So udealy() can't guarantee anything.
Clearly I don't understand something. Could you please explain why
udelay() supposed to work?
[1]
https://github.com/torvalds/linux/blob/master/arch/x86/lib/delay.c#L171
[2]
https://github.com/torvalds/linux/blob/master/include/asm-generic/delay.h#L19
-- 
Best regards,
Aleksander Alekseev
    
    
More information about the Kernelnewbies
mailing list