kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: afiskon@devzen.ru (Aleksander Alekseev)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Stupid question regarding bogomips and udelay()
Date: Mon, 1 Aug 2016 08:36:07 +0300	[thread overview]
Message-ID: <20160801083607.02157a64@fujitsu> (raw)

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

             reply	other threads:[~2016-08-01  5:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01  5:36 Aleksander Alekseev [this message]
2016-08-01  9:47 ` Stupid question regarding bogomips and udelay() François
2016-08-02  8:27   ` Aleksander Alekseev
2016-08-03  1:20     ` Daniel.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160801083607.02157a64@fujitsu \
    --to=afiskon@devzen.ru \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).