From: Nishanth Aravamudan <nacc@us.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>
Subject: HZ==250 and rounding issues?
Date: Wed, 3 Aug 2005 18:06:17 -0700 [thread overview]
Message-ID: <20050804010617.GD4255@us.ibm.com> (raw)
Hello all,
While discussing milliseconds and jiffies and their inter-relations with
Roman Zippel in a separate thread, I came across an interesting and
perhaps problematic rounding issue with directly using HZ when HZ==250.
Consider requesting a 10 millisecond sleep, in jiffies. This is
accomplished via HZ/100, as there are HZ jiffies in a second and, thus,
1/100th of HZ should be 10 milliseconds in jiffies (this is the common
interpretation, I think, and the flaw may simply lie in the
interpretation). But, if HZ==250, then HZ/100 = 2 (integer division with
truncation), which when translated to milliseconds, is 8 ms (250
interrupts per second means a jiffy is 4 milliseconds in duration).
Now, combine this with the potential corner case (explained in
http://marc.theaimsgroup.com/?l=linux-kernel&m=112311712414431&w=2)
where a schedule_timeout(HZ/100) request occurs immediately before a
timer interrupt occurs. We now might get a 4 millisecond sleep *and*
have schedule_timeout() return 0, indicating falsely that a full 10
millisecond sleep has elapsed.
Could be, though, that my analysis is flawed here too :) Please correct
me if that's the case!
I will try to audit the direct users of HZ; maybe this isn't really a
problem. Just some food for thought.
Thanks,
Nish
reply other threads:[~2005-08-04 1:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20050804010617.GD4255@us.ibm.com \
--to=nacc@us.ibm.com \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.