Skip to contentSkip to conversation

Increasing HZ (patch for HZ > 1000)

PATCH Jean-Marc Valin 13 participants 25 messages Dec 11, 2003 – Apr 7, 2004 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi,

I think this may be of interest to some people. I've attached a patch that makes it possible to increase HZ up to 10000. The patch adds some HZ-related defines (e.g. SHIFT_HZ) for higher HZ values. It also removes some shift by negative number and divide by zero (e.g. in bogomips computation) and prevents some overflows. I'm not sure I fixed everything, but right now it seems to work with HZ=10000. The only thing I'm seeing are messages such as: "orinoco_lock() called with hw_unavailable (dev=f75c8000)" and "eth1: IRQ handler is looping too much! Resetting.".

I know it's (much) too late for 2.6 but I'm sending the patch anyway so it (hopefully) doesn't get lost.

Jean-Marc

Signature · 3 lines
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada
include/linux/timex.h +6 -0
@@ -77,6 +77,12 @@
 # define SHIFT_HZ	9
 #elif HZ >= 768 && HZ < 1536
 # define SHIFT_HZ	10
+#elif HZ >= 1536 && HZ < 3072
+# define SHIFT_HZ	11
+#elif HZ >= 3072 && HZ < 6144
+# define SHIFT_HZ	12
+#elif HZ >= 6144 && HZ < 12288
+# define SHIFT_HZ	13
 #else
 # error You lose.
 #endif
init/main.c +2 -2
@@ -212,8 +212,8 @@
 
 /* Round the value and print it */	
 	printk("%lu.%02lu BogoMIPS\n",
-		loops_per_jiffy/(500000/HZ),
-		(loops_per_jiffy/(5000/HZ)) % 100);
+		HZ*(loops_per_jiffy>>3)/62500,
+		(HZ*(loops_per_jiffy>>3)/625)%100);
 }
 
 static int __init debug_kernel(char *str)
arch/i386/kernel/cpu/proc.c +2 -2
@@ -121,8 +121,8 @@
 			seq_printf(m, " %s", x86_cap_flags[i]);
 
 	seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
-		     c->loops_per_jiffy/(500000/HZ),
-		     (c->loops_per_jiffy/(5000/HZ)) % 100);
+                     HZ*(c->loops_per_jiffy>>3)/62500,
+                     (HZ*(c->loops_per_jiffy>>3)/625)%100);
 	return 0;
 }
 
kernel/timer.c +10 -2
@@ -561,7 +561,11 @@
 	if (ltemp > (MAXPHASE / MINSEC) << SHIFT_UPDATE)
 	    ltemp = (MAXPHASE / MINSEC) << SHIFT_UPDATE;
 	time_offset += ltemp;
-	time_adj = -ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
+#if SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE > 0
+	    time_adj = -ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
+#else
+	    time_adj = -ltemp >> (SHIFT_HZ + SHIFT_UPDATE - SHIFT_SCALE);
+#endif
     } else {
 	ltemp = time_offset;
 	if (!(time_status & STA_FLL))
@@ -569,7 +573,11 @@
 	if (ltemp > (MAXPHASE / MINSEC) << SHIFT_UPDATE)
 	    ltemp = (MAXPHASE / MINSEC) << SHIFT_UPDATE;
 	time_offset -= ltemp;
-	time_adj = ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
+#if SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE > 0
+	    time_adj = ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
+#else
+	    time_adj = ltemp >> (SHIFT_HZ + SHIFT_UPDATE - SHIFT_SCALE);
+#endif
     }
 
     /*
include/net/tcp.h +7 -3
@@ -486,8 +486,8 @@
    so that we select tick to get range about 4 seconds.
  */
 
-#if HZ <= 16 || HZ > 4096
-# error Unsupported: HZ <= 16 or HZ > 4096
+#if HZ <= 16 || HZ > 16384
+# error Unsupported: HZ <= 16 or HZ > 16384
 #elif HZ <= 32
 # define TCP_TW_RECYCLE_TICK (5+2-TCP_TW_RECYCLE_SLOTS_LOG)
 #elif HZ <= 64
@@ -502,8 +502,12 @@
 # define TCP_TW_RECYCLE_TICK (10+2-TCP_TW_RECYCLE_SLOTS_LOG)
 #elif HZ <= 2048
 # define TCP_TW_RECYCLE_TICK (11+2-TCP_TW_RECYCLE_SLOTS_LOG)
-#else
+#elif HZ <= 4096
 # define TCP_TW_RECYCLE_TICK (12+2-TCP_TW_RECYCLE_SLOTS_LOG)
+#elif HZ <= 8192
+# define TCP_TW_RECYCLE_TICK (13+2-TCP_TW_RECYCLE_SLOTS_LOG)
+#else
+# define TCP_TW_RECYCLE_TICK (14+2-TCP_TW_RECYCLE_SLOTS_LOG)
 #endif
 
 /*
drivers/char/dtlk.c +1 -1
@@ -207,7 +207,7 @@
 				   up to 250 usec for the RDY bit to
 				   go nonzero. */
 				for (retries = 0;
-				     retries < loops_per_jiffy / (4000/HZ);
+				     retries < HZ*(loops_per_jiffy>>5)/125;
 				     retries++)
 					if (inb_p(dtlk_port_tts) &
 					    TTS_WRITABLE)
include/linux/isicom.h +1 -1
@@ -147,7 +147,7 @@
 	int			close_delay;
 	unsigned short		channel;
 	unsigned short		status;
-	unsigned short		closing_wait;
+	unsigned int		closing_wait;
 	struct isi_board	* card;
 	struct tty_struct 	* tty;
 	wait_queue_head_t	close_wait;
include/linux/hayesesp.h +2 -2
@@ -87,8 +87,8 @@
 	int			stat_flags;
 	int			custom_divisor;
 	int			close_delay;
-	unsigned short		closing_wait;
-	unsigned short		closing_wait2;
+	unsigned int		closing_wait;
+	unsigned int		closing_wait2;
 	int			IER; 	/* Interrupt Enable Register */
 	int			MCR; 	/* Modem control register */
 	unsigned long		event;
include/linux/generic_serial.h +1 -1
@@ -42,7 +42,7 @@
   int                     blocked_open;
   struct tty_struct       *tty;
   unsigned long           event;
-  unsigned short          closing_wait;
+  unsigned int          closing_wait;
   int                     close_delay;
   struct real_driver      *rd;
   int                     wakeup_chars;
include/linux/cyclades.h +1 -1
@@ -581,7 +581,7 @@
 	int			custom_divisor;
 	int                     x_char; /* to be pushed out ASAP */
 	int			close_delay;
-	unsigned short		closing_wait;
+	unsigned int		closing_wait;
 	unsigned long		event;
 	unsigned long		last_active;
 	int			count;	/* # of fd on device */
include/linux/serialP.h +4 -4
@@ -47,8 +47,8 @@
 	int	count;
 	u8	*iomem_base;
 	u16	iomem_reg_shift;
-	unsigned short	close_delay;
-	unsigned short	closing_wait; /* time to wait before closing */
+	unsigned int	close_delay;
+	unsigned int	closing_wait; /* time to wait before closing */
 	struct async_icount	icount;	
 	int	io_type;
 	struct async_struct *info;
@@ -69,8 +69,8 @@
 	int			quot;
 	int			x_char;	/* xon/xoff character */
 	int			close_delay;
-	unsigned short		closing_wait;
-	unsigned short		closing_wait2; /* obsolete */
+	unsigned int		closing_wait;
+	unsigned int		closing_wait2; /* obsolete */
 	int			IER; 	/* Interrupt Enable Register */
 	int			MCR; 	/* Modem control register */
 	int			LCR; 	/* Line control register */
include/net/irda/ircomm_tty.h +2 -2
@@ -97,8 +97,8 @@
 	struct timer_list watchdog_timer;
 	struct work_struct  tqueue;
 
-        unsigned short    close_delay;
-        unsigned short    closing_wait; /* time to wait before closing */
+        unsigned int    close_delay;
+        unsigned int    closing_wait; /* time to wait before closing */
 
 	int  open_count;
 	int  blocked_open;	/* # of blocked opens */
include/linux/serial.h +3 -3
@@ -39,12 +39,12 @@
 	int	xmit_fifo_size;
 	int	custom_divisor;
 	int	baud_base;
-	unsigned short	close_delay;
+	unsigned int	close_delay;
 	char	io_type;
 	char	reserved_char[1];
 	int	hub6;
-	unsigned short	closing_wait; /* time to wait before closing */
-	unsigned short	closing_wait2; /* no longer used... */
+	unsigned int	closing_wait; /* time to wait before closing */
+	unsigned int	closing_wait2; /* no longer used... */
 	unsigned char	*iomem_base;
 	unsigned short	iomem_reg_shift;
 	unsigned int	port_high;
#1 lore raw
Quoted 9 lines

I think this may be of interest to some people. I've attached a patch that makes it possible to increase HZ up to 10000. The patch adds some HZ-related defines (e.g. SHIFT_HZ) for higher HZ values. It also removes some shift by negative number and divide by zero (e.g. in bogomips computation) and prevents some overflows. I'm not sure I fixed everything, but right now it seems to work with HZ=10000. The only thing I'm seeing are messages such as: "orinoco_lock() called with hw_unavailable (dev=f75c8000)" and "eth1: IRQ handler is looping too much! Resetting.".

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

M.

#2 lore raw
Quoted 3 lines

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

Jean-Marc

Signature · 3 lines
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada
#3 lore raw
Quoted 10 lines
Quoted 3 lines

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

Ha! ;-)
A hardware fix might be in order ;-)

M.

#4 lore raw
Quoted 12 lines · Martin J. Bligh
Quoted 11 lines
Quoted 3 lines

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

Quoted 2 lines

Ha! ;-)
A hardware fix might be in order ;-)

Indeed... I may have the only un-repaired Biostar M7VIB in the area out of several dozen. All the rest have had those 4 caps right above the AGP slot replaced already. And this one may also be the only one that doesn't get shut off at night. However it is also very unstable when starting from cold, needing 3-5 resets to even get through post without trashing the video after I had it apart to clean the cpu fan/sink and psu the other night. Its stable once thats been done, so I'm as usual, procrastinating. Been doing it for 69 years now. :)

Hardware indeed. I'm a Certified Electronics Technician. Have someone check all those electrolyric caps in the on-board psu in particular, using a device similar to a "Capacitor Wizard" which measures not the capacity of the cap, but the caps Equivalent Series Resistance (ESR) at 100 kilohertz or more. Anything over half an ohm should be replaced forthwith. This assumes of course that your tech in charge of hot solder has the tools to do it correctly. If not, find one who does have the tools.

Many mobos in a period ranging from about 2.5 to 1.5 years ago were built with caps that go defective prematurely due to a bad batch of them from several far eastern cap makers who were fed a bad recipe for the electrolyte in the caps, eg the Ethylene Glycol wasn't near pure enough.

Quoted 7 lines

M.

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

Signature · 7 lines
Cheers, Gene
AMD K6-III@500mhz 320M
Athlon1600XP@1400mhz  512M
99.22% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attornies please note, additions to this message
by Gene Heskett are:
Copyright 2003 by Maurice Eugene Heskett, all rights reserved.
#5 lore raw
Quoted 9 lines

Hardware indeed. I'm a Certified Electronics Technician. Have someone check all those electrolyric caps in the on-board psu in particular, using a device similar to a "Capacitor Wizard" which measures not the capacity of the cap, but the caps Equivalent Series Resistance (ESR) at 100 kilohertz or more. Anything over half an ohm should be replaced forthwith. This assumes of course that your tech in charge of hot solder has the tools to do it correctly. If not, find one who does have the tools.

Quoted 5 lines

Many mobos in a period ranging from about 2.5 to 1.5 years ago were built with caps that go defective prematurely due to a bad batch of them from several far eastern cap makers who were fed a bad recipe for the electrolyte in the caps, eg the Ethylene Glycol wasn't near pure enough.

When you say "fed a bad recipe", didn't they actually steal it? Or is that just an urban legend?

M.

#6 lore raw
Quoted 15 lines · Martin J. Bligh
Quoted 9 lines

Hardware indeed. I'm a Certified Electronics Technician. Have someone check all those electrolyric caps in the on-board psu in particular, using a device similar to a "Capacitor Wizard" which measures not the capacity of the cap, but the caps Equivalent Series Resistance (ESR) at 100 kilohertz or more. Anything over half an ohm should be replaced forthwith. This assumes of course that your tech in charge of hot solder has the tools to do it correctly. If not, find one who does have the tools.

Quoted 5 lines

Many mobos in a period ranging from about 2.5 to 1.5 years ago were built with caps that go defective prematurely due to a bad batch of them from several far eastern cap makers who were fed a bad recipe for the electrolyte in the caps, eg the Ethylene Glycol wasn't near pure enough.

Quoted 4 lines

When you say "fed a bad recipe", didn't they actually steal it? Or is that just an urban legend?

M.

"Appropriated". Also, it isn't ethylene glycol (that's antifreeze), It's potassium hydroxide with an inhibitor. The inhibitor was cleverly removed from the recipe and left out to be stolen. As expected, it was. Unfortunately, the bad caps didn't damage the competing company bad enough to put them out-of-business so the whole ploy was a waste of effort. ;^)

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

#7 lore raw
Quoted 1 line · Richard B. Johnson

On Thu, 11 Dec 2003, Martin J. Bligh wrote:

No, Gene Heskett wrote this:

Quoted 18 lines
Quoted 18 lines
Quoted 9 lines

Hardware indeed. I'm a Certified Electronics Technician. Have someone check all those electrolyric caps in the on-board psu in particular, using a device similar to a "Capacitor Wizard" which measures not the capacity of the cap, but the caps Equivalent Series Resistance (ESR) at 100 kilohertz or more. Anything over half an ohm should be replaced forthwith. This assumes of course that your tech in charge of hot solder has the tools to do it correctly. If not, find one who does have the tools.

Quoted 5 lines

Many mobos in a period ranging from about 2.5 to 1.5 years ago were built with caps that go defective prematurely due to a bad batch of them from several far eastern cap makers who were fed a bad recipe for the electrolyte in the caps, eg the Ethylene Glycol wasn't near pure enough.

When you say "fed a bad recipe", didn't they actually steal it? Or is that just an urban legend?

Quoted 8 lines
Quoted 1 line

M.

"Appropriated". Also, it isn't ethylene glycol (that's antifreeze), It's potassium hydroxide with an inhibitor. The inhibitor was cleverly removed from the recipe and left out to be stolen. As expected, it was. Unfortunately, the bad caps didn't damage the competing company bad enough to put them out-of-business so the whole ploy was a waste of effort. ;^)

I believe that potassium hydroxide, an extremely alkaline chemical, is involved with tantalum capacitors only. For electrolytics, its always been, and probably always will be, Ethylene Glycol to replace the air in the kraft paper foil seperator, and furnish a high dielectric constant, several times that of air. "Antifreeze", yes but without any inhibiters, none, technical pure grade only. Resistance in CM3 measured in siemans if you have a meter that goes that high. Most don't.

It doesn't take much on a per cap basis though. I almost single-handedly caused a nationwide shortage of capacitors one winter back in the 70's when I needed some pure stuff for the tv transmitter I was in charge of at the time. Seems that during the OPEC oil embargo, the only 55 gallon barrel of any kind of ethylene glycol in the whole country was a barrel of technical grade, sitting on the dock of the Mobil distributor 100 miles down the road in Omaha NE. I probably ran up a 500 dollar phone bill just finding it because I started at the refineries on the coasts.

It was either pay the about 10 bucks a gallon for it or go off the air. I paid, or rather the Nebraska ETV commission paid and bought that last barrel and KXNE-TV stayed on the air that winter.

It wasn't till late the next summer when the replacement capacitor shelf at your local electronics supplier finally started to get some dust cover again. It got pretty bare there for a few months.

Another of your trivia factoids for the day :-)

Signature · 7 lines
Cheers, Gene
AMD K6-III@500mhz 320M
Athlon1600XP@1400mhz  512M
99.22% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attornies please note, additions to this message
by Gene Heskett are:
Copyright 2003 by Maurice Eugene Heskett, all rights reserved.
#8 lore raw
In reply to Martin J. Bligh
Quoted 15 lines · Martin J. Bligh
Quoted 9 lines

Hardware indeed. I'm a Certified Electronics Technician. Have someone check all those electrolyric caps in the on-board psu in particular, using a device similar to a "Capacitor Wizard" which measures not the capacity of the cap, but the caps Equivalent Series Resistance (ESR) at 100 kilohertz or more. Anything over half an ohm should be replaced forthwith. This assumes of course that your tech in charge of hot solder has the tools to do it correctly. If not, find one who does have the tools.

Quoted 5 lines

Many mobos in a period ranging from about 2.5 to 1.5 years ago were built with caps that go defective prematurely due to a bad batch of them from several far eastern cap makers who were fed a bad recipe for the electrolyte in the caps, eg the Ethylene Glycol wasn't near pure enough.

Quoted 4 lines

When you say "fed a bad recipe", didn't they actually steal it? Or is that just an urban legend?

M.

Well, I *was* trying to be nice<vsg>. I'd made the assumption that the supplier was the one doing the stealing, and that they (the cap makers as buyers of this cheaper than usual product) were not 100% aware of the problems at the time. Yes, I've read the story, and the history of capacitor failures over the last 2 years does seem to lend considerable credance to the story. When you are a CET, doing component level repairs for a living for the last 50 some years, some things do get your attention, and poor life of capacitors has long since become the single leading failure of things electronic, recently by a factor measured in magnitudes over anything else, like bad semiconductors. Thats been the tend for the last 10 years in fact. Poor lubrication of things basicly mechanical like electrical switches is now second on the list, with a lot of white space between them.

The windshield wiper speed switch in your car being a prime example of that 2nd type of failure. If it hasn't miss-behaved, it will. Pull the knob off the end of the stalk and remove the super sticky syrupy grease there and replace it with lubriplate, end of problem, probably forever. Certainly for as long as you'll own it. Your trivia fact for the day :-)

Signature · 7 lines
Cheers, Gene
AMD K6-III@500mhz 320M
Athlon1600XP@1400mhz  512M
99.22% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attornies please note, additions to this message
by Gene Heskett are:
Copyright 2003 by Maurice Eugene Heskett, all rights reserved.
#9 lore raw
In reply to Martin J. Bligh

Hi!

Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

Quoted 2 lines

Ha! ;-)
A hardware fix might be in order ;-)

Every notebook from thinkpad 560X up has produced some kind of cpu-load-related-noise. You'd have to throw out quite a lot of notebooks...
Pavel
PS: Jean, can you try how high you can get it? You might want to go to 24kHz so that no human can hear it, or to 100kHz to be kind to cats. At ~1MHz you'd be even kind to bats :-), but it is probably impossible to get over 200kHz or so. Still it might be funny experiment.

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#10 lore raw
Quoted 3 lines

Every notebook from thinkpad 560X up has produced some kind of cpu-load-related-noise. You'd have to throw out quite a lot of notebooks...

You're right, I'm probably not the only one. It may be worth at least having an option to change HZ to less annoying values. Otherwise there are going to be lots of complaints when people try out 2.6 on their laptops and hear that noise. On mine, I seriously could not stand the noise more than 5 minutes. Not because it was that loud but 1 kHz is really annoying.

Quoted 5 lines

PS: Jean, can you try how high you can get it? You might want to go to 24kHz so that no human can hear it, or to 100kHz to be kind to cats. At ~1MHz you'd be even kind to bats :-), but it is probably impossible to get over 200kHz or so. Still it might be funny experiment.

For now, my patch only allows up to around 10 kHz. At that frequency, I don't hear anything because the noise is not loud enough (ear is much more sensitive at 1 kHz). Also, I have around 10% overhead on my Pentium-M 1.6 GHz, so I guess it's not for everyone. Extrapolating from there, I'd also say that at 100 kHz, it wouldn't do anything but handle the interrupts, which is slightly annoying when you want to actually get some work done :)

Jean-Marc

Signature · 3 lines
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada
#11 lore raw
Quoted 5 lines · Jean-Marc Valin

more sensitive at 1 kHz). Also, I have around 10% overhead on my Pentium-M 1.6 GHz, so I guess it's not for everyone. Extrapolating from there, I'd also say that at 100 kHz, it wouldn't do anything but handle the interrupts, which is slightly annoying when you want to actually get some work done :)

I once forgot to acknowledge an interrupt in the handler for a PCI board. It ended up being called ~300k times per second. The system load was noticeable.

Signature · 2 lines
Måns Rullgård
[email protected]
#12 lore raw
In reply to Jean-Marc Valin

Hi!

Quoted 10 lines
Quoted 3 lines

Every notebook from thinkpad 560X up has produced some kind of cpu-load-related-noise. You'd have to throw out quite a lot of notebooks...

You're right, I'm probably not the only one. It may be worth at least having an option to change HZ to less annoying values. Otherwise there are going to be lots of complaints when people try out 2.6 on their laptops and hear that noise. On mine, I seriously could not stand the noise more than 5 minutes. Not because it was that loud but 1 kHz is really annoying.

Okay, we are probably taking other sounds. I can hear cpu-load-related noise on every notebook from thinkpad 560X -- in a quiet room, and on some machines its rather hard to notice. You probably have way more annoying problem.

Quoted 6 lines
Quoted 5 lines

PS: Jean, can you try how high you can get it? You might want to go to 24kHz so that no human can hear it, or to 100kHz to be kind to cats. At ~1MHz you'd be even kind to bats :-), but it is probably impossible to get over 200kHz or so. Still it might be funny experiment.

Quoted 7 lines

For now, my patch only allows up to around 10 kHz. At that frequency, I don't hear anything because the noise is not loud enough (ear is much more sensitive at 1 kHz). Also, I have around 10% overhead on my Pentium-M 1.6 GHz, so I guess it's not for everyone. Extrapolating from there, I'd also say that at 100 kHz, it wouldn't do anything but handle the interrupts, which is slightly annoying when you want to actually get some work done :)

I wonder what happens at 200kHz then; system might detect some lost ticks and keep running at very slow speed...
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#13 lore raw
Quoted 11 lines · Pavel Machek
Quoted 10 lines
Quoted 3 lines

Every notebook from thinkpad 560X up has produced some kind of cpu-load-related-noise. You'd have to throw out quite a lot of notebooks...

You're right, I'm probably not the only one. It may be worth at least having an option to change HZ to less annoying values. Otherwise there are going to be lots of complaints when people try out 2.6 on their laptops and hear that noise. On mine, I seriously could not stand the noise more than 5 minutes. Not because it was that loud but 1 kHz is really annoying.

Quoted 4 lines

Okay, we are probably taking other sounds. I can hear cpu-load-related noise on every notebook from thinkpad 560X -- in a quiet room, and on some machines its rather hard to notice. You probably have way more annoying problem.

My laptop makes a slight noise in the speakers when there are interrupts. It's only noticeable with an external amplifier connected. There's also some ~1 kHz sound coming from the vicinity of the CPU, particularly when there is network activity.

Signature · 2 lines
Måns Rullgård
[email protected]
#14 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek
Quoted 7 lines

For now, my patch only allows up to around 10 kHz. At that frequency, I don't hear anything because the noise is not loud enough (ear is much more sensitive at 1 kHz). Also, I have around 10% overhead on my Pentium-M 1.6 GHz, so I guess it's not for everyone. Extrapolating from there, I'd also say that at 100 kHz, it wouldn't do anything but handle the interrupts, which is slightly annoying when you want to actually get some work done :)

I wonder what happens at 200kHz then; system might detect some lost ticks and keep running at very slow speed...

Indeed, with all the trouble HZ==1000 has caused, I'm thinking that playing w/ HZ at 10k and 10 would be good stress tests for the time subsystem.

I'd be interested in hearing how much drift people see when running w/ this patch.

thanks
-john

#15 lore raw
Quoted 3 lines · john stultz

Indeed, with all the trouble HZ==1000 has caused, I'm thinking that playing w/ HZ at 10k and 10 would be good stress tests for the time subsystem.

I think setting HZ much lower than 100 might break some drivers that do things like:

		timeout = jiffies + (HZ / 50);

Not sure if any of the common drivers have this problem but be on the lookout for it if you want to try running w/ really low HZ.

I suppose there should really be a "FRACTION_OF_SECOND()" macro or something that always returns >0 for specifying these really short delays.

-Mitch

#16 lore raw
In reply to Jean-Marc Valin

In article <[email protected]>, Jean-Marc Valin <[email protected]> wrote:

| 
| > Every notebook from thinkpad 560X up has produced some kind of
| > cpu-load-related-noise. You'd have to throw out quite a lot of
| > notebooks...
| 
| You're right, I'm probably not the only one. It may be worth at least
| having an option to change HZ to less annoying values. Otherwise there
| are going to be lots of complaints when people try out 2.6 on their
| laptops and hear that noise. On mine, I seriously could not stand the
| noise more than 5 minutes. Not because it was that loud but 1 kHz is
| really annoying.
| 
| > PS: Jean, can you try how high you can get it? You might want to go to
| > 24kHz so that no human can hear it, or to 100kHz to be kind to
| > cats. At ~1MHz you'd be even kind to bats :-), but it is probably
| > impossible to get over 200kHz or so. Still it might be funny
| > experiment.
| 
| For now, my patch only allows up to around 10 kHz. At that frequency, I
| don't hear anything because the noise is not loud enough (ear is much
| more sensitive at 1 kHz). Also, I have around 10% overhead on my
| Pentium-M 1.6 GHz, so I guess it's not for everyone. Extrapolating from
| there, I'd also say that at 100 kHz, it wouldn't do anything but handle
| the interrupts, which is slightly annoying when you want to actually get
| some work done :)
| 
| 	Jean-Marc

Stop! This is Linux we're talking about, if we can have Morse code panic messages, we can certainly have the idle loop change frequency to play a tune on the output capacitors (or whatever else make noise). How about the Penguin army marching music from the Saturday morning cartoon, and maybe hack LinuxBIOS to check for Windows running and have the idle loop play Twilight of the Gods.

I better stop before someone actually does it.

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#17 lore raw

sometime before now (bill davidsen) wrote this blurb:

Quoted 8 lines

Stop! This is Linux we're talking about, if we can have Morse code panic messages, we can certainly have the idle loop change frequency to play a tune on the output capacitors (or whatever else make noise). How about the Penguin army marching music from the Saturday morning cartoon, and maybe hack LinuxBIOS to check for Windows running and have the idle loop play Twilight of the Gods.

I better stop before someone actually does it.

what about the xfree hack that would let you use a monitor as an AM broadcasting station by tweaking on something?

http://slashdot.org/articles/01/11/26/2353252.shtml

Pat Erley

#18 lore raw
In reply to Jean-Marc Valin
Quoted 5 lines · Jean-Marc Valin
Quoted 4 lines

Why would you want to *increase* HZ? I'd say 1000 is already too high personally, but I'm curious what you'd want to do with it? Embedded real-time stuff?

Quoted 7 lines

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

Heh! Does it scare your dog away? ;)

#19 lore raw
In reply to Jean-Marc Valin
Quoted 6 lines

Actually, my reasons may sound a little strange, but basically I'd be fine with HZ=1000 if it wasn't for that annoying ~1 kHz sound when the CPU is idle (probably bad capacitors). By increasing HZ to 10 kHz, the sound is at a frequency where the ear is much less sensitive. Anyway, I thought some people might be interested in high HZ for other (more fundamental) reasons, so I posted the patch.

=8-)
I'd guess a tickless kernel might be what you actually want. See e.g.

http://sourceforge.net/projects/high-res-timers/

Tim

#20 lore raw
In reply to Martin J. Bligh

Just one more thing about the patch I sent. I think it addresses something unclean in the bogomips computation. For example, in arch/i386/kernel/cpu/proc.c, you have:

seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",

           c->loops_per_jiffy/(500000/HZ),
           (c->loops_per_jiffy/(5000/HZ)) % 100);

It's clear that for any case where 5000/HZ is not an integer, the bogomips decimals will be wrong and if 500000/HZ isn't an integer, the bogomips integer part will be wrong.

For example on a 2 GHz processor with a 4000 bogomips value and HZ=1200, the code above will produce 3996.66 instead of 4000. Of course, as soon as HZ goes above 5000, you have a divide by zero right at compile time.

Jean-Marc

Signature · 3 lines
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada
#21 lore raw

Hi!

Quoted 8 lines

Just one more thing about the patch I sent. I think it addresses something unclean in the bogomips computation. For example, in arch/i386/kernel/cpu/proc.c, you have:

seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",

           c->loops_per_jiffy/(500000/HZ),
           (c->loops_per_jiffy/(5000/HZ)) % 100);
Quoted 7 lines

It's clear that for any case where 5000/HZ is not an integer, the bogomips decimals will be wrong and if 500000/HZ isn't an integer, the bogomips integer part will be wrong.

For example on a 2 GHz processor with a 4000 bogomips value and HZ=1200, the code above will produce 3996.66 instead of 4000. Of course, as soon as HZ goes above 5000, you have a divide by zero right at compile time.

Well, on i386 we only run with HZ=100 and HZ=1000, so bug is latent, but if you can find nice way to rewrite it without the bug, it would probably be worth fixing.
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#22 lore raw
Quoted 3 lines

Well, on i386 we only run with HZ=100 and HZ=1000, so bug is latent, but if you can find nice way to rewrite it without the bug, it would probably be worth fixing.

Actually, the way I rewrote it in the patch is immune to that kind of problem:

seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",

           HZ*(c->loops_per_jiffy>>3)/62500,
           (HZ*(c->loops_per_jiffy>>3)/625)%100);

It will work correctly for any HZ up to ~34000 bogomips (using 32-bit arithmetic).

Jean-Marc

Signature · 3 lines
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada
#23 lore raw
Quoted 9 lines · Jean-Marc Valin

Actually, the way I rewrote it in the patch is immune to that kind of problem:

seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",

           HZ*(c->loops_per_jiffy>>3)/62500,
           (HZ*(c->loops_per_jiffy>>3)/625)%100);

It will work correctly for any HZ up to ~34000 bogomips (using 32-bit arithmetic).

I think it's likely any CPU with 34000 bogomips will have more than 32 bit ;-)

Signature · 3 lines
bill davidsen <[email protected]>
  CTO TMR Associates, Inc
  Doing interesting things with small computers since 1979

A message that is not in the archive (sent off-list or not yet received): [email protected]

#25 lore raw

Hi!

Quoted 7 lines
Quoted 7 lines

Actually, the way I rewrote it in the patch is immune to that kind of problem:

seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",

          HZ*(c->loops_per_jiffy>>3)/62500,
          (HZ*(c->loops_per_jiffy>>3)/625)%100);
Quoted 5 lines
Quoted 2 lines

It will work correctly for any HZ up to ~34000 bogomips (using 32-bit arithmetic).

I think it's likely any CPU with 34000 bogomips will have more than 32 bit ;-)

Hmmm, but it will perhaps be running in compatibility mode.

;-),
Pavel

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms