Skip to contentSkip to conversation

lapic-timer: increase the max_delta to 31 bits

PATCH In review Pierre Tardy 2 participants 3 messages Jan 6, 2011 – Jan 10, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lapic-timer: increase the max_delta to 31 bits

Latest atom socs(penwell) does not have hpet timer.

As their local APIC timer is clocked at 400KHZ, and the current code limit their Initial Counter register to 23 bits, they cannot sleep more than 1.34 seconds which leads to ~2 spurious wakeup per second (1 per thread)

These SOCs support 32bit timer so we change the max_delta to at least 31bits. So we can at least sleep for 300 seconds.

We could not find any previous chip errata where lapic would only have 23 bit precision As powertop is suggesting to activate HPET to "sleep longer", this could mean this problem is already known.

Problem is here since very first implementation of lapic timer as a clock event e9e2cdb [PATCH] clockevents: i386 drivers
cc contributors of the first patch and x86 maintainers

CC: Arjan van de Ven <[email protected]>
CC: Adrian Bunk <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: H. Peter Anvin <[email protected]>
CC: Ingo Molnar <[email protected]>
Cc: john stultz <[email protected]>
Cc: Roman Zippel <[email protected]>
Cc: Andi Kleen <[email protected]>
TO: Thomas Gleixner <[email protected]>
TO: Ingo Molnar <[email protected]>
TO: "H. Peter Anvin" <[email protected]>
TO: [email protected]
TO: Suresh Siddha <[email protected]>
TO: Yinghai Lu <[email protected]>
TO: Robert Richter <[email protected]>

---
 arch/x86/kernel/apic/apic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/apic/apic.c +1 -1
index 7821813..c031f1d 100644
@@ -684,7 +684,7 @@ static int __init calibrate_APIC_clock(void)
 	lapic_clockevent.mult = div_sc(delta, TICK_NSEC * LAPIC_CAL_LOOPS,
 				       lapic_clockevent.shift);
 	lapic_clockevent.max_delta_ns =
-		clockevent_delta2ns(0x7FFFFF, &lapic_clockevent);
+		clockevent_delta2ns(0x7FFFFFFF, &lapic_clockevent);
 	lapic_clockevent.min_delta_ns =
 		clockevent_delta2ns(0xF, &lapic_clockevent);
 
Signature · 13 lines
1.7.0.4

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Pierre Tardy

Latest atom socs(penwell) does not have hpet timer.

As their local APIC timer is clocked at 400KHZ, and the current code limit their Initial Counter register to 23 bits, they cannot sleep more than 1.34 seconds which leads to ~2 spurious wakeup per second (1 per thread)

Quoted 6 lines

These SOCs support 32bit timer so we change the max_delta to at least 31bits. So we can at least sleep for 300 seconds.

We could not find any previous chip errata where lapic would only have 23 bit precision As powertop is suggesting to activate HPET to "sleep longer", this could mean this problem is already known.

I have no idea why I put this limit there back then. If there is no erratum then there is no reason to keep it.

Quoted 31 lines

Problem is here since very first implementation of lapic timer as a clock event e9e2cdb [PATCH] clockevents: i386 drivers
cc contributors of the first patch and x86 maintainers

arch/x86/kernel/apic/apic.c +1 -1
index 7821813..c031f1d 100644
@@ -684,7 +684,7 @@ static int __init calibrate_APIC_clock(void)
 	lapic_clockevent.mult = div_sc(delta, TICK_NSEC * LAPIC_CAL_LOOPS,
 				       lapic_clockevent.shift);
 	lapic_clockevent.max_delta_ns =
-		clockevent_delta2ns(0x7FFFFF, &lapic_clockevent);
+		clockevent_delta2ns(0x7FFFFFFF, &lapic_clockevent);
 	lapic_clockevent.min_delta_ns =
 		clockevent_delta2ns(0xF, &lapic_clockevent);
 
Signature · 13 lines
1.7.0.4

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

[tip:x86/urgent] x86, lapic-timer: Increase the max_delta to 31 bits

In reply to Pierre Tardy
Commit-ID:  4aed89d6b515b9185351706ca95cd712c9d8d6a3
Gitweb:     http://git.kernel.org/tip/4aed89d6b515b9185351706ca95cd712c9d8d6a3
Author:     Pierre Tardy <[email protected]>
AuthorDate: Thu, 6 Jan 2011 16:23:29 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 10 Jan 2011 09:36:49 +0100

x86, lapic-timer: Increase the max_delta to 31 bits

Latest atom socs(penwell) does not have hpet timer.

As their local APIC timer is clocked at 400KHZ, and the current code limit their Initial Counter register to 23 bits, they cannot sleep more than 1.34 seconds which leads to ~2 spurious wakeup per second (1 per thread)

These SOCs support 32bit timer so we change the max_delta to at least 31bits. So we can at least sleep for 300 seconds.

We could not find any previous chip errata where lapic would only have 23 bit precision As powertop is suggesting to activate HPET to "sleep longer", this could mean this problem is already known.

Problem is here since very first implementation of lapic timer as a clock event e9e2cdb [PATCH] clockevents: i386 drivers.

Cc Arjan van de Ven <[email protected]>
Cc Adrian Bunk <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc john stultz <[email protected]>
Cc Roman Zippel <[email protected]>
Cc Andi Kleen <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/apic/apic.c +1 -1
index ce65d44..1efd378 100644
@@ -684,7 +684,7 @@ static int __init calibrate_APIC_clock(void)
 	lapic_clockevent.mult = div_sc(delta, TICK_NSEC * LAPIC_CAL_LOOPS,
 				       lapic_clockevent.shift);
 	lapic_clockevent.max_delta_ns =
-		clockevent_delta2ns(0x7FFFFF, &lapic_clockevent);
+		clockevent_delta2ns(0x7FFFFFFF, &lapic_clockevent);
 	lapic_clockevent.min_delta_ns =
 		clockevent_delta2ns(0xF, &lapic_clockevent);