Re: [PATCH] scheduler: fix x86 regression in native_sched_clock

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Friday, December 7, 2007 - 2:59 am

* Guillaume Chazarain <guichaz@yahoo.fr> wrote:


note that there are a couple of existing patches in this area. One is 
the fix below. There's also older frequency-scaling TSC patches - i'll 
try to dig them out.

	Ingo

---------------->
Subject: x86: idle wakeup event in the HLT loop
From: Ingo Molnar <mingo@elte.hu>

do a proper idle-wakeup event on HLT as well - some CPUs stop the TSC
in HLT too, not just when going through the ACPI methods.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/process_32.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Index: linux/arch/x86/kernel/process_32.c
===================================================================
--- linux.orig/arch/x86/kernel/process_32.c
+++ linux/arch/x86/kernel/process_32.c
@@ -113,10 +113,19 @@ void default_idle(void)
 		smp_mb();
 
 		local_irq_disable();
-		if (!need_resched())
+		if (!need_resched()) {
+			ktime_t t0, t1;
+			u64 t0n, t1n;
+
+			t0 = ktime_get();
+			t0n = ktime_to_ns(t0);
 			safe_halt();	/* enables interrupts racelessly */
-		else
-			local_irq_enable();
+			local_irq_disable();
+			t1 = ktime_get();
+			t1n = ktime_to_ns(t1);
+			sched_clock_idle_wakeup_event(t1n - t0n);
+		}
+		local_irq_enable();
 		current_thread_info()->status |= TS_POLLING;
 	} else {
 		/* loop is done by the caller */
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Fri Dec 7, 12:18 am)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Fri Dec 7, 1:02 am)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Ingo Molnar, (Fri Dec 7, 2:59 am)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Fri Dec 7, 4:18 am)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Fri Dec 7, 4:57 am)
Re: [patch] x86: scale cyc_2_nsec according to CPU frequency, Guillaume Chazarain, (Fri Dec 7, 7:27 am)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Fri Dec 7, 9:46 am)
Re: [patch] x86: scale cyc_2_nsec according to CPU frequency, Arjan van de Ven, (Sat Dec 8, 8:57 am)
Re: [patch] x86: scale cyc_2_nsec according to CPU frequency, Arjan van de Ven, (Sat Dec 8, 1:18 pm)
Re: [PATCH] scheduler: fix x86 regression in native_sched_ ..., Guillaume Chazarain, (Sat Dec 8, 4:37 pm)