From mboxrd@z Thu Jan 1 00:00:00 1970 From: afiskon@devzen.ru (Aleksander Alekseev) Date: Mon, 1 Aug 2016 08:36:07 +0300 Subject: Stupid question regarding bogomips and udelay() Message-ID: <20160801083607.02157a64@fujitsu> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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