Subject: [RFC] HZ entry in /proc/sys/kernel

I have seen few scripts allready that are assuming HZ==100.
Afaik this value is different in 2.5/2.4 for the same arch.
So is it worth to add on both simple /proc/sys/kernel/HZ ?

Simple patch for 2.4.21-rc3 , if it is allright i will do same thing for
2.5

----------------------------------------------------------

diff -ur 2/include/linux/sysctl.h 1/include/linux/sysctl.h
--- 2/include/linux/sysctl.h 2003-05-24 12:10:35.000000000 +0100
+++ 1/include/linux/sysctl.h 2003-05-26 12:44:16.000000000 +0100
@@ -125,6 +125,7 @@
KERN_TAINTED=53, /* int: various kernel tainted flags */
KERN_CADPID=54, /* int: PID of the process to notify on
CAD */
KERN_CORE_PATTERN=56, /* string: pattern for core-files */
+ KERN_HZ=57, /* int: HZ value */
};


diff -ur 2/kernel/sysctl.c 1/kernel/sysctl.c
--- 2/kernel/sysctl.c 2003-05-26 12:33:37.000000000 +0100
+++ 1/kernel/sysctl.c 2003-05-26 12:45:31.000000000 +0100
@@ -32,6 +32,7 @@
#include <linux/highuid.h>

#include <asm/uaccess.h>
+#include <asm/param.h>

#ifdef CONFIG_ROOT_NFS
#include <linux/nfs_fs.h>
@@ -123,6 +124,8 @@

#ifdef CONFIG_PROC_FS

+static unsigned int hz=HZ;
+
static ssize_t proc_readsys(struct file *, char *, size_t, loff_t *);
static ssize_t proc_writesys(struct file *, const char *, size_t,
loff_t *);
static int proc_sys_permission(struct inode *, int);
@@ -244,6 +247,8 @@
0600, NULL, &proc_dointvec},
{KERN_MAX_THREADS, "threads-max", &max_threads, sizeof(int),
0644, NULL, &proc_dointvec},
+ {KERN_HZ, "HZ", &hz, sizeof(unsigned int),
+ 0444, NULL, &proc_dointvec},
{KERN_RANDOM, "random", NULL, 0, 0555, random_table},
{KERN_OVERFLOWUID, "overflowuid", &overflowuid, sizeof(int),
0644, NULL,
&proc_dointvec_minmax, &sysctl_intvec, NULL,


--
Grzegorz Jaskiewicz <[email protected]>
K4 labs


2003-05-26 15:43:08

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [RFC] HZ entry in /proc/sys/kernel

On Mon, 2003-05-26 at 13:53, Grzegorz Jaskiewicz wrote:
> I have seen few scripts allready that are assuming HZ==100.
> Afaik this value is different in 2.5/2.4 for the same arch.

No it's not actually.
The userspace interface is constant/stable and in units of HZ=100 even
though the kernel HZ might be different.


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2003-05-27 19:26:33

by Daniele Pala

[permalink] [raw]
Subject: Re: [RFC] HZ entry in /proc/sys/kernel

On Mon, May 26, 2003 at 02:15:57PM +0200, Arjan van de Ven wrote:
> On Mon, 2003-05-26 at 13:53, Grzegorz Jaskiewicz wrote:
> > I have seen few scripts allready that are assuming HZ==100.
> > Afaik this value is different in 2.5/2.4 for the same arch.
>
> No it's not actually.
> The userspace interface is constant/stable and in units of HZ=100 even
> though the kernel HZ might be different.
>

What's this HZ value related to?
cheers,
Daniele

2003-05-27 19:29:36

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [RFC] HZ entry in /proc/sys/kernel


On Tue, May 27, 2003 at 09:39:57PM +0200, Daniele wrote:
> On Mon, May 26, 2003 at 02:15:57PM +0200, Arjan van de Ven wrote:
> > On Mon, 2003-05-26 at 13:53, Grzegorz Jaskiewicz wrote:
> > > I have seen few scripts allready that are assuming HZ==100.
> > > Afaik this value is different in 2.5/2.4 for the same arch.
> >
> > No it's not actually.
> > The userspace interface is constant/stable and in units of HZ=100 even
> > though the kernel HZ might be different.
> >
>
> What's this HZ value related to?

the userspace interface is not in units of kernel HZ, but in
"theoretical time units that happen to match a defined
default" which happens to match 10ms on x86.