From: "Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de>
To: linux-kernel@vger.kernel.org
Subject: almost a patch for 2.4.19: /proc/sys/kernel/time
Date: Fri, 18 Oct 2002 08:49:00 +0200 [thread overview]
Message-ID: <3DAFCAFA.14078.1E75B2@localhost> (raw)
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1185 bytes --]
Hello,
I have a patch known as "PPSkit" that converts the kernel to use an
internal time base of nanoseconds for wall time...
Some time ago (1999) I implemented a new sysctl directory
/proc/sys/kernel/time that allows fixing some of the oddities having to
do with time (e.g. setting the timezone, preventing the kernel from
doing RTC updates, forcing the kernel to do RTC updates when the clock
is set, etc.)
With the recent discussion about "HZ", I decided to implement
/proc/sys/kernel/time/Hz as read-only variable.
I'll attach a part of the patch against 2.4.19 that was ripped out of
"PPSpatch-2.4.19.gz" (that I uploaded today to the kernel master
directory ...kernel.org:/pub/linux/daemons/ntp/PPS). The file is time-
sysctl.diff (6kB).
The patch against kernel/time.c will not work, but that's only lines to
add. Leave out all variables that you don't know, and you should still
get a working subset.
The documentation refers to the "PPSkit" version, so ignore any
"nanosecond", or read it as "microsecond". I'd like to hear some
comments about the idea.
Please mail directly to me too as I'm nut subscribed to linux-kernel.
Thanks & regards,
Ulrich Windl
[-- Attachment #2: time-sysctl.diff --]
[-- Type: Application/Octet-stream, Size: 6163 bytes --]
Index: include/linux/sysctl.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/linux/sysctl.h,v
retrieving revision 1.1.1.7
retrieving revision 1.1.1.7.2.2
diff -u -r1.1.1.7 -r1.1.1.7.2.2
--- include/linux/sysctl.h 18 Aug 2002 20:12:08 -0000 1.1.1.7
+++ include/linux/sysctl.h 17 Oct 2002 20:02:05 -0000 1.1.1.7.2.2
@@ -124,8 +124,20 @@
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_HZ=6, /* int: HZ */
+ KERN_TIME_PPS_VAR=99, /* struct pps_var: pps */
+};
/* CTL_VM names: */
enum
# the following patch was edited!
Index: kernel/time.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/kernel/time.c,v
retrieving revision 1.1.1.4
retrieving revision 1.1.1.4.2.3
diff -u -r1.1.1.4 -r1.1.1.4.2.3
--- kernel/time.c 18 Aug 2002 20:12:14 -0000 1.1.1.4
+++ kernel/time.c 17 Oct 2002 20:06:20 -0000 1.1.1.4.2.3
@@ -7,28 +7,185 @@
+/* Define entries for `time' subdirectory. */
+static /* const */ int sysctl_tz_min = -12 * 60;
+static /* const */ int sysctl_tz_max = 12 * 60;
+static /* const */ int sysctl_zero = 0;
+static /* const */ int sysctl_one = 1;
+static /* const */ int sysctl_no_max = 1 << 30;
+static /* const */ int sysctl_tick_min = 9 * (NANOSECOND/10/hz);
+static /* const */ int sysctl_tick_max = 11 * (NANOSECOND/10/hz);
+static /* const */ int sysctl_tickadj_max = (NANOSECOND/hz) / 4;
+static /* const */ int sysctl_hz = HZ;
+
+ctl_table kern_time_table[] = {
+ /* Warning: ``sys_tz.tz_dsttime'' isn't checked properly */
+ {KERN_TIME_TIMEZONE, "timezone", &sys_tz, sizeof(sys_tz),
+ 0644, NULL, &proc_dointvec_minmax, NULL, NULL,
+ &sysctl_tz_min, &sysctl_tz_max},
+ {KERN_TIME_RTC_RUNS_LOCALTIME, "rtc_runs_localtime",
+ &rtc_runs_localtime, sizeof(rtc_runs_localtime),
+ 0644, NULL, &proc_dointvec_minmax, NULL, NULL,
+ &sysctl_zero, &sysctl_one},
+ {KERN_TIME_RTC_UPDATE, "rtc_update", &rtc_update, sizeof(rtc_update),
+ 0644, NULL, &proc_dointvec_minmax, NULL, NULL,
+ &sysctl_zero, &sysctl_no_max},
+ {KERN_TIME_TIME_TICK, "time_tick", &time_tick, sizeof(time_tick),
+ 0644, NULL, &proc_dointvec_minmax, NULL, NULL,
+ &sysctl_tick_min, &sysctl_tick_max},
+ {KERN_TIME_TICKADJ, "tickadj", &tickadj, sizeof(tickadj),
+ 0644, NULL, &proc_dointvec_minmax, NULL, NULL,
+ &sysctl_one, &sysctl_tickadj_max},
+ {KERN_TIME_HZ, "Hz", &sysctl_hz, sizeof(sysctl_hz),
+ 0444, NULL, &proc_dointvec},
+#ifdef CONFIG_NTP
+#ifdef CONFIG_NTP_PPS
+ /* this entry is for debugging (experimental) */
+ {KERN_TIME_PPS_VAR, "pps", &pps, sizeof(pps),
+ 0444, NULL, &proc_dointvec},
+#endif
+#endif
+ {0}
+};
+
Index: Documentation/sysctl/kernel.txt
===================================================================
RCS file: /root/LinuxCVS/Kernel/Documentation/sysctl/kernel.txt,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.6.2
diff -u -r1.1.1.2 -r1.1.1.2.6.2
--- Documentation/sysctl/kernel.txt 13 Dec 2001 18:48:49 -0000 1.1.1.2
+++ Documentation/sysctl/kernel.txt 17 Oct 2002 20:14:21 -0000 1.1.1.2.6.2
@@ -40,6 +40,7 @@
- sg-big-buff [ generic SCSI device (sg) ]
- shmmax [ sysv ipc ]
- tainted
+- time [ directory ]
- version
- zero-paged [ PPC only ]
@@ -218,6 +219,37 @@
on the maximum shared memory segment size that can be created.
Shared memory segments up to 1Gb are now supported in the
kernel. This value defaults to SHMMAX.
+
+==============================================================
+
+time:
+
+time/Hz (r/o):
+ Intended to reveal the value of HZ to user programs.
+
+time/pps (r/o):
+ (experimental) Used to reveal the internals of ``struct pps''
+
+time/rtc_runs_localtime (r/w):
+ Set to ``1'' if RTC is set to local time
+
+time/rtc_update (r/w):
+ Amount of seconds after which the RTC is updated from system time
+ if ``STA_UNSYNC'' in ``time_status'' is cleared. When setting the
+ system time directly, it will be updated the next second.
+ Setting ``rtc_update'' to a value <= 0, the RTC is not updated.
+
+time/tickadj (r/w):
+ Amount of nanoseconds that will be used to adjust a wrong clock
+ gradually (using ``adjtime()'').
+
+time/time_tick (r/w):
+ Amount of nanoseconds to add every timer interrupt.
+
+time/timezone (r/w):
+ Two values describing the time zone offset west of GMT in minutes,
+ and whether daylight saving time is active (required to convert
+ kernel time to local time).
==============================================================
Index: kernel/sysctl.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/kernel/sysctl.c,v
retrieving revision 1.1.1.11
retrieving revision 1.1.1.11.2.1
diff -u -r1.1.1.11 -r1.1.1.11.2.1
--- kernel/sysctl.c 18 Aug 2002 20:12:14 -0000 1.1.1.11
+++ kernel/sysctl.c 19 Aug 2002 20:36:01 -0000 1.1.1.11.2.1
@@ -14,6 +14,7 @@
* Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
* Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
* Wendling.
+ * Added `time' subdirectory, 11/09/99, Ulrich Windl
* The list_for_each() macro wasn't appropriate for the sysctl loop.
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
*/
@@ -108,6 +109,7 @@
{ root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
static ctl_table kern_table[];
+extern ctl_table kern_time_table[];
static ctl_table vm_table[];
#ifdef CONFIG_NET
extern ctl_table net_table[];
@@ -256,6 +258,7 @@
{KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug",
&sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec},
#endif
+ {KERN_TIME, "time", NULL, 0, 0555, kern_time_table},
{0}
};
reply other threads:[~2002-10-18 6:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DAFCAFA.14078.1E75B2@localhost \
--to=ulrich.windl@rz.uni-regensburg.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.