Skip to contentSkip to conversation

patch: sysctl.h (allocating new number)

PATCH Ulrich Windl 3 participants 3 messages Jan 25, 2002 – Jan 27, 2002

lore
Share & tools
lore
#0 lore raw

Hello,

I have attached a patch (1kB) against sysctl.h of 2.4.16. The patch allocates a new number for a directory /proc/sys/kernel/time.

I use that sysctl in the kernel add-on named PPSkit for some time now (since 2.2.13). However as the number was never officially allocated, I had to change it from 42 to 50, and from 50 to 55 for 2.4.16.

Therefore I'd like to allocate the number permanently.

So is there any benefit? Yes, because there's a problem with adjtimex(). Historically it was a bad design descision to use one adjtimex() to implement three different routines:

1) adjtime()
2) ntp_adjtime(), ntp_gettime()
3) controlling internal kernel variables like ``tick''

Actually the current implementation is a cul de sac: The current reference implementation for the NTP routines uses the same bit patterns as some Linux-specific extensions to adjtimex(). Partially it's possible to remap the bits in the kernel to do a new implementation, but sysctl is the better way to do it.

I have implemented sysctl extensions to read/write the ``tick'' and slew rate of adjtime() (among others) for my new kernel clock model using nanoseconds (PPSkit-2.0.1). If there's demand to a back-merge to the main stream sources, plese say what you would like. As the project was sponsored a little bit recently, I'm willing to donate a few working hours for that.

The sysctl part looks like this (older kernel):
tick1b:/proc/sys/kernel/time # ll
total 0

dr-xr-xr-x   2 root     root            0 Jan 25 08:10 .
dr-xr-xr-x   3 root     root            0 Jan 25 08:10 ..
-r--r--r--   1 root     root            0 Jan 25 08:10 pps
-rw-r--r--   1 root     root            0 Jan 25 08:10 
rtc_runs_localtime
-rw-r--r--   1 root     root            0 Jan 25 08:10 rtc_update
-rw-r--r--   1 root     root            0 Jan 25 08:10 tickadj
-rw-r--r--   1 root     root            0 Jan 25 08:10 time_tick
-rw-r--r--   1 root     root            0 Jan 25 08:10 timezone

Except for the first entry (experimental for debugging) the contents are:
0 (rtc_runs_localtime)
660 (rtc_update)
500000 (tickadj [ns])
10000000 (time_tick [ns])
-60 0 (timezone)

IMHO it's time to make a turn in the cul de sac before the truck hits the end of the road.

Regards
Ulrich
NOTE: Not subscribed to linux-kernel, so make sure that I'll get your replies...

Index: include/linux/sysctl.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/linux/sysctl.h,v retrieving revision 1.1.1.6
retrieving revision 1.1.1.6.2.1

linux/sysctl.h +11 -0
diff -u -r1.1.1.6 -r1.1.1.6.2.1
@@ -124,8 +124,19 @@
 	KERN_CORE_USES_PID=52,		/* int: use core or core.%pid */
 	KERN_TAINTED=53,	/* int: various kernel tainted flags */
 	KERN_CADPID=54,		/* int: PID of the process to notify on CAD */
+	KERN_TIME=55,		/* directory: time */
 };
 
+/* KERN_TIME names: */
+enum
+{
+	KERN_TIME_TIMEZONE=1,		/* struct: timezone */
+	KERN_TIME_RTC_UPDATE=2,		/* int: rtc_update */
+	KERN_TIME_RTC_RUNS_LOCALTIME=3,	/* int: rtc_runs_localtime */
+	KERN_TIME_TIME_TICK=4,		/* int: time_tick */
+	KERN_TIME_TICKADJ=5,		/* int: tickadj */
+	KERN_TIME_PPS_VAR=99,		/* struct pps_var: pps */
+};
 
 /* CTL_VM names: */
 enum
#1 lore raw
Followup to:  <3C51146F.6774.15F75C@localhost>
By author:    "Ulrich Windl" <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 8 lines

I have implemented sysctl extensions to read/write the ``tick'' and slew rate of adjtime() (among others) for my new kernel clock model using nanoseconds (PPSkit-2.0.1). If there's demand to a back-merge to the main stream sources, plese say what you would like. As the project was sponsored a little bit recently, I'm willing to donate a few working hours for that.

I, for one, would definitely see the clock model merged into the mainstream kernel.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<[email protected]>
#2 lore raw
In reply to Ulrich Windl
Quoted 4 lines · H. Peter Anvin
Followup to:  <3C51146F.6774.15F75C@localhost>
By author:    "Ulrich Windl" <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 8 lines
Quoted 2 lines

I have implemented sysctl extensions to read/write the ``tick'' and slew rate of adjtime() (among others) for my new kernel clock model using nanoseconds (PPSkit-2.0.1). If there's demand to a back-merge to the main stream sources, plese say what you would like. As the project was sponsored a little bit recently, I'm willing to donate a few working hours for that.

I, for one, would definitely see the clock model merged into the mainstream kernel.

-hpa

Amen to this!

I, for two, would definitely like to see it there as well!