linux-mips
[Top] [All Lists]

Re: jiffies_64 vs. jiffies

To: linux-kernel@vger.kernel.org
Subject: Re: jiffies_64 vs. jiffies
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Wed, 01 Mar 2006 21:05:41 +0900 (JST)
Cc: linux-mips@linux-mips.org
In-reply-to: <20060301.144442.118975101.nemoto@toshiba-tops.co.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20060301.144442.118975101.nemoto@toshiba-tops.co.jp>
Sender: linux-mips-bounce@linux-mips.org
>>>>> On Wed, 01 Mar 2006 14:44:42 +0900 (JST), Atsushi Nemoto 
>>>>> <anemo@mba.ocn.ne.jp> said:
anemo> Hi.  I noticed that the 'jiffies' variable has 'wall_jiffies +
anemo> 1' value in most of time.  I'm using MIPS platform but I think
anemo> this is same for other platforms.

anemo> I suppose this is due to gcc does not know that jiffies_64 and
anemo> jiffies share same place.
...
anemo> Is this really expected code?  If no, how it can be fixed?
anemo> Insert "barrier()" right after "jiffies_64++" ?

I suppose passing updated jiffies to update_times() would be more
efficient than barrier().  Here is a patch.


Pass updated jiffies to update_times() to avoid jiffies/jiffies_64
aliasing.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/kernel/timer.c b/kernel/timer.c
index fe3a9a9..7734788 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -904,11 +904,11 @@ void run_local_timers(void)
  * Called by the timer interrupt. xtime_lock must already be taken
  * by the timer IRQ!
  */
-static inline void update_times(void)
+static inline void update_times(unsigned long jif)
 {
        unsigned long ticks;
 
-       ticks = jiffies - wall_jiffies;
+       ticks = jif - wall_jiffies;
        if (ticks) {
                wall_jiffies += ticks;
                update_wall_time(ticks);
@@ -924,8 +924,7 @@ static inline void update_times(void)
 
 void do_timer(struct pt_regs *regs)
 {
-       jiffies_64++;
-       update_times();
+       update_times(++jiffies_64);
        softlockup_tick(regs);
 }
 
---
Atsushi Nemoto

<Prev in Thread] Current Thread [Next in Thread>