lkml.org 
[lkml]   [2005]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] i386: Selectable Frequency of the Timer Interrupt


On Thu, 14 Jul 2005, Arjan van de Ven wrote:
>
> I *will* argue that for relative delays in drivers, msleep() is better.

Oh, I agree.

I think we should continue the simplification of the simple stuff. If
somebody just wants to sleep a while, do it.

But if somebody is doing this because they think "jiffies" are evil, then
that somebody is being a total idiot. Jiffies aren't evil. They are
basically the most efficient way to handle any kind of absolute timeouts,
and any "repeating timeout" _needs_ to be written in absolute terms.

And quite frankly, in this discussion I have several times seen the
argument that we should be getting rid of jiffies because somebody thinks
jiffies are "hard" and somehow incompatible with "tickless".

THAT is the thinking I want to squash.

We're not getting rid of jiffies, and we're not going to be "tickless". We
might have a variable clock, but that has _nothing_ to do with the basic
fact that even a variable clock needs a fundamental baseline, and that the
kernel _needs_ a heartbeat.

And that baseline and heartbeat is HZ and "jiffies". End of story. Anybody
who argues for getting rid of it just isn't thinking things through.

> I have nothing religious against jiffies per se. My argument however is
> that with a few simple, relative interfaces *in addition* to an absolute
> interface, almost all drivers suddenly are isolated from jiffies and HZ
> because they simply don't care. Because they really DON'T care about
> absolute time. At all.

That's not even true.

A _lot_ of drivers end up caring about absolute time, because a _lot_ of
drivers have a very simple issue like:

- poll this port every 10ms until it returns "ready", or until we time
out after 500ms.

And the thing is, you can do it the stupid way:

for (i = 0; i < 50; i++) {
if (ready())
return 0;
msleep(10);
}
.. timeout ..

or you can do it the _right_ way. The stupid way is simpler, but anybody
who doesn't see what the problem is has some serious problems in kernel
programming. Hint: it might not be polling for half a second, it might be
polling for half a _minute_ for all you know.

In other words, the _right_ way to do this is literally

unsigned long timeout = jiffies + HZ/2;
for (;;) {
if (ready())
return 0;
if (time_after(timeout, jiffies))
break;
msleep(10);
}

which is unquestionably more complex, yes, but it's more complex because
it is CORRECT!

And yes, we have had people "simplifying" drivers and screwing things like
this up. And you don't even notice, until the machine is under heavy load,
and then the "simplified" driver ends up being very very broken, and
people wonder why performance sucks.

So stop saying that drivers not needing absolute timeouts. They need it
qutie often.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-11-18 23:46    [W:0.202 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site