mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: schwidefsky@googlemail.com
Cc: johnstul@us.ibm.com, akpm@osdl.org, zippel@linux-m68k.org,
	clameter@engr.sgi.com, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, ak@muc.de
Subject: Re: [PATCH] simplify update_times (avoid jiffies/jiffies_64 aliasing problem)
Date: Fri, 04 Aug 2006 00:53:52 +0900 (JST)	[thread overview]
Message-ID: <20060804.005352.128616651.anemo@mba.ocn.ne.jp> (raw)
In-Reply-To: <6e0cfd1d0608020550k7ae2c44dg94afbe56d66b@mail.gmail.com>

On Wed, 2 Aug 2006 14:50:32 +0200, "Martin Schwidefsky" <schwidefsky@googlemail.com> wrote:
> If you switch of the hz timer in idle you'll get lots of lost ticks.
> And if you are
> running a virtualized system you can loose you cpu for some ticks as well.
> Pass the number of ticks to do_timer.

I see.  Then how about this?


[PATCH] cleanup do_timer and update_times

Rename do_timer() to do_timer_ticks() and pass ticks.  Now do_timer()
is just wrapper of do_timer_ticks().

This also make a barrier added by
5aee405c662ca644980c184774277fc6d0769a84 needless.

Also adjust x86_64 timer interrupt handler with this change.

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

diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 7a9b182..3dbe30e 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -421,16 +421,14 @@ #endif
 				(((long) offset << US_SCALE) / vxtime.tsc_quot) - 1;
 	}
 
-	if (lost > 0) {
+	if (lost > 0)
 		handle_lost_ticks(lost, regs);
-		jiffies += lost;
-	}
 
 /*
  * Do the timer stuff.
  */
 
-	do_timer(regs);
+	do_timer_ticks(lost + 1);
 #ifndef CONFIG_SMP
 	update_process_times(user_mode(regs));
 #endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6afa72e..5d7dfa1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1180,7 +1180,8 @@ extern void switch_uid(struct user_struc
 
 #include <asm/current.h>
 
-extern void do_timer(struct pt_regs *);
+extern void do_timer_ticks(unsigned long ticks);
+#define do_timer(regs)	do_timer_ticks(1)
 
 extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
 extern int FASTCALL(wake_up_process(struct task_struct * tsk));
diff --git a/kernel/timer.c b/kernel/timer.c
index b650f04..50ed235 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1218,7 +1218,7 @@ static inline void calc_load(unsigned lo
 	static int count = LOAD_FREQ;
 
 	count -= ticks;
-	if (count < 0) {
+	while (count < 0) {
 		count += LOAD_FREQ;
 		active_tasks = count_active_tasks();
 		CALC_LOAD(avenrun[0], EXP_1, active_tasks);
@@ -1265,11 +1265,8 @@ 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 ticks)
 {
-	unsigned long ticks;
-
-	ticks = jiffies - wall_jiffies;
 	wall_jiffies += ticks;
 	update_wall_time();
 	calc_load(ticks);
@@ -1281,12 +1278,10 @@ static inline void update_times(void)
  * jiffies is defined in the linker script...
  */
 
-void do_timer(struct pt_regs *regs)
+void do_timer_ticks(unsigned long ticks)
 {
-	jiffies_64++;
-	/* prevent loading jiffies before storing new jiffies_64 value. */
-	barrier();
-	update_times();
+	jiffies_64 += ticks;
+	update_times(ticks);
 }
 
 #ifdef __ARCH_WANT_SYS_ALARM

  reply	other threads:[~2006-08-03 15:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 14:02 Atsushi Nemoto
2006-03-02 15:51 ` Atsushi Nemoto
2006-03-02 19:09 ` Christoph Lameter
2006-03-03  2:44   ` Atsushi Nemoto
2006-03-03  3:04     ` Andrew Morton
2006-03-03  3:20       ` Andi Kleen
2006-03-03  4:31       ` Atsushi Nemoto
2006-03-03  5:45         ` David S. Miller
2006-03-03 16:26           ` Atsushi Nemoto
2006-03-03 16:31         ` Atsushi Nemoto
2006-03-04  8:18           ` Andrew Morton
2006-03-04 11:20             ` Andi Kleen
2006-03-04 11:40               ` Andrew Morton
2006-03-04  5:21                 ` Andi Kleen
2006-03-04 23:13                 ` Paul Mackerras
2006-03-06  2:32                   ` Atsushi Nemoto
2006-03-04 11:42               ` Paul Mackerras
2006-03-04 11:44                 ` Andrew Morton
2006-03-04 12:33                   ` Paul Mackerras
2006-03-04 16:43                     ` Atsushi Nemoto
2006-03-03 20:17       ` john stultz
2006-03-03 21:15         ` Andrew Morton
2006-03-04 17:15         ` Atsushi Nemoto
2006-07-30 14:54           ` Atsushi Nemoto
2006-07-31 10:36             ` Martin Schwidefsky
2006-08-01 14:44               ` Atsushi Nemoto
2006-08-02 12:50                 ` Martin Schwidefsky
2006-08-03 15:53                   ` Atsushi Nemoto [this message]
2006-08-04 14:02                     ` Martin Schwidefsky
2006-08-06 16:13                       ` Atsushi Nemoto
2006-08-07 11:28                         ` Martin Schwidefsky
2006-08-07 19:58                         ` Andrew Morton
2006-08-08  8:11                           ` Martin Schwidefsky
2006-08-09 15:07                           ` Atsushi Nemoto
2006-03-03 18:13     ` john stultz
2006-03-04  2:34       ` Ralf Baechle

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=20060804.005352.128616651.anemo@mba.ocn.ne.jp \
    --to=anemo@mba.ocn.ne.jp \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=clameter@engr.sgi.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=schwidefsky@googlemail.com \
    --cc=zippel@linux-m68k.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

all inboxes | Powered by JetHome®