From: Srivatsa Vaddagiri <vatsa@in.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: arjan@infradead.org, s0348365@sms.ed.ac.uk, kernel@kolivas.org,
tytso@mit.edu, cfriesen@nortel.com, rlrevell@joe-job.com,
trenn@suse.de, george@mvista.com, johnstul@us.ibm.com,
akpm@osdl.org
Subject: [PATCH 3/3] Updated dynamic tick patches - Recover walltime upon wakeup
Date: Wed, 31 Aug 2005 22:57:04 +0530 [thread overview]
Message-ID: <20050831172704.GD4974@in.ibm.com> (raw)
In-Reply-To: <20050831165843.GA4974@in.ibm.com>
On Wed, Aug 31, 2005 at 10:28:43PM +0530, Srivatsa Vaddagiri wrote:
> Following patches related to dynamic tick are posted in separate mails,
> for convenience of review. The first patch probably applies w/o dynamic
> tick consideration also.
>
> Patch 3/3 -> Use lost tick information in dyn-tick time recovery
This patch uses the lost tick information returned by mark_offset()
function in dyn-tick, to recover time.
---
arch/i386/Kconfig | 0
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/dyn-tick.c | 11 ++++++--
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/time.c | 13 ++++++----
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_cyclone.c | 4 ++-
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_hpet.c | 4 ++-
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_none.c | 3 +-
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_pit.c | 3 +-
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_pm.c | 6 +++-
linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_tsc.c | 12 ++++++---
linux-2.6.13-rc6-mm2-root/include/asm-i386/timer.h | 2 -
10 files changed, 40 insertions(+), 18 deletions(-)
diff -puN include/asm-i386/timer.h~drift_fix include/asm-i386/timer.h
--- linux-2.6.13-rc6-mm2/include/asm-i386/timer.h~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/include/asm-i386/timer.h 2005-08-31 16:36:30.000000000 +0530
@@ -19,7 +19,7 @@
*/
struct timer_opts {
char* name;
- void (*mark_offset)(void);
+ int (*mark_offset)(void);
unsigned long (*get_offset)(void);
unsigned long long (*monotonic_clock)(void);
void (*delay)(unsigned long);
diff -puN arch/i386/kernel/time.c~drift_fix arch/i386/kernel/time.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/time.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/time.c 2005-08-31 16:36:30.000000000 +0530
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(profile_pc);
* timer_interrupt() needs to keep up the real-time clock,
* as well as call the "do_timer()" routine every clocktick
*/
-static inline void do_timer_interrupt(int irq, struct pt_regs *regs)
+static inline void do_timer_interrupt(int irq, struct pt_regs *regs, int lost)
{
#ifdef CONFIG_X86_IO_APIC
if (timer_ack) {
@@ -271,7 +271,8 @@ static inline void do_timer_interrupt(in
}
#endif
- do_timer_interrupt_hook(regs);
+ if (!dyn_tick_enabled() || lost)
+ do_timer_interrupt_hook(regs);
if (MCA_bus) {
@@ -296,6 +297,8 @@ static inline void do_timer_interrupt(in
*/
irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
+ int lost;
+
/*
* Here we are in the timer irq handler. We just have irqs locally
* disabled but we don't know if the timer_bh is running on the other
@@ -305,9 +308,9 @@ irqreturn_t timer_interrupt(int irq, voi
*/
write_seqlock(&xtime_lock);
- cur_timer->mark_offset();
-
- do_timer_interrupt(irq, regs);
+ lost = cur_timer->mark_offset();
+
+ do_timer_interrupt(irq, regs, lost);
write_sequnlock(&xtime_lock);
return IRQ_HANDLED;
diff -puN arch/i386/kernel/dyn-tick.c~drift_fix arch/i386/kernel/dyn-tick.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/dyn-tick.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/dyn-tick.c 2005-08-31 16:36:30.000000000 +0530
@@ -92,7 +92,13 @@ void dyn_tick_interrupt(int irq, struct
if (all_were_sleeping) {
/* Recover jiffies */
- cur_timer->mark_offset();
+ if (irq) {
+ int lost;
+
+ lost = cur_timer->mark_offset();
+ if (lost)
+ do_timer(regs);
+ }
if (cpu_has_local_apic())
enable_pit_timer();
}
@@ -116,8 +122,7 @@ void dyn_tick_time_init(struct timer_opt
{
spin_lock_init(&dyn_tick_lock);
- if (strncmp(cur_timer->name, "tsc", 3) == 0 ||
- strncmp(cur_timer->name, "pmtmr", 3) == 0) {
+ if (strncmp(cur_timer->name, "pmtmr", 3) == 0) {
dyn_tick->state |= DYN_TICK_SUITABLE;
printk(KERN_INFO "dyn-tick: Found suitable timer: %s\n",
cur_timer->name);
diff -puN arch/i386/kernel/timers/timer_cyclone.c~drift_fix arch/i386/kernel/timers/timer_cyclone.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_cyclone.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_cyclone.c 2005-08-31 16:36:30.000000000 +0530
@@ -45,7 +45,7 @@ static seqlock_t monotonic_lock = SEQLOC
} while (high != cyclone_timer[1]);
-static void mark_offset_cyclone(void)
+static int mark_offset_cyclone(void)
{
unsigned long lost, delay;
unsigned long delta = last_cyclone_low;
@@ -101,6 +101,8 @@ static void mark_offset_cyclone(void)
*/
if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
jiffies_64++;
+
+ return 1;
}
static unsigned long get_offset_cyclone(void)
diff -puN arch/i386/kernel/timers/timer_hpet.c~drift_fix arch/i386/kernel/timers/timer_hpet.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_hpet.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_hpet.c 2005-08-31 16:36:30.000000000 +0530
@@ -96,7 +96,7 @@ static unsigned long get_offset_hpet(voi
return edx;
}
-static void mark_offset_hpet(void)
+static int mark_offset_hpet(void)
{
unsigned long long this_offset, last_offset;
unsigned long offset;
@@ -119,6 +119,8 @@ static void mark_offset_hpet(void)
this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
monotonic_base += cycles_2_ns(this_offset - last_offset);
write_sequnlock(&monotonic_lock);
+
+ return 1;
}
static void delay_hpet(unsigned long loops)
diff -puN arch/i386/kernel/timers/timer_none.c~drift_fix arch/i386/kernel/timers/timer_none.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_none.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_none.c 2005-08-31 16:36:30.000000000 +0530
@@ -1,9 +1,10 @@
#include <linux/init.h>
#include <asm/timer.h>
-static void mark_offset_none(void)
+static int mark_offset_none(void)
{
/* nothing needed */
+ return 1;
}
static unsigned long get_offset_none(void)
diff -puN arch/i386/kernel/timers/timer_pit.c~drift_fix arch/i386/kernel/timers/timer_pit.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_pit.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_pit.c 2005-08-31 16:36:30.000000000 +0530
@@ -32,9 +32,10 @@ static int __init init_pit(char* overrid
return 0;
}
-static void mark_offset_pit(void)
+static int mark_offset_pit(void)
{
/* nothing needed */
+ return 1;
}
static unsigned long long monotonic_clock_pit(void)
diff -puN arch/i386/kernel/timers/timer_pm.c~drift_fix arch/i386/kernel/timers/timer_pm.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_pm.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_pm.c 2005-08-31 16:36:30.000000000 +0530
@@ -135,7 +135,7 @@ pm_good:
setup_pit_timer();
init_cpu_khz();
- set_dyn_tick_max_skip( (0xFFFFFF / (286 * 1000000)) * 1024 * HZ );
+ set_dyn_tick_max_skip(((0xFFFFFF / 1000000) * 286 * HZ) >> 10);
return 0;
}
@@ -156,7 +156,7 @@ static inline u32 cyc2us(u32 cycles)
* this gets called during each timer interrupt
* - Called while holding the writer xtime_lock
*/
-static void mark_offset_pmtmr(void)
+static int mark_offset_pmtmr(void)
{
u32 lost, delta, deltaus, offset_now;
@@ -182,6 +182,8 @@ static void mark_offset_pmtmr(void)
/* compensate for lost ticks */
if (lost >= 2)
jiffies_64 += lost - 1;
+
+ return lost;
}
static int pmtmr_resume(void)
diff -puN arch/i386/kernel/timers/timer_tsc.c~drift_fix arch/i386/kernel/timers/timer_tsc.c
--- linux-2.6.13-rc6-mm2/arch/i386/kernel/timers/timer_tsc.c~drift_fix 2005-08-31 16:36:17.000000000 +0530
+++ linux-2.6.13-rc6-mm2-root/arch/i386/kernel/timers/timer_tsc.c 2005-08-31 16:36:30.000000000 +0530
@@ -177,7 +177,7 @@ static inline void update_monotonic_base
}
#ifdef CONFIG_HPET_TIMER
-static void mark_offset_tsc_hpet(void)
+static int mark_offset_tsc_hpet(void)
{
unsigned long long last_offset;
unsigned long offset, temp, hpet_current;
@@ -221,6 +221,8 @@ static void mark_offset_tsc_hpet(void)
delay_at_last_interrupt = hpet_current - offset;
ASM_MUL64_REG(temp, delay_at_last_interrupt,
hpet_usec_quotient, delay_at_last_interrupt);
+
+ return 1;
}
#endif
@@ -347,7 +349,7 @@ int recalibrate_cpu_khz(void)
}
EXPORT_SYMBOL(recalibrate_cpu_khz);
-static void mark_offset_tsc(void)
+static int mark_offset_tsc(void)
{
unsigned long lost,delay;
unsigned long delta = last_tsc_low;
@@ -456,8 +458,12 @@ static void mark_offset_tsc(void)
* between tsc and pit reads (as noted when
* usec delta is > 90% # of usecs/tick)
*/
- if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
+ if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ)) {
jiffies_64++;
+ lost++;
+ }
+
+ return 1;
}
static int __init init_tsc(char* override)
diff -puN arch/i386/Kconfig~drift_fix arch/i386/Kconfig
_
--
Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017
next prev parent reply other threads:[~2005-08-31 17:27 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-31 16:58 Updated dynamic tick patches Srivatsa Vaddagiri
2005-08-31 17:12 ` [PATCH 1/3] Updated dynamic tick patches - Fix lost tick calculation in timer_pm.c Srivatsa Vaddagiri
2005-08-31 22:36 ` Zachary Amsden
2005-08-31 22:47 ` john stultz
2005-09-02 15:43 ` [PATCH 1/3] dynticks - implement no idle hz for x86 Con Kolivas
2005-09-02 15:45 ` [PATCH 2/3] dyntick - Fix lost tick calculation in timer pm.c Con Kolivas
2005-09-02 15:46 ` [PATCH 3/3] dyntick - Recover walltime upon wakeup Con Kolivas
2005-09-02 17:25 ` [PATCH 2/3] dyntick - Fix lost tick calculation in timer pm.c Srivatsa Vaddagiri
2005-09-02 20:18 ` Thomas Schlichter
2005-09-02 21:21 ` john stultz
2005-09-02 16:56 ` [PATCH 1/3] dynticks - implement no idle hz for x86 Russell King
2005-09-02 17:12 ` Srivatsa Vaddagiri
2005-09-03 6:13 ` Con Kolivas
2005-09-03 7:58 ` Russell King
2005-09-03 8:01 ` Con Kolivas
2005-09-03 8:06 ` Russell King
2005-09-03 8:14 ` Con Kolivas
2005-09-04 20:10 ` Nishanth Aravamudan
2005-09-04 20:26 ` Russell King
2005-09-04 20:37 ` Nishanth Aravamudan
2005-09-04 21:17 ` Russell King
2005-09-05 3:08 ` Con Kolivas
2005-09-05 16:28 ` Nishanth Aravamudan
2005-09-05 6:58 ` Tony Lindgren
2005-09-05 16:30 ` Nishanth Aravamudan
2005-09-04 20:41 ` Nishanth Aravamudan
2005-09-05 5:32 ` Srivatsa Vaddagiri
2005-09-05 5:48 ` Nishanth Aravamudan
2005-09-05 6:32 ` Srivatsa Vaddagiri
2005-09-05 6:44 ` Nishanth Aravamudan
2005-09-06 20:51 ` Nishanth Aravamudan
2005-09-07 8:13 ` Tony Lindgren
2005-09-07 15:00 ` Nishanth Aravamudan
2005-09-07 15:53 ` Nishanth Aravamudan
2005-09-07 17:07 ` Srivatsa Vaddagiri
2005-09-07 17:23 ` Nishanth Aravamudan
2005-09-07 18:14 ` Srivatsa Vaddagiri
2005-09-07 18:22 ` Nishanth Aravamudan
2005-09-07 16:14 ` Bill Davidsen
2005-09-07 16:42 ` Nish Aravamudan
2005-09-07 17:17 ` Srivatsa Vaddagiri
2005-09-07 17:27 ` Nish Aravamudan
2005-09-07 18:18 ` Srivatsa Vaddagiri
2005-09-07 18:33 ` Nish Aravamudan
2005-09-09 16:27 ` Bill Davidsen
2005-09-05 7:37 ` Russell King
2005-09-05 7:49 ` Srivatsa Vaddagiri
2005-09-05 8:00 ` Russell King
2005-09-05 16:33 ` Nishanth Aravamudan
2005-09-05 7:00 ` Srivatsa Vaddagiri
2005-09-05 7:27 ` Tony Lindgren
2005-09-05 17:02 ` Nishanth Aravamudan
2005-09-07 7:37 ` Tony Lindgren
2005-09-07 15:05 ` Nishanth Aravamudan
2005-09-08 10:00 ` Tony Lindgren
2005-09-08 21:22 ` Nishanth Aravamudan
2005-09-08 22:08 ` Nishanth Aravamudan
2005-09-09 22:30 ` Nishanth Aravamudan
2005-09-20 11:06 ` Srivatsa Vaddagiri
2005-09-20 14:58 ` Nishanth Aravamudan
2005-09-22 13:38 ` Martin Schwidefsky
2005-09-22 14:52 ` Nishanth Aravamudan
2005-09-22 18:32 ` Srivatsa Vaddagiri
2005-09-26 15:08 ` Srivatsa Vaddagiri
2005-09-23 6:55 ` Srivatsa Vaddagiri
2005-09-05 7:44 ` Russell King
2005-09-05 8:19 ` Srivatsa Vaddagiri
2005-09-05 8:32 ` Russell King
2005-09-05 9:24 ` Srivatsa Vaddagiri
2005-09-05 17:06 ` Nishanth Aravamudan
2005-09-05 17:04 ` Nishanth Aravamudan
2005-09-05 17:27 ` Srivatsa Vaddagiri
2005-09-05 18:06 ` Nishanth Aravamudan
2005-09-05 13:19 ` Srivatsa Vaddagiri
2005-09-05 16:57 ` Nishanth Aravamudan
2005-09-05 17:25 ` Srivatsa Vaddagiri
2005-09-05 18:11 ` Nishanth Aravamudan
2005-09-03 4:05 ` [PATCH 1/3] Updated dynamic tick patches - Fix lost tick calculation in timer_pm.c Lee Revell
2005-09-03 4:18 ` Peter Williams
2005-09-03 4:34 ` Lee Revell
2005-09-03 4:48 ` Peter Williams
2005-09-03 5:15 ` Parag Warudkar
2005-09-03 5:30 ` Lee Revell
2005-09-03 5:20 ` Srivatsa Vaddagiri
2005-09-06 10:32 ` Pavel Machek
2005-09-06 10:46 ` Srivatsa Vaddagiri
2005-09-06 18:04 ` john stultz
2005-08-31 17:26 ` [PATCH 2/3] Updated dynamic tick patches - Cleanup Srivatsa Vaddagiri
2005-08-31 17:27 ` Srivatsa Vaddagiri [this message]
2005-09-01 5:23 ` Updated dynamic tick patches Con Kolivas
2005-09-01 13:07 ` Tony Lindgren
2005-09-01 13:19 ` David Weinehall
2005-09-01 13:46 ` Tony Lindgren
2005-09-01 14:11 ` Srivatsa Vaddagiri
2005-09-02 17:34 ` Srivatsa Vaddagiri
2005-09-03 10:16 ` Tony Lindgren
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=20050831172704.GD4974@in.ibm.com \
--to=vatsa@in.ibm.com \
--cc=akpm@osdl.org \
--cc=arjan@infradead.org \
--cc=cfriesen@nortel.com \
--cc=george@mvista.com \
--cc=johnstul@us.ibm.com \
--cc=kernel@kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rlrevell@joe-job.com \
--cc=s0348365@sms.ed.ac.uk \
--cc=trenn@suse.de \
--cc=tytso@mit.edu \
/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
Powered by JetHome