Re: [PATCH/RFC] msleep() with hrtimers
From: Roman Zippel
Date: Mon Jul 16 2007 - 11:43:17 EST
Hi,
On Mon, 16 Jul 2007, Jonathan Corbet wrote:
> > One possible problem here is that setting up that timer can be
> > considerably more expensive, for a relative timer you have to read the
> > current time, which can be quite expensive (e.g. your machine now uses the
> > PIT timer, because TSC was deemed unstable).
>
> That's a possibility, I admit I haven't benchmarked it. I will say that
> I don't think it will be enough to matter - msleep() is not a hot-path
> sort of function. Once the system is up and running it almost never
> gets called at all - at least, on my setup.
That's a bit my problem - we have to consider other setups as well.
Is it worth converting all msleep users behind their back or should we
just a provide a separate function for those who care?
I would really like to keep hrtimer and kernel timer separate and make it
obvious who is using what, as the usage requirements are somewhat
different.
> > One question here would be, is it really a problem to sleep a little more?
>
> "A little more" is a bit different than "twenty times as long as you
> asked for." That "little bit more" added up to a few seconds when
> programming a device which needs a brief delay after tweaking each of
> almost 200 registers.
Which driver is this? I'd like to look at this, in case there's some other
hidden problem.
> > BTW there is another thing to consider. If you already run with hrtimer/
> > dyntick, there is not much reason to keep HZ at 100, so you could just
> > increase HZ to get the same effect.
>
> Except that then, with the current implementation, you're paying for the
> higher HZ whenever the CPU is busy. I bet that doesn't take long to
> overwhelm any added overhead in the hrtimer msleep().
Actually if that's the case I'd consider this a bug, where is that extra
cost coming from?
> In the end, I did this because I thought msleep() should do what it
> claims to do, because I thought that getting a known-to-expire timeout
> off the timer wheel made sense, and to make a tiny baby step in the
> direction of reducing the use of jiffies in the core code.
I know that Ingo considers everything HZ related evil, but it really is
not - it keeps Linux scalable. Unless you need the high resolution the
timer wheel performance is still pretty hard to beat. That
"known-to-expire" stuff is really the least significant problem to
consider here, please just forget about it.
I don't want to keep anyone from using hrtimer, if it's just some driver
go wild, but in generic code we have to consider portability issues. Using
jiffies as a time base is still unbeatable cheap in the general case, so
we have to carefully consider whether using a different time source is
required. There is nothing wrong with using jiffies if it fits the bill
and in many cases it still does.
bye, Roman
-
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/