PM timer still has problems
Hi,
Booting with clock=pmtmr causes weird problems here (the system complains that clock override failed and the bogomips loop produces bogus values). Below is the dmesg output as well as /proc/cpuinfo. I have CONFIG_X86_LOCAL_APIC=y and CONFIG_X86_PM_TIMER=y.
I don't really know whether this box (ASUS L3800C, more data at
http://bugme.osdl.org/show_bug.cgi?id=1185) has a PM timer or not, but even if it doesn't, the code should account for that gracefully. I'll be happy to provide any additional info.
Signature · 239 lines
Karol 'sziwan' Kozimor [email protected] dmesg: Linux version 2.6.0-mm2 (sziwan@nadir) (gcc version 3.3.2) #1 Tue Dec 30 21:18:25 CET 2003 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009fc00 (usable) BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved) BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000000fff9000 (usable) BIOS-e820: 000000000fff9000 - 000000000ffff000 (ACPI data) BIOS-e820: 000000000ffff000 - 0000000010000000 (ACPI NVS) BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved) 255MB LOWMEM available. On node 0 totalpages: 65529 DMA zone: 4096 pages, LIFO batch:1 Normal zone: 61433 pages, LIFO batch:14 HighMem zone: 0 pages, LIFO batch:1 DMI 2.3 present. ASUS L3C with broken BIOS detected. Refusing to enable the local APIC. ACPI: RSDP (v000 ASUS ) @ 0x000f6890 ACPI: RSDT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9000 ACPI: FADT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9080 ACPI: BOOT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9040 ACPI: DSDT (v001 ASUS P4_L3CS 0x00001000 MSFT 0x0100000d) @ 0x00000000 Building zonelist for node : 0 Kernel command line: BOOT_IMAGE=2.6 ro root=305 resume=/dev/hda1 acpi_sleep=s3_bios clock=pmtmr current: c031ea60 current->thread_info: c0386000 Initializing CPU#0 PID hash table entries: 1024 (order 10: 8192 bytes) Warning: clock= override failed. Defaulting to PIT Using pit for high-res timesource Console: colour VGA+ 80x25 Memory: 255896k/262116k available (1877k kernel code, 5520k reserved, 705k data, 132k init, 0k highmem) zapping low mappings. Calibrating delay loop... 2252.80 BogoMIPS Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) CPU: After generic identify, caps: 3febf9ff 00000000 00000000 00000000 CPU: After vendor identify, caps: 3febf9ff 00000000 00000000 00000000 CPU: Trace cache: 12K uops, L1 D cache: 8K CPU: L2 cache: 512K CPU: After all inits, caps: 3febf9ff 00000000 00000000 00000080 Intel machine check architecture supported. Intel machine check reporting enabled on CPU#0. CPU#0: Intel P4/Xeon Extended MCE MSRs (12) available CPU#0: Thermal monitoring enabled CPU: Intel(R) Pentium(R) 4 Mobile CPU 1.70GHz stepping 04 Enabling fast FPU save and restore... done. Enabling unmasked SIMD FPU exception support... done. Checking 'hlt' instruction... OK. POSIX conformance testing by UNIFIX NET: Registered protocol family 16 PCI: PCI BIOS revision 2.10 entry at 0xf0e40, last bus=2 PCI: Using configuration type 1 mtrr: v2.0 (20020519) ACPI: Subsystem revision 20031203 tbxface-0117 [03] acpi_load_tables : ACPI Tables successfully acquired Parsing all Control Methods:.............................................................................................................................................................................................................................................................. Table [DSDT](id F004) - 761 Objects with 59 Devices 254 Methods 26 Regions ACPI Namespace successfully loaded at root c03c35bc ACPI: IRQ9 SCI: Level Trigger. evxfevnt-0093 [04] acpi_enable : Transition to ACPI mode successful evgpeblk-0747 [06] ev_create_gpe_block : GPE 00 to 15 [_GPE] 2 regs at 000000000000E428 on int 9 evgpeblk-0747 [06] ev_create_gpe_block : GPE 16 to 31 [_GPE] 2 regs at 000000000000E42C on int 9 Completing Region/Field/Buffer/Package initialization:.................................................................................. Initialized 26/26 Regions 0/0 Fields 23/23 Buffers 33/33 Packages (769 nodes) Executing all Device _STA and_INI methods:............................................................. 61 Devices found containing: 61 _STA, 5 _INI methods ACPI: Interpreter enabled ACPI: Using PIC for interrupt routing ACPI: PCI Interrupt Link [LNKA] (IRQs *5) ACPI: PCI Interrupt Link [LNKB] (IRQs 7 *11) ACPI: PCI Interrupt Link [LNKC] (IRQs 3 11) ACPI: PCI Interrupt Link [LNKD] (IRQs 5 7 11) ACPI: PCI Interrupt Link [LNKE] (IRQs 3 4 5 6 7 10 11 12 14 15) ACPI: PCI Interrupt Link [LNKF] (IRQs 3 4 5 6 7 10 11 12 14 15) ACPI: PCI Interrupt Link [LNKG] (IRQs 3 4 5 6 7 10 11 12 14 15) ACPI: PCI Interrupt Link [LNKH] (IRQs 3 4 5 6 7 10 11 12 14 15) ACPI: PCI Root Bridge [PCI0] (00:00) PCI: Probing PCI hardware (bus 00) Transparent bridge - 0000:00:1e.0 ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.PCI1._PRT] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.PCI2._PRT] ACPI: Embedded Controller [ECD0] (gpe 28) ACPI: Power Resource [PRCF] (on) Linux Plug and Play Support v0.97 (c) Adam Belay PnPBIOS: Scanning system for PnP BIOS support... PnPBIOS: Found PnP BIOS installation structure at 0xc00fc3c0 PnPBIOS: PnP BIOS version 1.0, entry 0xf0000:0xc3f0, dseg 0xf0000 pnp: 00:11: ioport range 0x290-0x297 has been reserved pnp: 00:11: ioport range 0x3f0-0x3f1 has been reserved pnp: 00:11: ioport range 0xe400-0xe47f has been reserved pnp: 00:11: ioport range 0xec00-0xec3f has been reserved PnPBIOS: 15 nodes reported by PnP BIOS; 15 recorded by driver ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 5 ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 9 ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9 ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 11 PCI: Using ACPI for IRQ routing PCI: if you experience problems, try using option 'pci=noacpi' or even 'acpi=off' SBF: Simple Boot Flag extension found and enabled. SBF: Setting boot flags 0x1 Machine check exception polling timer started. devfs: v1.22 (20021013) Richard Gooch ([email protected]) devfs: boot_options: 0x1 SGI XFS for Linux with no debug enabled ACPI: AC Adapter [ACAD] (on-line) ACPI: Battery Slot [BAT0] (battery present) ACPI: Power Button (FF) [PWRF] ACPI: Sleep Button (CM) [SLPB] ACPI: Lid Switch [LIDD] ACPI: Fan [CFAN] (on) ACPI: Processor [CPU0] (supports C1 C2, 8 throttling states) ACPI: Thermal Zone [THRM] (51 C) pty: 256 Unix98 ptys configured Real Time Clock Driver v1.12 Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx ICH3M: IDE controller at PCI slot 0000:00:1f.1 ICH3M: chipset revision 2 ICH3M: not 100% native mode: will probe irqs later ide0: BM-DMA at 0x8400-0x8407, BIOS settings: hda:DMA, hdb:pio ide1: BM-DMA at 0x8408-0x840f, BIOS settings: hdc:DMA, hdd:pio hda: IC25N040ATCS04-0, ATA DISK drive Using anticipatory io scheduler ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 hdc: TOSHIBA DVD-ROM SD-R2212, ATAPI CD/DVD-ROM drive ide1 at 0x170-0x177,0x376 on irq 15 hda: max request size: 128KiB hda: 78140160 sectors (40007 MB) w/1768KiB Cache, CHS=65535/16/63, UDMA(100) /dev/ide/host0/bus0/target0/lun0: p1 p2 p3 < p5 p6 p7 > p4 end_request: I/O error, dev hdc, sector 0 cdrom: : unknown mrw mode page hdc: ATAPI 24X DVD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33) Uniform CD-ROM driver Revision: 3.20 end_request: I/O error, dev hdc, sector 0 mice: PS/2 mouse device common for all mice i8042.c: Detected active multiplexing controller, rev 1.1. serio: i8042 AUX0 port at 0x60,0x64 irq 12 serio: i8042 AUX1 port at 0x60,0x64 irq 12 serio: i8042 AUX2 port at 0x60,0x64 irq 12 serio: i8042 AUX3 port at 0x60,0x64 irq 12 Synaptics Touchpad, model: 1 Firmware: 4.6 180 degree mounted touchpad Sensor: 18 new absolute packet format Touchpad has extended capability bits -> four buttons -> multifinger detection -> palm detection input: SynPS/2 Synaptics TouchPad on isa0060/serio4 serio: i8042 KBD port at 0x60,0x64 irq 1 input: AT Translated Set 2 keyboard on isa0060/serio0 NET: Registered protocol family 2 IP: routing cache hash table of 2048 buckets, 16Kbytes TCP: Hash tables configured (established 16384 bind 32768) NET: Registered protocol family 1 NET: Registered protocol family 17 Resume Machine: resuming from /dev/hda1 Resuming from device hda1 Resume Machine: This is normal swap space PM: Reading pmdisk image. PM: Resume from disk failed. ACPI: (supports S0 S1 S3 S4 S5) XFS mounting filesystem hda5 Ending clean XFS mount for filesystem: hda5 VFS: Mounted root (xfs filesystem) readonly. Mounted devfs on /dev Freeing unused kernel memory: 132k freed Adding 393552k swap on /dev/hda1. Priority:-1 extents:1 XFS mounting filesystem hda6 Ending clean XFS mount for filesystem: hda6 Asus Laptop ACPI Extras version 0.26 L3C model detected, supported Linux Kernel Card Services options: [pci] [cardbus] [pm] Yenta: CardBus bridge found at 0000:02:07.0 [1043:1624] Yenta: ISA IRQ mask 0x0498, PCI irq 5 Socket status: 30000006 PCI: Enabling device 0000:02:07.1 (0000 -> 0002) Yenta: CardBus bridge found at 0000:02:07.1 [1043:1624] Yenta: ISA IRQ mask 0x0498, PCI irq 11 Socket status: 30000006 cs: IO port probe 0x0c00-0x0cff: clean. cs: IO port probe 0x0800-0x08ff: clean. cs: IO port probe 0x0100-0x04ff: excluding 0x2f8-0x2ff 0x378-0x37f 0x3c0-0x3df 0x3f8-0x3ff 0x4d0-0x4d7 cs: IO port probe 0x0a00-0x0aff: clean. 8139too Fast Ethernet driver 0.9.27 eth0: RealTek RTL8139 at 0xa800, 00:e0:18:dc:6d:bc, IRQ 9 eth0: Identified 8139 chip type 'RTL-8100' eth0: link down drivers/usb/core/usb.c: registered new driver usbfs drivers/usb/core/usb.c: registered new driver hub drivers/usb/host/uhci-hcd.c: USB Universal Host Controller Interface driver v2.1 uhci_hcd 0000:00:1d.0: UHCI Host Controller PCI: Setting latency timer of device 0000:00:1d.0 to 64 uhci_hcd 0000:00:1d.0: irq 5, io base 0000b800 uhci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 1 hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected uhci_hcd 0000:00:1d.1: UHCI Host Controller PCI: Setting latency timer of device 0000:00:1d.1 to 64 uhci_hcd 0000:00:1d.1: irq 9, io base 0000b400 uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 2 hub 2-0:1.0: USB hub found hub 2-0:1.0: 2 ports detected hub 1-0:1.0: new USB device on port 1, assigned address 2 request_module: failed /sbin/modprobe -- net-pf-10. error = 256 PCI: Setting latency timer of device 0000:00:1f.5 to 64 intel8x0_measure_ac97_clock: measured 49997 usecs intel8x0: clocking to 48000 ohci1394: $Rev: 1087 $ Ben Collins <[email protected]> ohci1394: fw-host0: OHCI-1394 1.0 (PCI): IRQ=[9] MMIO=[d6000000-d60007ff] Max Packet=[2048] ieee1394: Host added: ID:BUS[0-00:1023] GUID[00e0180003075522] /proc/cpuinfo: processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 Mobile CPU 1.70GHz stepping : 4 cpu MHz : 0.000 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm bogomips : 2252.80
Quoted 5 lines · Karol Kozimor
Booting with clock=pmtmr causes weird problems here (the system complains that clock override failed and the bogomips loop produces bogus values). Below is the dmesg output as well as
/proc/cpuinfo. I haveCONFIG_X86_LOCAL_APIC=yandCONFIG_X86_PM_TIMER=y.
Yup, thanks. Several people have reported problems with the PM timer. Unfortunately, everyone's symptoms seem to be different.
I'm not sure whether we're dealing with BIOS problem, hardware problems, an implementation bug or all of the above.
Arjan, was the PM time code in 2.4 widely deployed and/or reliable?
Thus wrote Andrew Morton:
Quoted 6 lines
Quoted 4 lines
Booting with clock=pmtmr causes weird problems here (the system complains that clock override failed and the bogomips loop produces bogus values). Below is the dmesg output as well as
/proc/cpuinfo. I haveCONFIG_X86_LOCAL_APIC=yandCONFIG_X86_PM_TIMER=y.Yup, thanks. Several people have reported problems with the PM timer. Unfortunately, everyone's symptoms seem to be different.
Just for the record: I'm still getting those problems with 2.6.1-rc1-mm1. Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Quoted 7 lines · Karol Kozimor
Thus wrote Andrew Morton:
Quoted 6 lines
Quoted 5 lines
Booting with clock=pmtmr causes weird problems here (the system complains that clock override failed and the bogomips loop
produces bogus values). Below is the dmesg output as well as/proc/cpuinfo. I haveCONFIG_X86_LOCAL_APIC=yandCONFIG_X86_PM_TIMER=y.
Quoted 5 lines
Quoted 2 lines
Yup, thanks. Several people have reported problems with the PM timer. Unfortunately, everyone's symptoms seem to be different.
Just for the record: I'm still getting those problems with 2.6.1-rc1-mm1. Best regards,
I threw a monkey wrench in timer code and came up with the patch below... It is not intended for inclusion as is, just some work in progress.
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock. Plus there some code rearrangements, and stuff I grabbed from the CPUFREQ list (Dominics + Li Shahoua P4 variable tsc info ), etc... If there is an interest I can split the code into smaller chinks. For what it worth I am running with ACPI PM timer, CPUFREQ (dynamically switching frequency based on load) and Synaptics and everything is calm. Ntpd has also stopped complaining about loosing sync...
Dmitry
===================================================================
[email protected], 2004-01-05 00:38:31-05:00, [email protected]
Timers: convert ACPIT PM timer to use tsc to do delays and
monotonic clock, code consolidations
arch/i386/kernel/time.c | 51 ++++ arch/i386/kernel/timers/common.c | 283 +++++++++++++++++---------- arch/i386/kernel/timers/timer.c | 3 arch/i386/kernel/timers/timer_cyclone.c | 75 +++---- arch/i386/kernel/timers/timer_hpet.c | 196 ++++++++++++------- arch/i386/kernel/timers/timer_pm.c | 67 +----- arch/i386/kernel/timers/timer_tsc.c | 330 +------------------------------- include/asm-i386/timer.h | 9 include/asm-i386/timer_common.h | 70 ++++++ 9 files changed, 515 insertions(+), 569 deletions(-)
===================================================================
arch/i386/kernel/time.c +51 -0
@@ -45,6 +45,7 @@#include <linux/sysdev.h> #include <linux/bcd.h> #include <linux/efi.h> +#include <linux/cpufreq.h> #include <asm/io.h> #include <asm/smp.h>
@@ -345,6 +346,8 @@ cur_timer =select_timer ();printk (KERN_INFO "Using %s for high-res timesource\n" ,cur_timer->name); +init_cpu_khz (); + time_init_hook(); }#endif
@@ -369,5 +372,53 @@ cur_timer =select_timer ();printk (KERN_INFO "Using %s for high-res timesource\n" ,cur_timer->name); +init_cpu_khz (); +time_init_hook (); } + +#ifdef CONFIG_CPU_FREQ +static unsigned int ref_freq =0 ; +static unsigned long loops_per_jiffy_ref =0 ; + +#ifndef CONFIG_SMP +static unsigned long cpu_khz_ref =0 ; +#endif + +static int time_cpufreq_notifier (struct notifier_block *nb,unsigned long val, +void *data) +{ +struct cpufreq_freqs *freq = data; + +write_seqlock_irq (&xtime_lock); +if (!ref_freq) { + ref_freq = freq->old; + loops_per_jiffy_ref = cpu_data[freq->cpu].loops_per_jiffy; +#ifndef CONFIG_SMP + cpu_khz_ref = cpu_khz; +#endif + } + +if ((val ==CPUFREQ_PRECHANGE && freq->old < freq->new) || + (val ==CPUFREQ_POSTCHANGE && freq->old > freq->new)) { + cpu_data[freq->cpu].loops_per_jiffy =cpufreq_scale (loops_per_jiffy_ref, ref_freq, freq->new); +#ifndef CONFIG_SMP +if (cpu_khz) + cpu_khz =cpufreq_scale (cpu_khz_ref, ref_freq, freq->new); +#endif + } +write_sequnlock_irq (&xtime_lock); + +return 0 ; +} + +static struct notifier_block time_cpufreq_notifier_block = { + .notifier_call = time_cpufreq_notifier +}; + +static int __init cpufreq_time (void ) +{ +return cpufreq_register_notifier (&time_cpufreq_notifier_block,CPUFREQ_TRANSITION_NOTIFIER ); +} +core_initcall (cpufreq_time); +#endif
arch/i386/kernel/timers/common.c +184 -99
337 lines not on this page · raw message
arch/i386/kernel/timers/timer.c +3 -0
@@ -22,6 +22,9 @@#ifdef CONFIG_X86_PM_TIMER &timer_pmtmr,#endif +#ifdef CONFIG_HPET_TIMER + &timer_tsc_hpet, +#endif &timer_tsc, &timer_pit, NULL,
arch/i386/kernel/timers/timer_cyclone.c +37 -38
183 lines not on this page · raw message
arch/i386/kernel/timers/timer_hpet.c +134 -62
252 lines not on this page · raw message
arch/i386/kernel/timers/timer_pm.c +12 -55
135 lines not on this page · raw message
arch/i386/kernel/timers/timer_tsc.c +20 -310
404 lines not on this page · raw message
include/asm-i386/timer.h +4 -5
@@ -24,6 +24,8 @@extern struct timer_opts *select_timer (void );extern void clock_fallback (void ); +extern void init_cpu_khz (void ); +/* Modifiers for buggy PIT handling */ extern int pit_latch_buggy;
@@ -38,15 +40,12 @@#ifdef CONFIG_X86_CYCLONE_TIMER extern struct timer_opts timer_cyclone;#endif - -extern unsigned long calibrate_tsc (void ); -extern void init_cpu_khz (void );#ifdef CONFIG_HPET_TIMER extern struct timer_opts timer_hpet; -extern unsigned long calibrate_tsc_hpet (unsigned long *tsc_hpet_quotient_ptr); +extern struct timer_opts timer_tsc_hpet;#endif -#ifdef CONFIG_X86_PM_TIMER extern struct timer_opts timer_pmtmr;#endif +#endif
include/asm-i386/timer_common.h new file +70 -0
70 lines not on this page · raw message
Thus wrote Dmitry Torokhov:
Quoted 10 lines
I threw a monkey wrench in timer code and came up with the patch below... It is not intended for inclusion as is, just some work in progress.
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock. Plus there some code rearrangements, and stuff I grabbed from the CPUFREQ list (Dominics + Li Shahoua P4 variable tsc info ), etc... If there is an interest I can split the code into smaller chinks. For what it worth I am running with ACPI PM timer, CPUFREQ (dynamically switching frequency based on load) and Synaptics and everything is calm. Ntpd has also stopped complaining about loosing sync...
Well, no luck here. When clock=pmtmr is appended, the system hangs just after printing:
#v+
Warning: clock= override failed. Defaulting to PIT
Using pit for high-res timesource
Detected 1700.598 MHz processor.
Console: colour VGA+ 80x25
#v-
The system boots fine without the clock= parameter, though. [it's an ASUS L3800C laptop with a P4-M and 2.6.1-rc1-mm1 with your patch on top]
Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Quoted 2 lines · Dmitry Torokhov
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock.
I think you have a valid point that as loops_per_jiffy isn't updated, delay_pmtmr() and delay_pit() are broken w/ CPUFREQ.
However I don't understand using the TSC for montonic_clock. I have no clue why the HPET folks implemented it that way (likely my fault for not enough documentaiton), but I haven't had the time to try to clean up that code. And really, if your TSC is reliable enough for monotonic_clock, why are you using the pmtmr? :) Unless it specifically is resolving an issue, I'd drop that change.
Quoted 3 lines
Plus there some code rearrangements, and stuff I grabbed
from the CPUFREQ list (Dominics + Li Shahoua P4 variable tsc info ), etc... If there is an interest I can split the code into smaller chinks.
Yes. Please do split out the white space, and the cpufreq changes as well. I realize that the patch is very inter-woven, but atleast those two changes are fairly seperable.
Quoted 4 lines
For what
it worth I am running with ACPI PM timer, CPUFREQ (dynamically switching frequency based on load) and Synaptics and everything is calm. Ntpd has also stopped complaining about loosing sync...
Its very good this is working for you! However, I'd definately like to narrow down the specific change that causes it to work.
thanks for the strong interest and effort!
-john
Quoted 7 lines · john stultz
Quoted 2 lines · Dmitry Torokhov
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock.
I think you have a valid point that as
loops_per_jiffyisn't updated,delay_pmtmr()anddelay_pit()are broken w/ CPUFREQ.
Quoted 7 lines
However I don't understand using the TSC for
montonic_clock. I have no clue why the HPET folks implemented it that way (likely my fault for not enough documentaiton), but I haven't had the time to try to clean up that code. And really, if your TSC is reliable enough formonotonic_clock, why are you using the pmtmr? :) Unless it specifically is resolving an issue, I'd drop that change.
I thought (it seems that I was mistaken) that the goal of monotonic_clock is to privide high-resolution cheap timestamps that are guaranteed never go back as there is no adjustments to the time. The normal clock it supposed to be stable and accurate but probably give lower resolution. In case of pmtmr vs. TSC seems to have higher resolution and is cheap so it was used.
Dmitry
Quoted 15 lines · Dmitry Torokhov
Quoted 7 lines · john stultz
Quoted 2 lines · Dmitry Torokhov
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock.
I think you have a valid point that as
loops_per_jiffyisn't updated,delay_pmtmr()anddelay_pit()are broken w/ CPUFREQ.Quoted 6 lines
However I don't understand using the TSC for
montonic_clock. I have no clue why the HPET folks implemented it that way (likely my fault for not enough documentaiton), but I haven't had the time to try to clean up that code. And really, if your TSC is reliable enough formonotonic_clock, why are you using the pmtmr? :) Unless it specifically is resolving an issue, I'd drop that change.
Quoted 5 lines
I thought (it seems that I was mistaken) that the goal of
monotonic_clockis to privide high-resolution cheap timestamps that are guaranteed never go back as there is no adjustments to the time. The normal clock it supposed to be stable and accurate but probably give lower resolution. In case of pmtmr vs. TSC seems to have higher resolution and is cheap so it was used.
Indeed never going back in time was an important part of the goal, but it also is supposed to give the number of nanoseconds that have past since boot. If the TSC is unsynched or changes frequency then we cannot provide that. Additionally if the TSC is unsynched, monotonic_clock can go backwards when using the TSC.
If someone wants a highres and possibly inconsistent timestamp (somewhat like sched_clock uses), get_cycles() provides that interface.
thanks
-john
Thus wrote Dmitry Torokhov:
Quoted 10 lines
I threw a monkey wrench in timer code and came up with the patch below... It is not intended for inclusion as is, just some work in progress.
I decided to go hpet way and use tsc in ACPI PM timer to do delay stuff and monotonic clock. Plus there some code rearrangements, and stuff I grabbed from the CPUFREQ list (Dominics + Li Shahoua P4 variable tsc info ), etc... If there is an interest I can split the code into smaller chinks. For what it worth I am running with ACPI PM timer, CPUFREQ (dynamically switching frequency based on load) and Synaptics and everything is calm. Ntpd has also stopped complaining about loosing sync...
Well, no luck here. When clock=pmtmr is appended, the system hangs just after printing:
#v+
Warning: clock= override failed. Defaulting to PIT
Using pit for high-res timesource
Detected 1700.598 MHz processor.
Console: colour VGA+ 80x25
#v-
The system boots fine without the clock= parameter, though. [it's an ASUS L3800C laptop with a P4-M and 2.6.1-rc1-mm1 with your patch on top]
Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Quoted 10 lines · Karol Kozimor
Hi,
Booting with clock=pmtmr causes weird problems here (the system complains that clock override failed and the bogomips loop produces bogus values). Below is the dmesg output as well as/proc/cpuinfo. I haveCONFIG_X86_LOCAL_APIC=yandCONFIG_X86_PM_TIMER=y.I don't really know whether this box (ASUS L3800C, more data at
http://bugme.osdl.org/show_bug.cgi?id=1185) has a PM timer or not, but even if it doesn't, the code should account for that gracefully. I'll be happy to provide any additional info.
If the override boot option failed, its most likely your system doesn't have an ACPI PM time source. Instead it seems your system is having trouble using the PIT as a time source (which seems not all that uncommon unfortunately).
I guess we can just re-call select_timer() without an override if the override fails, that way you'll fall back to the default time source on your system. Try the (compile tested) patch below and see if that helps.
Thanks for the feedback!
-john
arch/i386/kernel/timers/timer.c +25 -6
@@ -43,21 +43,40 @@ cur_timer = &timer_pit; } -/* iterates through the list of timers, returning the first -* one that initializes successfully. +/* helper function to iterates through the list of timers, +* returning the first one that initializes successfully. */ -struct timer_opts *select_timer (void ) +static struct timer_opts *pick_timer (char * override) {int i =0 ;/* find most preferred working timer */ while (timers[i]) {if (timers[i]->init) -if (timers[i]->init (clock_override) ==0 ) +if (timers[i]->init (override) ==0 )return timers[i]; ++i; } - -panic ("select_timer: Cannot find a suitable timer\n" );return NULL ; +} + +struct timer_opts *select_timer (void ) +{ +struct timer_opts * ret; + +/* pick the best time source*/ + ret =pick_timer (clock_override); + +/* if we didn't find anything, try without the override */ +if (!ret && clock_override) { +printk ("Warning: 'clock=%s' override failed.\n" , clock_override); + ret =pick_timer (NULL ); + } + +/* if we still didn't find anything, we're ruined */ +/* note that this won't happen, as the PIT always succeeds*/ +if (!ret) +panic ("select_timer: Cannot find a suitable timer\n" ); + +return ret; }
arch/i386/kernel/timers/timer_pit.c +1 -1
@@ -24,7 +24,7 @@ {/* check clock override */ if (override[0 ] &&strncmp (override,"pit" ,3 )) -printk (KERN_ERR "Warning: clock= override failed. Defaulting to PIT\n" ); +return -ENODEV ; count_p =LATCH ;return 0 ;
Thus wrote john stultz:
Quoted 2 lines
If the override boot option failed, its most likely your system doesn't have an ACPI PM time source. Instead it seems your system is having
Well, I don't have the slightest idea on how to determine this, though I read somewhere that all ACPI-compliant systems have those.
Quoted 2 lines
trouble using the PIT as a time source (which seems not all that uncommon unfortunately).
Perhaps, though bear in mind it behaves so only if clock=pmtmr has been appended and works fine with clock=pit.
Quoted 3 lines
I guess we can just re-call
select_timer()without an override if the override fails, that way you'll fall back to the default time source on your system. Try the (compile tested) patch below and see if that helps.
That would be PIT again, as TSC is unusable due to CPUFreq. I'll try it ASAP -- should I test with Dmitry's patch applied? Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Quoted 6 lines · Karol Kozimor
Thus wrote john stultz:
Quoted 2 lines
If the override boot option failed, its most likely your system doesn't have an ACPI PM time source. Instead it seems your system is having
Well, I don't have the slightest idea on how to determine this, though I read somewhere that all ACPI-compliant systems have those.
More debug output is probably needed.
Quoted 5 lines
Quoted 2 lines
trouble using the PIT as a time source (which seems not all that uncommon unfortunately).
Perhaps, though bear in mind it behaves so only if clock=pmtmr has been appended and works fine with clock=pit.
Ah, I must have missed that point. Indeed that is very odd. When booting without the clock= what time source is used? Does booting w/ "clock=crazy" also show the problem?
Quoted 6 lines
Quoted 3 lines
I guess we can just re-call
select_timer()without an override if the override fails, that way you'll fall back to the default time source on your system. Try the (compile tested) patch below and see if that helps.That would be PIT again, as TSC is unusable due to CPUFreq. I'll try it ASAP -- should I test with Dmitry's patch applied?
No, my patch is just against 2.6.1-rc1 (really I should have checked if it applies onto mm2, but I didn't). Due to the misunderstanding above, I'm actually more interested in the questions I just asked then if the last patch worked (but if you're feeling bored, don't let me stop you from testing it :)
thanks
-john
Thus wrote john stultz:
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
If the override boot option failed, its most likely your system doesn't have an ACPI PM time source. Instead it seems your system is having
Well, I don't have the slightest idea on how to determine this, though I read somewhere that all ACPI-compliant systems have those.
More debug output is probably needed.
I'll be happy to provide it :)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
trouble using the PIT as a time source (which seems not all that uncommon unfortunately).
Perhaps, though bear in mind it behaves so only if clock=pmtmr has been appended and works fine with clock=pit.
Ah, I must have missed that point. Indeed that is very odd. When booting without the clock= what time source is used? Does booting w/ "clock=crazy" also show the problem?
It depends -- generally either PIT (that's 2.4) or TSC, the latter switches back to PIT once CPUFreq is used. I've never seen any problems with the bogomips loop or /proc/cpuinfo, except when it could be directly attributed to CPUFreq bugs.
I booted the following with clock=crazy:
1) 2.6.1-rc1-mm1 with Dmitry's patch: deadlock as before
2) 2.6.0-test11-almost vanilla (Nigel's swsusp patches): passed, results similar to -rc1-mm1 vanilla, i.e. cpuinfo shows 0 MHz and bogomips is miscalculated.
So it seems to be a more generic problem.
2.6.1-rc1 is on the way.
Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Thus wrote john stultz:
Quoted 3 lines
Ah, I must have missed that point. Indeed that is very odd. When booting without the clock= what time source is used? Does booting w/ "clock=crazy" also show the problem?
A quick follow-up: booting with 2.6.1-rc1 + plus your patch:
clock=crazy: doesn't even pass the Uncompressing kernel... Booting Linux
stage,
clock=pmtmr: see above
clock=tsc : boots normally
clock=pit : as well
Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Quoted 8 lines · Karol Kozimor
Thus wrote john stultz:
Quoted 3 lines
Ah, I must have missed that point. Indeed that is very odd. When booting without the clock= what time source is used? Does booting w/ "clock=crazy" also show the problem?
A quick follow-up: booting with 2.6.1-rc1 + plus your patch:
clock=crazy: doesn't even pass the Uncompressing kernel... Booting Linux
stage,
Grrr. That def shouldn't happen. Let me do some further local testing and I'll get back to you with another patch.
Quoted 1 line
clock=pmtmr: see above
Expected, as 2.6.1-rc1 doesn't have the ACPI pm time source, so pmtmr=crazy ;)
Quoted 2 lines
clock=tsc : boots normally
clock=pit : as well
I'm still curious about what default time source is selected (when not using the clock= option) using 2.6.1-rc1-mm1. As well as what happens there w/ clock=crazy.
thanks so much for the feedback.
-john
Quoted 5 lines · john stultz
If the override boot option failed, its most likely your system doesn't have an ACPI PM time source. Instead it seems your system is having trouble using the PIT as a time source (which seems not all that uncommon unfortunately).
Or that Karol's laptop has ACPI PM timer that is accessed through the memory (ACPI_ADR_SPACE_SYSTEM_MEMORY), is there such implementations? Right now timer_pm.c only supports IO-port based timer access.
Dmitry
Thus wrote Dmitry Torokhov:
Quoted 3 lines
Or that Karol's laptop has ACPI PM timer that is accessed through the memory (
ACPI_ADR_SPACE_SYSTEM_MEMORY), is there such implementations? Right nowtimer_pm.conly supports IO-port based timer access.
Apparently, the PM timer now works as of 2.6.1-mm4:
#v+
Detected 1700.569 MHz processor.
Using pmtmr for high-res timesource
#v-
But the BogoMIPS loop is still wrong:
#v+
Calibrating delay loop... 1683.45 BogoMIPS
#v-
It looks as if it needed to be multiplied by two, right? Additionally, the /proc/cpuinfo is not updated on governor change (I'm using the speedstep-ich driver which otherwise works fine), although the real CPU frequency certainly is. I'm not sure if this is in any way related though.
Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]
Thus wrote Dmitry Torokhov:
[...]
Another follow-up, this time the BogoMIPS value is completely bogus.
#v+
Linux version 2.6.2-rc1-mm2 (sziwan@nadir) (gcc version 3.3.2) #11 Fri Jan 23 22:45:18 CET 2004 BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000000fff9000 (usable)
BIOS-e820: 000000000fff9000 - 000000000ffff000 (ACPI data)
BIOS-e820: 000000000ffff000 - 0000000010000000 (ACPI NVS)
BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved)
255MB LOWMEM available.
zapping low mappings.
On node 0 totalpages: 65529
DMA zone: 4096 pages, LIFO batch:1
Normal zone: 61433 pages, LIFO batch:14
HighMem zone: 0 pages, LIFO batch:1
DMI 2.3 present.
ASUS L3C with broken BIOS detected. Refusing to enable the local APIC.
ACPI: RSDP (v000 ASUS ) @ 0x000f6890
ACPI: RSDT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9000
ACPI: FADT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9080
ACPI: BOOT (v001 ASUS P4_L3CS 0x42302e31 MSFT 0x31313031) @ 0x0fff9040
ACPI: DSDT (v001 ASUS P4_L3CS 0x00001000 MSFT 0x0100000d) @ 0x00000000
ACPI: PM-Timer IO Port: 0xe408
Built 1 zonelists
current: c031ea60current->thread_info: c0386000
Initializing CPU#0
Kernel command line: BOOT_IMAGE=2.6 ro root=305 resume=/dev/hda1 acpi_sleep=s3_bios clock=pmtmr PID hash table entries: 1024 (order 10: 8192 bytes)
Detected 1700.567 MHz processor.
Using pmtmr for high-res timesource
Console: colour VGA+ 80x25
Memory: 255896k/262116k available (1878k kernel code, 5512k reserved, 704k data, 132k init, 0k highmem) Calibrating delay loop... 8.19 BogoMIPS
#v-
FYI, it was around 1700 BogoMIPS with 2.6.1-mm4 (using pmtmr). Best regards,
Signature · 2 lines
Karol 'sziwan' Kozimor [email protected]