public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Finn Arne Gangstad <Finn.Gangstad@fast.no>
To: Tim Schmielau <tim@physik3.uni-rostock.de>
Cc: Andrew Morton <akpm@digeo.com>, Vitezslav Samel <samel@mail.cz>,
	Matthew Wilcox <willy@debian.org>, Eric Piel <Eric.Piel@Bull.Net>,
	davidm@hpl.hp.com, linux-ia64@linuxia64.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix nanosleep() granularity bumps
Date: Mon, 24 Mar 2003 13:06:04 +0100	[thread overview]
Message-ID: <20030324120604.GA3004@fast.no> (raw)
In-Reply-To: <Pine.LNX.4.33.0303180954330.27487-100000@gans.physik3.uni-rostock.de>

On Tue, Mar 18, 2003 at 10:05:56AM +0100, Tim Schmielau wrote:
> On Mon, 17 Mar 2003, Tim Schmielau wrote:
> 
> > I've re-checked that the problem does not occur with the original "initial
> > jiffies" patch for 2.4.
> 
> Stupid me - 2.4 with the patch has the same problem, it just takes 10x as
> long to show up, a range that was not covered by the testcase.
> 
> 
> The actual problem is that I didn't fully understand the, well,
> 'elaborated' way of counting jiffies in the timer cascade:
> 
> When starting out with timer_jiffies=0, the timer cascade is
> (unneccessarily) triggered on the first timer interrupt, incrementing all
> the higher indices.
> When starting with any other initial jiffies value, we miss that and end
> up with all higher indices being off by one.

Suggest the attached patch as a fix instead - easier to understand I
think and works for every possible start value. This is what I made for
Andrea Arcangeli many years ago...

diff -ur linux-2.5.65/kernel/timer.c linux-2.5.65-new/kernel/timer.c
--- linux-2.5.65/kernel/timer.c	2003-03-17 22:44:41.000000000 +0100
+++ linux-2.5.65-new/kernel/timer.c	2003-03-24 12:57:31.000000000 +0100
@@ -1182,11 +1182,14 @@
 		INIT_LIST_HEAD(base->tv1.vec + j);
 
 	base->timer_jiffies = INITIAL_JIFFIES;
-	base->tv1.index = INITIAL_JIFFIES & TVR_MASK;
-	base->tv2.index = (INITIAL_JIFFIES >> TVR_BITS) & TVN_MASK;
-	base->tv3.index = (INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) & TVN_MASK;
-	base->tv4.index = (INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) & TVN_MASK;
-	base->tv5.index = (INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) & TVN_MASK;
+	base->tv1.index = (1 + (INITIAL_JIFFIES - 1)) & TVR_MASK;
+	base->tv2.index = (1 + ((INITIAL_JIFFIES - 1) >> TVR_BITS)) & TVN_MASK;
+	base->tv3.index = (1 + ((INITIAL_JIFFIES - 1)
+				>> (TVR_BITS + TVN_BITS))) & TVN_MASK;
+	base->tv4.index = (1 + ((INITIAL_JIFFIES - 1)
+				>> (TVR_BITS + 2 * TVN_BITS))) & TVN_MASK;
+	base->tv5.index = (1 + ((INITIAL_JIFFIES - 1)
+				>> (TVR_BITS + 3 * TVN_BITS))) & TVN_MASK;
 }
 	
 static int __devinit timer_cpu_notify(struct notifier_block *self, 


- Finn Arne

  reply	other threads:[~2003-03-24 11:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3E70B797.DFC260B@Bull.Net>
     [not found] ` <15984.58358.499539.299000@napali.hpl.hp.com>
2003-03-14 14:34   ` [BUG] nanosleep() granularity bumps up in 2.5.64 (was: [PATCH] settimeofday() not synchronised with gettimeofday()) Eric Piel
2003-03-14 14:48     ` [Linux-ia64] " Matthew Wilcox
2003-03-17  7:45       ` Vitezslav Samel
2003-03-17 13:55         ` [BUG] nanosleep() granularity bumps up in 2.5.64 Tim Schmielau
2003-03-17 19:42           ` [BUG & WORKAROUND] " Tim Schmielau
2003-03-18  9:05             ` [PATCH] fix nanosleep() granularity bumps Tim Schmielau
2003-03-24 12:06               ` Finn Arne Gangstad [this message]
2003-03-24 12:10                 ` Tim Schmielau
2003-03-14 19:29     ` [Linux-ia64] Re: [BUG] nanosleep() granularity bumps up in 2.5.64 (was: [PATCH] settimeofday() not synchronised with gettimeofday()) David Mosberger
     [not found] <Pine.LNX.4.33.0303181251130.28123-100000@gans.physik3.uni-rostock.de>
2003-03-18 20:26 ` [PATCH] fix nanosleep() granularity bumps Tim Schmielau
2003-03-19  2:08   ` george anzinger
2003-03-19  4:31     ` Andrew Morton
2003-03-19  2:37       ` george anzinger
2003-03-19  2:59         ` Andrew Morton
2003-03-19  7:51       ` Tim Schmielau
2003-03-19  8:35         ` george anzinger
2003-03-19  9:28         ` george anzinger
2003-03-19  9:40           ` Tim Schmielau
2003-03-19 21:30             ` george anzinger
2003-03-20  7:36               ` Tim Schmielau
2003-03-19  9:42           ` Andrew Morton
2003-03-19 18:08             ` george anzinger
2003-03-19 18:51               ` Andrew Morton
2003-03-19 20:29                 ` george anzinger

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=20030324120604.GA3004@fast.no \
    --to=finn.gangstad@fast.no \
    --cc=Eric.Piel@Bull.Net \
    --cc=akpm@digeo.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-ia64@linuxia64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samel@mail.cz \
    --cc=tim@physik3.uni-rostock.de \
    --cc=willy@debian.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox