mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Tim Schmielau <tim@physik3.uni-rostock.de>
Cc: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>,
	Matti Aarnio <matti.aarnio@zmailer.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH *] use 64 bit jiffies
Date: Mon, 17 Feb 2003 14:55:05 +0100	[thread overview]
Message-ID: <20030217135505.GF6282@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <Pine.LNX.4.33.0302041401010.1267-100000@gans.physik3.uni-rostock.de>

On Tue, 4 February 2003 14:04:38 +0100, Tim Schmielau wrote:
> 
> A patch for 2.4.20-pre7 (and maybe later) is at
>   http://www.physik3.uni-rostock.de/tim/kernel/2.4/

Some of the architectures appear to be untested. This fixes arm and
beautifies m68k.
( At least, I hope so. I didn't test it either :)

Tim, is the inline patch fine with you?

Jörn

-- 
There's nothing better for promoting creativity in a medium than
making an audience feel "Hmm ­ I could do better than that!"
-- Douglas Adams in a slashdot interview

--- linux-2.4.20-pre7-j64/include/linux/timex.h	Thu Nov 22 20:46:18 2001
+++ linux-2.4.20-pre7-j64-dbg/include/linux/timex.h	Wed Sep 25 19:11:51 2002
@@ -53,6 +53,13 @@
 
 #include <asm/param.h>
 
+#ifdef CONFIG_DEBUG_JIFFIESWRAP
+  /* Make the jiffies counter wrap around sooner. */
+# define INITIAL_JIFFIES ((unsigned long)(-300*HZ))
+#else
+# define INITIAL_JIFFIES 0
+#endif
+
 /*
  * The following defines establish the engineering parameters of the PLL
  * model. The HZ variable establishes the timer interrupt frequency, 100 Hz

--- linux-2.4.20-pre7-j64/kernel/timer.c	Wed Sep 25 18:38:36 2002
+++ linux-2.4.20-pre7-j64-dbg/kernel/timer.c	Wed Sep 25 19:11:51 2002
@@ -65,9 +65,10 @@
 
 extern int do_setitimer(int, struct itimerval *, struct itimerval *);
 
-unsigned long volatile jiffies;
+unsigned long volatile jiffies = INITIAL_JIFFIES;
 #ifdef NEEDS_JIFFIES_64
-static unsigned int volatile jiffies_msb_flips;
+static unsigned int volatile
+	jiffies_msb_flips = INITIAL_JIFFIES>>(BITS_PER_LONG-1);
 #endif
 
 unsigned int * prof_buffer;
@@ -123,10 +124,21 @@
 	for (i = 0; i < TVR_SIZE; i++)
 		INIT_LIST_HEAD(tv1.vec + i);
 
+#ifdef CONFIG_DEBUG_JIFFIESWRAP
+	tv1.index = INITIAL_JIFFIES & TVR_MASK;
+	tv2.index = (INITIAL_JIFFIES >> TVR_BITS) & TVN_MASK;
+	tv3.index = (INITIAL_JIFFIES >> (TVR_BITS + TVN_BITS)) & TVN_MASK;
+	tv4.index = (INITIAL_JIFFIES >> (TVR_BITS + 2*TVN_BITS)) & TVN_MASK;
+	tv5.index = (INITIAL_JIFFIES >> (TVR_BITS + 3*TVN_BITS)) & TVN_MASK;
+
+	printk(KERN_NOTICE "Set up jiffies counter to wrap in %ld seconds.\n",
+	       (-(long)jiffies)/HZ);
+#endif
+
 	init_jiffieswrap_timer();
 }
 
-static unsigned long timer_jiffies;
+static unsigned long timer_jiffies = INITIAL_JIFFIES;
 
 static inline void internal_add_timer(struct timer_list *timer)
 {
@@ -668,7 +680,7 @@
 }
 
 /* jiffies at the most recent update of wall time */
-unsigned long wall_jiffies;
+unsigned long wall_jiffies = INITIAL_JIFFIES;
 
 /*
  * This spinlock protect us from races in SMP while playing with xtime. -arca

--- linux-2.4.20-pre7-j64/fs/proc/array.c	Wed Sep 25 18:38:36 2002
+++ linux-2.4.20-pre7-j64-dbg/fs/proc/array.c	Wed Sep 25 19:11:51 2002
@@ -369,7 +369,7 @@
 		nice,
 		0UL /* removed */,
 		task->it_real_value,
-		(unsigned long long)(task->start_time),
+		(unsigned long long)(task->start_time) - INITIAL_JIFFIES,
 		vsize,
 		mm ? mm->rss : 0, /* you might want to shift this left 3 */
 		task->rlim[RLIMIT_RSS].rlim_cur,

--- linux-2.4.20-pre7-j64/fs/proc/proc_misc.c	Wed Sep 25 18:53:38 2002
+++ linux-2.4.20-pre7-j64-dbg/fs/proc/proc_misc.c	Wed Sep 25 19:11:51 2002
@@ -208,7 +208,7 @@
 	unsigned long uptime_remainder, idle_remainder;
 	int len;
 
-	uptime = get_jiffies_64();
+	uptime = get_jiffies_64() - INITIAL_JIFFIES;
 	uptime_remainder = (unsigned long) do_div(uptime, HZ);
 	idle = get_sidle_64() + get_uidle_64();
 	idle_remainder = (unsigned long) do_div(idle, HZ);
@@ -386,7 +386,8 @@
 	int i, len = 0;
 	extern unsigned long total_forks;
 	unsigned int sum = 0;
-	u64 jif = get_jiffies_64(), user = 0, nice = 0, system = 0;
+	u64 jif = get_jiffies_64() - INITIAL_JIFFIES;
+	u64 user = 0, nice = 0, system = 0;
 	int major, disk;
 
 	for (i = 0 ; i < smp_num_cpus; i++) {

--- linux-2.4.20-pre7-j64/kernel/info.c	Wed Sep 25 18:38:36 2002
+++ linux-2.4.20-pre7-j64-dbg/kernel/info.c	Wed Sep 25 19:11:51 2002
@@ -22,7 +22,7 @@
 	memset((char *)&val, 0, sizeof(struct sysinfo));
 
 	cli();
-	uptime = get_jiffies_64();
+	uptime = get_jiffies_64() - INITIAL_JIFFIES;
 	do_div(uptime, HZ);
 	val.uptime = (unsigned long) uptime;
 

--- linux-2.4.20-pre7-j64/Documentation/Configure.help	Wed Sep 25 18:33:43 2002
+++ linux-2.4.20-pre7-j64-dbg/Documentation/Configure.help	Wed Sep 25 19:11:51 2002
@@ -25244,6 +25244,14 @@
   of the BUG call as well as the EIP and oops trace.  This aids
   debugging but costs about 70-100K of memory.
 
+Debug jiffies counter wraparound (DANGEROUS)
+CONFIG_DEBUG_JIFFIESWRAP
+  Say Y here to initialize the jiffies counter to a value 5 minutes
+  before wraparound. This may make your system UNSTABLE and its
+  only use is to hunt down the causes of this instability.
+  If you don't know what the jiffies counter is or if you want
+  a stable system, say N.
+                                                                            
 Include kgdb kernel debugger
 CONFIG_KGDB
   Include in-kernel hooks for kgdb, the Linux kernel source level

--- linux-2.4.20-pre7-j64/arch/arm/config.in	Wed Sep 25 18:33:43 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/arm/config.in	Wed Sep 25 19:11:51 2002
@@ -649,6 +649,7 @@
 dep_bool '  Morse code panics' CONFIG_PANIC_MORSE $CONFIG_DEBUG_KERNEL $CONFIG_PC_KEYB
 dep_bool '  Spinlock debugging' CONFIG_DEBUG_SPINLOCK $CONFIG_DEBUG_KERNEL
 dep_bool '  Wait queue debugging' CONFIG_DEBUG_WAITQ $CONFIG_DEBUG_KERNEL
+dep_bool '  Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP $CONFIG_DEBUG_KERNEL
 dep_bool '  Verbose BUG() reporting (adds 70K)' CONFIG_DEBUG_BUGVERBOSE $CONFIG_DEBUG_KERNEL
 dep_bool '  Verbose kernel error messages' CONFIG_DEBUG_ERRORS $CONFIG_DEBUG_KERNEL
 # These options are only for real kernel hackers who want to get their hands dirty. 
--- linux-2.4.20-pre7-j64/arch/cris/config.in	Wed Sep 25 18:33:43 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/cris/config.in	Wed Sep 25 19:11:51 2002
@@ -243,6 +243,7 @@
 if [ "$CONFIG_SOUND" != "n" ]; then
   source drivers/sound/Config.in
 fi
+bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 endmenu
 
 source drivers/usb/Config.in

--- linux-2.4.20-pre7-j64/arch/i386/config.in	Wed Sep 25 18:33:43 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/i386/config.in	Wed Sep 25 19:11:51 2002
@@ -451,6 +451,7 @@
    bool '  Magic SysRq key' CONFIG_MAGIC_SYSRQ
    bool '  Spinlock debugging' CONFIG_DEBUG_SPINLOCK
    bool '  Compile the kernel with frame pointers' CONFIG_FRAME_POINTER
+   bool '  Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 fi
 
 endmenu

--- linux-2.4.20-pre7-j64/arch/m68k/config.in	Wed Sep 25 18:33:43 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/m68k/config.in	Wed Sep 25 19:11:51 2002
@@ -552,6 +552,7 @@
 if [ "$CONFIG_DEBUG_KERNEL" != "n" ]; then
    bool '  Magic SysRq key' CONFIG_MAGIC_SYSRQ
    bool '  Debug memory allocations' CONFIG_DEBUG_SLAB
+   bool '  Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
    bool '  Verbose BUG() reporting' CONFIG_DEBUG_BUGVERBOSE
 fi
 

--- linux-2.4.20-pre7/arch/mips/config-shared.in	Wed Sep 25 19:27:11 2002
+++ linux-2.4.20-pre7-j64/arch/mips/config-shared.in	Wed Sep 25 19:15:30 2002
@@ -798,6 +798,7 @@
 if [ "$CONFIG_SMP" != "y" ]; then
    bool 'Run uncached' CONFIG_MIPS_UNCACHED
 fi
+dep_bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP $CONFIG_MIPS32 
 endmenu
 
 source lib/Config.in

--- linux-2.4.20-pre7-j64/arch/parisc/config.in	Wed Sep 25 18:33:45 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/parisc/config.in	Wed Sep 25 19:11:51 2002
@@ -194,6 +194,7 @@
 
 #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 endmenu
 
 source lib/Config.in

--- linux-2.4.20-pre7-j64/arch/ppc/config.in	Wed Sep 25 18:33:45 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/ppc/config.in	Wed Sep 25 19:17:13 2002
@@ -423,5 +423,6 @@
       string '    Additional compile arguments' CONFIG_COMPILE_OPTIONS "-g -ggdb"
     fi
   fi
+  bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 fi
 endmenu

--- linux-2.4.20-pre7-j64/arch/sh/config.in	Wed Sep 25 18:33:46 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/sh/config.in	Wed Sep 25 19:11:51 2002
@@ -385,6 +385,7 @@
 if [ "$CONFIG_SH_STANDARD_BIOS" = "y" ]; then
    bool 'Early printk support' CONFIG_SH_EARLY_PRINTK
 fi
+bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 endmenu
 
 source lib/Config.in

--- linux-2.4.20-pre7-j64/arch/sparc/config.in	Wed Sep 25 18:33:47 2002
+++ linux-2.4.20-pre7-j64-dbg/arch/sparc/config.in	Wed Sep 25 19:11:51 2002
@@ -265,6 +265,7 @@
 comment 'Kernel hacking'
 
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
+bool 'Debug jiffies counter wraparound (DANGEROUS)' CONFIG_DEBUG_JIFFIESWRAP
 endmenu
 
 source lib/Config.in

  reply	other threads:[~2003-02-17 13:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-02 22:55 Tim Schmielau
2003-02-03  6:42 ` Denis Vlasenko
2003-02-03  8:28   ` Matti Aarnio
2003-02-03  8:47     ` Tim Schmielau
2003-02-03  8:55       ` Matti Aarnio
2003-02-04 13:00         ` Tim Schmielau
2003-02-04  6:41     ` Denis Vlasenko
2003-02-04  8:27       ` Robert de Bath
2003-02-04  8:41         ` Denis Vlasenko
2003-02-04  9:29       ` Jörn Engel
2003-02-04 13:04         ` Tim Schmielau
2003-02-17 13:55           ` Jörn Engel [this message]
2003-02-17 14:02             ` Tim Schmielau
2003-02-17 14:15             ` Matti Aarnio
2003-02-17 14:23               ` Tim Schmielau
2003-02-04 17:37       ` Randy.Dunlap
2003-02-16  1:37         ` [PATCH] make jiffies wrap 5 min after boot Tim Schmielau
2003-02-16  2:08           ` Anton Blanchard
2003-02-16  2:43             ` William Lee Irwin III
2003-02-16  2:50               ` Michael Vergoz
2003-02-16  6:37               ` Robert Love
2003-02-16  7:16                 ` Muli Ben-Yehuda
2003-02-16 11:50                   ` Falk Hueffner
2003-02-16 12:04                     ` William Lee Irwin III
2003-02-11 20:50       ` [patch] jiffies wrap fixes for 2.5.60 Tim Schmielau
2003-02-11 21:31         ` Roger Larsson
2003-02-12 12:09           ` Tim Schmielau
2003-02-05 11:42 ` use 64 bit jiffies broke HZ=100 case (and fix) Oleg Drokin
2003-02-05 12:22   ` Tim Schmielau

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=20030217135505.GF6282@wohnheim.fh-wedel.de \
    --to=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.aarnio@zmailer.org \
    --cc=tim@physik3.uni-rostock.de \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®