2001-07-16 16:12:25

by Rolf Fokkens

[permalink] [raw]
Subject: PATCH: /proc/sys/kernel/hz

Hi!

Some software (like procps) needs the HZ constant in the kernel. It's
sometimes determined by counting jiffies during a second. The attached patch
just "publishes" the HZ constant in /proc/sys/kernel/hz.

Rolf


Attachments:
linux-2.4.6-sysctl.hz.patch (1.54 kB)

2001-07-16 16:55:15

by Ulrich Drepper

[permalink] [raw]
Subject: Re: PATCH: /proc/sys/kernel/hz

Rolf Fokkens <[email protected]> writes:

> Some software (like procps) needs the HZ constant in the kernel. It's
> sometimes determined by counting jiffies during a second. The attached patch
> just "publishes" the HZ constant in /proc/sys/kernel/hz.

And what is wrong with

getconf CLK_TCK

or programmatically

hz = sysconf (_SC_CLK_TCK);


Update your libc and this info will come from the kernel.

--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------

2001-07-16 18:01:47

by Rolf Fokkens

[permalink] [raw]
Subject: RE: PATCH: /proc/sys/kernel/hz

Ulrich Drepper <[email protected]> writes:

>> Some software (like procps) needs the HZ constant in the kernel. It's
>> sometimes determined by counting jiffies during a second. The attached
patch
>> just "publishes" the HZ constant in /proc/sys/kernel/hz.
>
>And what is wrong with
> getconf CLK_TCK
>or programmatically
> hz = sysconf (_SC_CLK_TCK);

In short: it doesn't work: it reads 100 while I changed it to 1024 in my
kernel.

> Update your libc and this info will come from the kernel.

Neither RedHat 6.2 (glibc-2.1.3) nor SuSE 7.2 (glibc-2.2.2) works, so what
glibc version are you suggesting?

And suppose I have the right glibc, then the kernel may become a little
confusing:

bash# cd linux-2.4.6
bash# find . -name "*.c" -exec grep -q CLK_TCK {} \; -print
#define _SC_CLK_TCK 3
./arch/sparc/kernel/sys_sunos.c
#define _SC_CLK_TCK 3
./arch/sparc64/kernel/sys_sunos32.c
#define SOLARIS_CONFIG_CLK_TCK 7
./arch/sparc64/solaris/misc.c
bash# find . -name "*.h" -exec grep CLK_TCK {} \; -print
#define _SC_CLK_TCK 3
./include/asm-sparc64/unistd.h

Seems OK for sparc and maybe for solaris, for others it's a mess.

Rolf

2001-07-16 18:01:07

by Ulrich Drepper

[permalink] [raw]
Subject: Re: PATCH: /proc/sys/kernel/hz

Kurt Garloff <[email protected]> writes:

> Suppose HZ is variable. How does glibc find out about HZ of the _running_
> kernel? Just curious ... as I don't see a public place where the kernel
> publishes such info.

You people don't even know your kernel:

$ LD_SHOW_AUXV=1 getconf CLK_TCK

--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------

2001-07-16 18:03:37

by Kurt Garloff

[permalink] [raw]
Subject: Re: PATCH: /proc/sys/kernel/hz

On Mon, Jul 16, 2001 at 09:50:35AM -0700, Ulrich Drepper wrote:
>
> hz = sysconf (_SC_CLK_TCK);
>
> Update your libc and this info will come from the kernel.

Suppose HZ is variable. How does glibc find out about HZ of the _running_
kernel? Just curious ... as I don't see a public place where the kernel
publishes such info.

Regards,
--
Kurt Garloff <[email protected]> Eindhoven, NL
GPG key: See mail header, key servers Linux kernel development
SuSE GmbH, Nuernberg, FRG SCSI, Security


Attachments:
(No filename) (557.00 B)
(No filename) (232.00 B)
Download all attachments

2001-07-16 18:46:43

by Andreas Jaeger

[permalink] [raw]
Subject: Re: PATCH: /proc/sys/kernel/hz

Rolf Fokkens <[email protected]> writes:

> Ulrich Drepper <[email protected]> writes:
>
>>> Some software (like procps) needs the HZ constant in the kernel. It's
>>> sometimes determined by counting jiffies during a second. The attached
> patch
>>> just "publishes" the HZ constant in /proc/sys/kernel/hz.
>>
>>And what is wrong with
>> getconf CLK_TCK
>>or programmatically
>> hz = sysconf (_SC_CLK_TCK);
>
> In short: it doesn't work: it reads 100 while I changed it to 1024 in my
> kernel.

Then your kernel is broken, check AT_CLKTCK,

Andreas
--
Andreas Jaeger
SuSE Labs [email protected]
private [email protected]
http://www.suse.de/~aj

2001-07-16 19:25:38

by Rolf Fokkens

[permalink] [raw]
Subject: RE: PATCH: /proc/sys/kernel/hz

Right.

The macro CLOCKS_PER_SEC is used for AT_CLKTCK, and for some architectures
there actually _is_ a relationship between CLOCKS_PER_SEC and HZ, and for
some there is _not_ (linux/include/asm-*/param.h).

For i386 the relation apparently _is_ there. For IA64 there's the assumption
however that that the relation is _not_ there, the kernel assumes that it's
100 HZ for ia32 _always_. Weird.

Still leaves me wondering about procps.

Thanks,

Rolf

-----Original Message-----
From: Andreas Jaeger [mailto:[email protected]]
Sent: Monday, July 16, 2001 8:34 PM
To: Rolf Fokkens
Cc: '[email protected]'; '[email protected]';
'[email protected]'
Subject: Re: PATCH: /proc/sys/kernel/hz


Rolf Fokkens <[email protected]> writes:

> Ulrich Drepper <[email protected]> writes:
>
>>> Some software (like procps) needs the HZ constant in the kernel. It's
>>> sometimes determined by counting jiffies during a second. The attached
> patch
>>> just "publishes" the HZ constant in /proc/sys/kernel/hz.
>>
>>And what is wrong with
>> getconf CLK_TCK
>>or programmatically
>> hz = sysconf (_SC_CLK_TCK);
>
> In short: it doesn't work: it reads 100 while I changed it to 1024 in my
> kernel.

Then your kernel is broken, check AT_CLKTCK,

Andreas
--
Andreas Jaeger
SuSE Labs [email protected]
private [email protected]
http://www.suse.de/~aj