logo
Published on KernelTrap (http://kerneltrap.org)

Linux: Changing The Default Hertz

By Jeremy
Created Jul 11 2005 - 09:43

A recent discussion on the lkml [1] debated the merits of modifying the default hertz of the Linux kernel. The default hertz of the 2.4 kernel is 100 Hz, while the default hertz of the 2.6 kernel is currently 1000 Hz. In Andrew Morton [interview [2]]'s plans for 2.6.13 [story [3]] he lists a patch tagged with the comment, "changes default HZ to 250, make HZ Kconfigurable". As to why 250Hz was chosen, Linus explained [4] in an email from May of 2004, "1kHz is also good in that it makes it easy to convert both to USER_HZ and to ms/ns. But maybe something like 250Hz would be better - still high enough that things like multimedia (which really wants higher frequencies in order to be able to sleep for fractional video-frames) should be happy, low enough that we use less CPU."

Andrew Morton explained that the problems with the current 2.6 default Hz are, "some machines exhibit appreciable latency in entering low power state via ACPI, and 1000Hz reduces their battery life. By about half, iirc." However, Alan Cox [interview [5]] suggested that reducing the Hz to 250 may not be enough to solve these problems, "100Hz is good for power management/older boxes, 250Hz is too fast for some laptop APM to avoid clock slew, too fast for power saving and too slow for some multimedia weenies." As to how 1000Hz was selected in the first place, Linus Torvalds explained, "I chose 1000 originally partly as a way to make sure that people that assumed HZ was 100 would get a swift kick in the pants. That meant making a _big_ change, not a small subtle one." He added, "so 1kHz was a bit of an overkill, but it worked well enough that we never really got around to changing it."


From: Chris Wedgwood [email blocked]
To: Linux Kernel Mailing List [email blocked]
Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt
Date:	Fri, 8 Jul 2005 14:49:08 -0700

On Thu, Jun 23, 2005 at 11:28:47AM -0700, Linux Kernel Mailing List wrote:

> [PATCH] i386: Selectable Frequency of the Timer Interrupt

[...]

> +choice
> +	prompt "Timer frequency"
> +	default HZ_250

WHAT?

The previous value here i386 is 1000 --- so why is the default 250.

Changing the *default* time interrupt frequency in a stable series is
*really* bad idea if you ask me.


Now that this has hit mainline please consider applying:


--- kernel/Kconfig.hz~	2005-06-24 22:16:35.023986593 -0700
+++ kernel/Kconfig.hz	2005-07-08 14:46:35.428917597 -0700
@@ -4,7 +4,7 @@
 
 choice
 	prompt "Timer frequency"
-	default HZ_250
+	default HZ_1000
 	help
 	 Allows the configuration of the timer frequency. It is customary
 	 to have the timer interrupt run at 1000 HZ but 100 HZ may be more


From: Andrew Morton [6] [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Fri, 8 Jul 2005 14:59:53 -0700 Chris Wedgwood [email blocked] wrote: > > On Thu, Jun 23, 2005 at 11:28:47AM -0700, Linux Kernel Mailing List wrote: ^^^^^^ It's been over two weeks and nobody has complained about anything. > > > [PATCH] i386: Selectable Frequency of the Timer Interrupt > > [...] > > > +choice > > + prompt "Timer frequency" > > + default HZ_250 > > WHAT? > > The previous value here i386 is 1000 --- so why is the default 250. Because 1000 is too high. > Now that this has hit mainline please consider applying: We might indeed do that. But if nobody continues to notice anything, we might not. We'll see.
From: Chris Wedgwood [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Fri, 8 Jul 2005 15:05:21 -0700 On Fri, Jul 08, 2005 at 02:59:53PM -0700, Andrew Morton wrote: > > On Thu, Jun 23, 2005 at 11:28:47AM -0700, Linux Kernel Mailing List wrote: > ^^^^^^ > It's been over two weeks and nobody has complained about anything. Two weeks isn't that long IMO (I only just noticed myself). > Because 1000 is too high. How so? There have been comparatively few complaints about this since we switched quite some time ago. Strictly speaking I agree 1000 might be too high --- but we've had it for so long now, almost all over 2.5.x (I think?) and all of 2.6.x.
From: Linus Torvalds [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Fri, 8 Jul 2005 15:08:19 -0700 (PDT) On Fri, 8 Jul 2005, Andrew Morton wrote: > > > > The previous value here i386 is 1000 --- so why is the default 250. > > Because 1000 is too high. Yes. I chose 1000 originally partly as a way to make sure that people that assumed HZ was 100 would get a swift kick in the pants. That meant making a _big_ change, not a small subtle one. For example, people tend to react if "uptime" suddenly says the machine has been up for a hundred days (even if it's really only been up for ten), but if it is off by just a factor of two, it might be overlooked. So 1kHz was a bit of an overkill, but it worked well enough that we never really got around to changing it. Linus
From: Andrew Morton [7] [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Fri, 8 Jul 2005 15:33:27 -0700 Lee Revell <rlrevell@joe-job.com> wrote: > > On Fri, 2005-07-08 at 14:59 -0700, Andrew Morton wrote: > > Chris Wedgwood [email blocked] wrote: > > > > > > On Thu, Jun 23, 2005 at 11:28:47AM -0700, Linux Kernel Mailing List wrote: > > ^^^^^^ > > > > It's been over two weeks and nobody has complained about anything. > > Wrong, I complained loudly about this as soon as it was posted, about > two weeks ago. You know what I mean. Nobody has yet reported adverse effects upon real applications.
From: Martin Schlemmer [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Sat, 09 Jul 2005 19:08:11 +0200 On Fri, 2005-07-08 at 14:59 -0700, Andrew Morton wrote: > Chris Wedgwood [email blocked] wrote: > > WHAT? > > > > The previous value here i386 is 1000 --- so why is the default 250. > > Because 1000 is too high. > What happened to 300 as default, as that is divisible by both 50 and 60 (or something like that) ? Wanted to remember somebody suggested rather using that ... Curiosity sake. Thanks, -- Martin Schlemmer
From: Lee Revell <rlrevell@joe-job.com> Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Sat, 09 Jul 2005 14:16:31 -0400 On Sat, 2005-07-09 at 19:08 +0200, Martin Schlemmer wrote: > On Fri, 2005-07-08 at 14:59 -0700, Andrew Morton wrote: > > Chris Wedgwood [email blocked] wrote: > > > > WHAT? > > > > > > The previous value here i386 is 1000 --- so why is the default 250. > > > > Because 1000 is too high. > > > > What happened to 300 as default, as that is divisible by both 50 and 60 > (or something like that) ? I still think you're absolutely insane to change the default in the middle of a stable kernel series. People WILL complain about it. Lee
From: Arjan van de Ven [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Sat, 09 Jul 2005 20:31:55 +0200 On Sat, 2005-07-09 at 14:16 -0400, Lee Revell wrote: > On Sat, 2005-07-09 at 19:08 +0200, Martin Schlemmer wrote: > > On Fri, 2005-07-08 at 14:59 -0700, Andrew Morton wrote: > > > Chris Wedgwood [email blocked] wrote: > > > > > > WHAT? > > > > > > > > The previous value here i386 is 1000 --- so why is the default 250. > > > > > > Because 1000 is too high. > > > > > > > What happened to 300 as default, as that is divisible by both 50 and 60 > > (or something like that) ? > > I still think you're absolutely insane to change the default in the > middle of a stable kernel series. People WILL complain about it. why? it's a config option. Some distros ship 100 already, others 1000, again others will do 250. What does it matter? (Although I still prefer 300 over 250 due to the 50/60 thing) This is not a userspace visible thing really with few exceptions, and well people can select the one they want, right?
From: Lee Revell <rlrevell@joe-job.com> Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Sat, 09 Jul 2005 14:36:02 -0400 On Sat, 2005-07-09 at 20:31 +0200, Arjan van de Ven wrote: > why? Because the minimum poll/select timeout is now 4ms rather than 1ms. An app that has a soft RT constraint somewhere in the middle that worked on 2.6.12 will break on 2.6.13. > it's a config option. Some distros ship 100 already, others 1000, again > others will do 250. What does it matter? > (Although I still prefer 300 over 250 due to the 50/60 thing) > > This is not a userspace visible thing really with few exceptions, and > well people can select the one they want, right? Then why not leave the default at 1000? Lee
From: Andrew Morton [8] [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Sat, 9 Jul 2005 12:12:12 -0700 Lee Revell <rlrevell@joe-job.com> wrote: > > > This is not a userspace visible thing really with few exceptions, and > > well people can select the one they want, right? > > Then why not leave the default at 1000? Because some machines exhibit appreciable latency in entering low power state via ACPI, and 1000Hz reduces their battery life. By about half, iirc.
From: Alan Cox [9] [email blocked] To: Andrew Morton [email blocked] Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt Date: Mon, 11 Jul 2005 14:18:51 +0100 On Gwe, 2005-07-08 at 22:59, Andrew Morton wrote: > Chris Wedgwood [email blocked] wrote: > > > > On Thu, Jun 23, 2005 at 11:28:47AM -0700, Linux Kernel Mailing List wrote: > ^^^^^^ > > It's been over two weeks and nobody has complained about anything. Then your mail system is faulty because I did. 1000Hz is good for multmedia, 100Hz is good for power management/older boxes, 250Hz is too fast for some laptop APM to avoid clock slew, too fast for power saving and too slow for some multimedia weenies.



Related Links:


Source URL:
http://kerneltrap.org/node/5411