[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20060804.005352.128616651.anemo@mba.ocn.ne.jp>
Date: Fri, 04 Aug 2006 00:53:52 +0900 (JST)
From: Atsushi Nemoto <anemo@....ocn.ne.jp>
To: schwidefsky@...glemail.com
Cc: johnstul@...ibm.com, akpm@...l.org, zippel@...ux-m68k.org,
clameter@...r.sgi.com, linux-kernel@...r.kernel.org,
ralf@...ux-mips.org, ak@....de
Subject: Re: [PATCH] simplify update_times (avoid jiffies/jiffies_64
aliasing problem)
On Wed, 2 Aug 2006 14:50:32 +0200, "Martin Schwidefsky" <schwidefsky@...glemail.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@....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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists