public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ia64: change usermode HZ to 250
@ 2006-06-27 22:01 hawkes
  2006-06-28  8:39 ` Arjan van de Ven
  0 siblings, 1 reply; 30+ messages in thread
From: hawkes @ 2006-06-27 22:01 UTC (permalink / raw)
  To: Tony Luck, Andrew Morton, linux-ia64, linux-kernel
  Cc: Jack Steiner, Dan Higgins, hawkes, Jeremy Higdon

include/asm-ia64/param.h defines HZ to be 1024 for usermode use, i.e.,
when the file gets installed as /usr/include/asm/param.h.
As the comment says:
    Technically, this is wrong, but some old apps still refer to it.  
    The proper way to get the HZ value is via sysconf(_SC_CLK_TCK).
At the very least, this technically wrong #define ought to reflect the
current default value (250) used by all arch/ia64 platforms.  No one uses
1024 anymore.  This makes those "old apps" (e.g., usr/bin/iostat) behave
properly for with a default kernel.  (And at some point, the define ought
to be removed altogether, which would expose all the applications that
erroneously expect HZ to be a compile-time constant.)

Signed-off-by: John Hawkes <hawkes@sgi.com>

Index: linux/include/asm-ia64/param.h
===================================================================
--- linux.orig/include/asm-ia64/param.h	2006-06-17 18:49:35.000000000 -0700
+++ linux/include/asm-ia64/param.h	2006-06-27 14:46:53.119407077 -0700
@@ -36,7 +36,7 @@
     * Technically, this is wrong, but some old apps still refer to it.  The proper way to
     * get the HZ value is via sysconf(_SC_CLK_TCK).
     */
-# define HZ 1024
+# define HZ 250
 #endif
 
 #endif /* _ASM_IA64_PARAM_H */

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: [PATCH] ia64: change usermode HZ to 250
@ 2006-06-27 22:26 Luck, Tony
  2006-06-27 23:09 ` Lee Revell
  2006-06-28  8:43 ` Arjan van de Ven
  0 siblings, 2 replies; 30+ messages in thread
From: Luck, Tony @ 2006-06-27 22:26 UTC (permalink / raw)
  To: hawkes, Tony Luck, Andrew Morton, linux-ia64, linux-kernel
  Cc: Jack Steiner, Dan Higgins, Jeremy Higdon

> -# define HZ 1024
> +# define HZ 250

Is every distribution just using the default 250? (How boring,
what't the use of CONFIG options if everyone makes the same choice).

No other architecture seems to want to be nice to applications,
I see "#define HZ 100" across most of them.  If this is going in,
it should fix all architectures.

Isn't the usual answer "applications should not include kernel
headers"?

-Tony

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: [PATCH] ia64: change usermode HZ to 250
@ 2006-06-28 17:36 Luck, Tony
  2006-06-29  9:37 ` Jes Sorensen
  0 siblings, 1 reply; 30+ messages in thread
From: Luck, Tony @ 2006-06-28 17:36 UTC (permalink / raw)
  To: Alan Cox, John Daiker
  Cc: John Hawkes, Arjan van de Ven, Tony Luck, Andrew Morton,
	linux-ia64, linux-kernel, Jack Steiner, Dan Higgins,
	Jeremy Higdon

> In the cached HZ case there will be no performance hit of measure
> anyway. The bigger problem is existing user space. That is why we've
> always kept the user visible HZ based values the same when changing the
> kernel HZ. You can't automatically regenerate all the old binaries you
> might otherwise break.

No we haven't kept user visible HZ the same ... look at times(2)
it reports in "clock ticks", and has a note on the manual page
that you must use sysconf(_SC_CLK_TCK) to find out how many ticks
are in a second.  So dusty deck binaries with hard-coded 100 (or
even older ones with 60 or 50) have been broken for a while now.

Also note that the sysconf(_SC_CLK_TCK) call doesn't take a
system call, the kernel passes CLOCKS_PER_SEC in the AT_CLKTCK
auxilliary vector during fs/binfmt_elf.c:create_elf_tables(),
so glibc can complete this call with a simple table lookup in
userspace.

Fixing param.h to have #define HZ sysconf(_SC_CLK_TCK) sounds
like a plausible solution, many incorrect uses will be fixed
automagically by the next rebuild.  But some more obscure usages
of HZ may not compile (which is good, then they can be fixed
properly) or worse may compile, but not do the right thing.

Removing it completely might be better, it may force people to
look at how they are using HZ.  But there are probably many old
programs that have:

#ifndef HZ
#define HZ 60
#endif

So this won't catch them.

The ultimate safe solution might be:

#define HZ Fix your program to use sysconf(_SC_CLK_TCK)! \
	(and BTW, you should not include kernel headers)

Which is highly likely to cause a compile failure (but should
at least provide a clue to the user on what they should do).

-Tony

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [PATCH] ia64: change usermode HZ to 250
@ 2006-06-29 14:09 Albert Cahalan
  0 siblings, 0 replies; 30+ messages in thread
From: Albert Cahalan @ 2006-06-29 14:09 UTC (permalink / raw)
  To: akpm, alan, arjan, hawkes, jdaiker, jes, linux-ia64, linux-kernel,
	tony.luck, tony.luck

> Fixing param.h to have #define HZ sysconf(_SC_CLK_TCK) sounds
> like a plausible solution, many incorrect uses will be fixed
> automagically by the next rebuild.  But some more obscure usages
> of HZ may not compile (which is good, then they can be fixed
> properly) or worse may compile, but not do the right thing.

This makes compiles fail on one of the non-glibc libraries,
either uClibc or dietlibc, which does not provide sysconf.

The order in which procps tries things is:

1. walk off the end of environ to get the ELF notes
2. /proc/uptime to /proc/stat ratio
3. HZ
4. lame guess based on endianness and word size

I do not want sysconf. It is is an unreliable piece of shit
that gives me poor guesses instead of returning appropriate
error codes. It does this swell job while being damn slow.
I can do no worse with my own random guess.

(on my TODO list: count CPUs myself, because glibc often
thinks there are zero -- and this is not an error code)

> The ultimate safe solution might be:
>
> #define HZ Fix your program to use sysconf(_SC_CLK_TCK)! \
>       (and BTW, you should not include kernel headers)
>
> Which is highly likely to cause a compile failure (but should
> at least provide a clue to the user on what they should do).

This breaks perfectly fine code, except that it will be yet one more
thing for people to patch out when making headers for userspace.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: [PATCH] ia64: change usermode HZ to 250
@ 2006-07-09 19:18 Luck, Tony
  0 siblings, 0 replies; 30+ messages in thread
From: Luck, Tony @ 2006-07-09 19:18 UTC (permalink / raw)
  To: Arjan van de Ven, Jeremy Higdon
  Cc: Jes Sorensen, Alan Cox, John Daiker, John Hawkes, Tony Luck,
	Andrew Morton, linux-ia64, linux-kernel, Jack Steiner,
	Dan Higgins

> > So is times() is broken in IA64, or is this an exception to Alan's
> > statement?

> yes it's broken; it needs to convert it to the original HZ (1024) and


http://www.opengroup.org/onlinepubs/007908799/xsh/times.html

In which there is a typo: 

"Applications should use to determine the number of clock ticks
 per second as it may vary from system to system"

Clearly the word "sysconf" is missing between "use" and "to" (sysconf()
*is* listed in the SEE ALSO section).

I thought that part of the reason Linus raised HZ from 100 to 1000
on x86 was to help flush out pre-historic programs that didn't
know about sysconf() [With the hope that results that are off by
an order of magnitude would be absurd enough to get notice].

> make the sysconf() function also return 1024

Making sysconf lie about the actual system tick sounds such a
bad idea on so many levels!

-Tony

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2006-07-12  2:02 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-27 22:01 [PATCH] ia64: change usermode HZ to 250 hawkes
2006-06-28  8:39 ` Arjan van de Ven
2006-06-28 15:43   ` John Hawkes
2006-06-28 16:21     ` Alan Cox
2006-06-28 16:11       ` John Daiker
2006-06-28 16:50         ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2006-06-27 22:26 Luck, Tony
2006-06-27 23:09 ` Lee Revell
2006-06-28  8:43 ` Arjan van de Ven
2006-06-28 10:47   ` Alan Cox
2006-06-28 10:34     ` Arjan van de Ven
2006-06-28 14:46       ` Christoph Lameter
2006-06-28 17:36 Luck, Tony
2006-06-29  9:37 ` Jes Sorensen
2006-06-29 11:02   ` Alan Cox
2006-06-29 10:48     ` Jes Sorensen
2006-06-29 10:55       ` Arjan van de Ven
2006-06-29 12:56         ` Jes Sorensen
2006-07-08  0:14         ` Jeremy Higdon
2006-07-08  2:51           ` Tony Luck
2006-07-08  6:42           ` Arjan van de Ven
2006-07-08 13:07             ` David Mosberger-Tang
2006-07-10 20:22               ` Jeremy Higdon
2006-07-11  3:01                 ` David Mosberger-Tang
2006-07-11 10:10                   ` Alan Cox
2006-07-11 18:37                   ` Jeremy Higdon
2006-07-12  2:02                     ` David Mosberger-Tang
2006-06-29 11:34       ` Alan Cox
2006-06-29 14:09 Albert Cahalan
2006-07-09 19:18 Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox