All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast
@ 2008-09-09  8:28 Wei, Gang
  2008-09-10 10:15 ` Keir Fraser
  0 siblings, 1 reply; 10+ messages in thread
From: Wei, Gang @ 2008-09-09  8:28 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

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

CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast

LAPIC will stop during C3, and resume to work after exit from C3. Considering below case:
The LAPIC timer was programmed to expire after 1000us, but CPU enter C3 after 100us and exit C3 at 9xxus.

   0us: reprogram_timer(1000us)
 100us: entry C3, LAPIC timer stop
 9xxus: exit C3 due to unexpected event, LAPIC timer continue running
10xxus: reprogram_timer(1000us), fail due to the past expiring time.
......: no timer softirq raised, no change to LAPIC timer.
......: if entry C3 again, HPET will be forced reprogramed to now+small_slop.
......: if entry C2, no change to LAPIC.
18xxus: LAPIC timer expires unexpectedly if no C3 entries after 10xxus.

>From above sequences, we can find this case will either introduce extra HPET intrs or put off the softtimer expiring.
This patch simply stops the LAPIC timer first (avoid immediate unnecessary expiring) and raise a softirq (continue the softtimer handling process, which will correct the LAPIC timer) when reprogram LAPIC timer fails.

Signed-off-by: Wei Gang <gang.wei@intel.com>

[-- Attachment #2: cancel_useless_timer_intr_0909.patch --]
[-- Type: application/octet-stream, Size: 2012 bytes --]

CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast

LAPIC will stop during C3, and resume to work after exit from C3. Considering below case:
The LAPIC timer was programmed to expire after 1000us, but CPU enter C3 after 100us and exit C3 at 9xxus.

   0us: reprogram_timer(1000us)
 100us: entry C3, LAPIC timer stop
 9xxus: exit C3 due to unexpected event, LAPIC timer continue running
10xxus: reprogram_timer(1000us), fail due to the past expiring time.
......: no timer softirq raised, no change to LAPIC timer.
......: if entry C3 again, hpet will be forced reprogramed to now+small_slop.
......: if entry C2, no change to LAPIC.
18xxus: LAPIC timer expires unexpectedly if no C3 entries after 10xxus.

From above sequences, we can find this case will either introduce extra hpet intrs or put off the softtimer expiring.
This patch simply stops the LAPIC timer first (avoid immediate unnecessary expiring) and raise a softirq (continue the softtimer handling process, which will correct the LAPIC timer) when reprogram apic timer fails.

Signed-off-by: Wei Gang <gang.wei@intel.com>

diff -r da8cf43032a9 xen/arch/x86/hpet.c
--- a/xen/arch/x86/hpet.c	Tue Sep 09 09:07:17 2008 +0800
+++ b/xen/arch/x86/hpet.c	Tue Sep 09 09:47:16 2008 +0800
@@ -221,6 +221,8 @@ void hpet_broadcast_enter(void)
 
     spin_lock(&ch->lock);
 
+    disable_APIC_timer();
+
     cpu_set(smp_processor_id(), ch->cpumask);
 
     /* reprogram if current cpu expire time is nearer */
@@ -239,11 +241,17 @@ void hpet_broadcast_exit(void)
 
     if ( cpu_test_and_clear(cpu, ch->cpumask) )
     {
-        reprogram_timer(per_cpu(timer_deadline, cpu));
+        if ( !reprogram_timer(per_cpu(timer_deadline, cpu)) )
+        {
+            reprogram_timer(0);
+            raise_softirq(TIMER_SOFTIRQ);
+        }
 
         if ( cpus_empty(ch->cpumask) && ch->next_event != STIME_MAX )
             reprogram_hpet_evt_channel(ch, STIME_MAX, 0, 0);
     }
+
+    enable_APIC_timer();
 
     spin_unlock_irq(&ch->lock);
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-09-11 15:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-09  8:28 [PATCH 2/4] CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast Wei, Gang
2008-09-10 10:15 ` Keir Fraser
2008-09-10 14:25   ` Wei, Gang
2008-09-10 14:51     ` [PATCH 2/4] CPUIDLE: Avoid remnant LAPIC timer intrwhile " Tian, Kevin
2008-09-11  7:38     ` [PATCH 2/4] CPUIDLE: Avoid remnant LAPIC timer intr while " Keir Fraser
2008-09-11  7:46       ` Wei, Gang
2008-09-11 10:38     ` Keir Fraser
2008-09-11 10:59       ` [PATCH 2/4] CPUIDLE: Avoid remnant LAPIC timerintr " Tian, Kevin
2008-09-11 11:06         ` Keir Fraser
2008-09-11 15:22           ` Wei, Gang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.