mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: vatsa@in.ibm.com
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org,
	ck list <ck@vds.kolivas.org>
Subject: [PATCH 3/3] dyntick - Recover walltime upon wakeup
Date: Sat, 3 Sep 2005 01:46:11 +1000	[thread overview]
Message-ID: <200509030146.11874.kernel@kolivas.org> (raw)
In-Reply-To: <200509030145.18368.kernel@kolivas.org>

[-- Attachment #1: Type: text/plain, Size: 10 bytes --]

Con
---



[-- Attachment #2: dyntick-Recover_walltime_upon_wakeup.patch --]
[-- Type: text/x-diff, Size: 7878 bytes --]


This patch uses the lost tick information returned by mark_offset()
function in dyn-tick, to recover time.

Code by Srivatsa Vaddagiri <vatsa@in.ibm.com>

Index: linux-2.6.13-mm1/arch/i386/kernel/dyn-tick.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/dyn-tick.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/dyn-tick.c	2005-09-03 01:12:11.000000000 +1000
@@ -91,7 +91,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();
 	}
Index: linux-2.6.13-mm1/arch/i386/kernel/time.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/time.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/time.c	2005-09-03 01:12:11.000000000 +1000
@@ -250,7 +250,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) {
@@ -268,7 +268,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) {
@@ -293,6 +294,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
@@ -302,9 +305,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;
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_cyclone.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_cyclone.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_cyclone.c	2005-09-03 01:12:11.000000000 +1000
@@ -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)
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_hpet.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_hpet.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_hpet.c	2005-09-03 01:12:11.000000000 +1000
@@ -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)
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_none.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_none.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_none.c	2005-09-03 01:12:11.000000000 +1000
@@ -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)
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_pit.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_pit.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_pit.c	2005-09-03 01:12:11.000000000 +1000
@@ -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)
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_pm.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_pm.c	2005-09-03 01:12:11.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_pm.c	2005-09-03 01:12:11.000000000 +1000
@@ -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)
Index: linux-2.6.13-mm1/arch/i386/kernel/timers/timer_tsc.c
===================================================================
--- linux-2.6.13-mm1.orig/arch/i386/kernel/timers/timer_tsc.c	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/arch/i386/kernel/timers/timer_tsc.c	2005-09-03 01:12:11.000000000 +1000
@@ -175,7 +175,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;
@@ -219,6 +219,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
 
@@ -345,7 +347,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;
@@ -438,8 +440,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)
Index: linux-2.6.13-mm1/include/asm-i386/timer.h
===================================================================
--- linux-2.6.13-mm1.orig/include/asm-i386/timer.h	2005-09-03 01:11:54.000000000 +1000
+++ linux-2.6.13-mm1/include/asm-i386/timer.h	2005-09-03 01:12:11.000000000 +1000
@@ -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);

  reply	other threads:[~2005-09-02 15:46 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       ` Con Kolivas [this message]
2005-09-02 17:25       ` 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 ` [PATCH 3/3] Updated dynamic tick patches - Recover walltime upon wakeup Srivatsa Vaddagiri
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=200509030146.11874.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=ck@vds.kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vatsa@in.ibm.com \
    /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