public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* HZ==250 and rounding issues?
@ 2005-08-04  1:06 Nishanth Aravamudan
  0 siblings, 0 replies; only message in thread
From: Nishanth Aravamudan @ 2005-08-04  1:06 UTC (permalink / raw)
  To: LKML

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-08-04  1:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-04  1:06 HZ==250 and rounding issues? Nishanth Aravamudan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox