All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank van Maarseveen <frankvm@xs4all.nl>
To: linux-kernel@vger.kernel.org
Subject: 2.4.23 can run with HZ==0!
Date: Mon, 29 Dec 2003 00:05:22 +0100	[thread overview]
Message-ID: <20031228230522.GA1876@janus> (raw)

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

The first thing I noticed was that a select for .2 seconds seemed to
hang in a python script I was working on that time. I didn't believe it
so I tried some other things including "sleep 1", "usleep 1", stracing
them and it all came down to one conclusion

	the clock has stopped

/proc/interrupts confirmed that the clock has stopped:

$ cat /proc/interrupts 
           CPU0       
  0:    7745428          XT-PIC  timer
  1:          2          XT-PIC  keyboard
  2:          0          XT-PIC  cascade
  8:          1          XT-PIC  rtc
  9:          0          XT-PIC  via82cxxx, usb-uhci
 11:      12106          XT-PIC  usb-uhci, usb-uhci, eth0
 12:      12079          XT-PIC  eth1
 14:       8582          XT-PIC  ide0
 15:       8623          XT-PIC  ide1
NMI:          0 
LOC:          0 
ERR:          0
MIS:          0
$ cat /proc/interrupts 
           CPU0       
  0:    7745428          XT-PIC  timer
  1:          2          XT-PIC  keyboard
  2:          0          XT-PIC  cascade
  8:          1          XT-PIC  rtc
  9:          0          XT-PIC  via82cxxx, usb-uhci
 11:      12116          XT-PIC  usb-uhci, usb-uhci, eth0
 12:      12079          XT-PIC  eth1
 14:       8582          XT-PIC  ide0
 15:       8623          XT-PIC  ide1

notice that network irqs are taking place for eth0 but no timer irqs.

halt, reboot (-f) etc didn't work because they all wanted to sleep. I
had to power cycle. Now HZ is ok (1000) again.  HZ has been patched but
that's an unlikely cause (patch attached in case you wonder).

Hardware: VIA CL6000

At the time this happened I was also playing with /dev/ttyS3 lines on
the mobo (static discharge?)

-- 
Frank

[-- Attachment #2: hz.patch --]
[-- Type: text/plain, Size: 3616 bytes --]

--- linux/include/asm-i386/param.h.hz	Mon Aug 18 12:15:42 2003
+++ linux/include/asm-i386/param.h	Mon Aug 18 12:26:26 2003
@@ -2,8 +2,9 @@
 #define _ASMi386_PARAM_H
 
 #ifndef HZ
-#define HZ 100
+#define HZ 1000
 #endif
+#define jiffies_to_clock_t(x) ((x) / (HZ / 100))
 
 #define EXEC_PAGESIZE	4096
 
--- linux/kernel/sys.c.hz	Mon Aug 18 12:15:36 2003
+++ linux/kernel/sys.c	Mon Aug 18 12:26:20 2003
@@ -807,10 +807,16 @@
 	 *	atomically safe type this is just fine. Conceptually its
 	 *	as if the syscall took an instant longer to occur.
 	 */
-	if (tbuf)
-		if (copy_to_user(tbuf, &current->times, sizeof(struct tms)))
+	if (tbuf) {
+		struct tms tmp;
+		tmp.tms_utime = jiffies_to_clock_t(current->times.tms_utime);
+		tmp.tms_stime = jiffies_to_clock_t(current->times.tms_stime);
+		tmp.tms_cutime = jiffies_to_clock_t(current->times.tms_cutime);
+		tmp.tms_cstime = jiffies_to_clock_t(current->times.tms_cstime);
+		if (copy_to_user(tbuf, &tmp, sizeof(struct tms)))
 			return -EFAULT;
-	return jiffies;
+	}
+	return jiffies_to_clock_t(jiffies);
 }
 
 /*
--- linux/kernel/timer.c.hz	Wed Dec  4 11:01:40 2002
+++ linux/kernel/timer.c	Mon Aug 18 12:15:42 2003
@@ -472,6 +472,15 @@
     else
 	time_adj += (time_adj >> 2) + (time_adj >> 5);
 #endif
+#if HZ == 1000
+    /* Compensate for (HZ==1000) != (1 << SHIFT_HZ).
+     * Add 1.5625% and 0.78125% to get 1023.4375; => only 0.05% error (p. 14)
+     */
+    if (time_adj < 0)
+	time_adj -= (-time_adj >> 6) + (-time_adj >> 7);
+    else
+	time_adj += (time_adj >> 6) + (time_adj >> 7);
+#endif
 }
 
 /* in the NTP reference this is called "hardclock()" */
--- linux/fs/proc/array.c.hz	2003-11-30 21:52:24.000000000 +0100
+++ linux/fs/proc/array.c	2003-11-30 21:52:26.000000000 +0100
@@ -362,15 +362,15 @@
 		task->cmin_flt,
 		task->maj_flt,
 		task->cmaj_flt,
-		task->times.tms_utime,
-		task->times.tms_stime,
-		task->times.tms_cutime,
-		task->times.tms_cstime,
+		jiffies_to_clock_t(task->times.tms_utime),
+		jiffies_to_clock_t(task->times.tms_stime),
+		jiffies_to_clock_t(task->times.tms_cutime),
+		jiffies_to_clock_t(task->times.tms_cstime),
 		priority,
 		nice,
 		0UL /* removed */,
 		task->it_real_value,
-		task->start_time,
+		jiffies_to_clock_t(task->start_time),
 		vsize,
 		mm ? mm->rss : 0, /* you might want to shift this left 3 */
 		task->rlim[RLIMIT_RSS].rlim_cur,
--- linux/fs/proc/proc_misc.c.hz	Mon Aug 18 12:15:26 2003
+++ linux/fs/proc/proc_misc.c	Mon Aug 18 13:35:59 2003
@@ -325,18 +325,21 @@
 	}
 
 	proc_sprintf(page, &off, &len,
-		      "cpu  %u %u %u %lu\n", user, nice, system,
-		      jif * smp_num_cpus - (user + nice + system));
+		      "cpu  %u %u %u %lu\n",
+			jiffies_to_clock_t(user),
+			jiffies_to_clock_t(nice),
+			jiffies_to_clock_t(system),
+			jiffies_to_clock_t(jif * smp_num_cpus - (user + nice + system)));
 	for (i = 0 ; i < smp_num_cpus; i++)
 		proc_sprintf(page, &off, &len,
 			"cpu%d %u %u %u %lu\n",
 			i,
-			kstat.per_cpu_user[cpu_logical_map(i)],
-			kstat.per_cpu_nice[cpu_logical_map(i)],
-			kstat.per_cpu_system[cpu_logical_map(i)],
-			jif - (  kstat.per_cpu_user[cpu_logical_map(i)] \
+			jiffies_to_clock_t(kstat.per_cpu_user[cpu_logical_map(i)]),
+			jiffies_to_clock_t(kstat.per_cpu_nice[cpu_logical_map(i)]),
+			jiffies_to_clock_t(kstat.per_cpu_system[cpu_logical_map(i)]),
+			jiffies_to_clock_t(jif - (  kstat.per_cpu_user[cpu_logical_map(i)] \
 				   + kstat.per_cpu_nice[cpu_logical_map(i)] \
-				   + kstat.per_cpu_system[cpu_logical_map(i)]));
+				   + kstat.per_cpu_system[cpu_logical_map(i)])));
 	proc_sprintf(page, &off, &len,
 		"page %u %u\n"
 		"swap %u %u\n"

             reply	other threads:[~2003-12-28 23:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-28 23:05 Frank van Maarseveen [this message]
2003-12-29  9:45 ` 2.4.23 can run with HZ==0! Arjan van de Ven
2003-12-29 12:52   ` Frank van Maarseveen
2003-12-29 12:52     ` Arjan van de Ven
2003-12-29 15:26     ` Rob Love
2003-12-29 15:54       ` Frank van Maarseveen
2003-12-29 15:54         ` Arjan van de Ven
2003-12-29 16:05         ` Rob Love

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=20031228230522.GA1876@janus \
    --to=frankvm@xs4all.nl \
    --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.