Re: [PATCH] hrtimers: Special-case zero length sleeps

From: Thomas Gleixner
Date: Wed Feb 15 2012 - 15:30:22 EST


On Wed, 15 Feb 2012, Matthew Garrett wrote:

> On Wed, Feb 15, 2012 at 09:14:30PM +0100, Thomas Gleixner wrote:
>
> > Just for the extended fun of it: The pre hrtimer implementation in
> > Linux put the task on sleep as well up to the next jiffies boundary,
> > so anything which used sleep(0) on a pre hrtimer kernel was going to
> > sleep. That's also the case today when high resolution timers are
> > disabled (compile or runtime).
> >
> > So anything which relies on sleep(0) as a fast scheduling point is and
> > has been broken forever.
>
> Excellent. So the real question is what /should/ sleep(0) do - nothing,
> schedule or sleep for an arbitrary period of time that could be years?

Well, I don't expect slack to be set to years and I really don't want
to special case sleep(0), because then we might end up discussing
special casing usleep(1) or nanosleep(1ns) as well.

slack gets added to all timers, period.

You can tune the slack for your app if you think that it's necessary,
but I bet that in 99,9% of the cases the programmer does not even know
why the hell he put sleep(0), usleep(1) or nanosleep(1ns) into his
code.

Thanks,

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