TSC as timecounter makes system lag

Jia-Shiun Li jiashiun at gmail.com
Sun Jan 15 14:35:58 UTC 2017


Sorry just saw this. Bad Gmail.


On Fri, Jan 13, 2017 at 8:05 PM, Konstantin Belousov <kostikbel at gmail.com>
wrote:

> On Fri, Jan 13, 2017 at 08:26:04AM +0800, Jia-Shiun Li wrote:
> > Hi all,
> >
> > since 2 or 3 weeks ago, I noticed that my old Penryn-based Intel Pentium
> > T4200 notebook lagged a lot. System time was running a lot slower,
> > sometimes even looked like it freezed. Keystroke repeat rate was slow
> too.
> >
> > Since system time is slow, I tried to change timecounter from default TSC
> > to HPET. And it resumed normal immediately.
> Please show the output of sysctl kern.timecounter and kern.eventtimer.
> I suspect that you changed eventtimer and not timecounter.
>

Files attached. I changed it by "sysctl kern.timecounter.hardware=HPET"


> The same world binary works fine on other Ivybridge and Haswell desktops,
> > so I assume this may be related to CPU or mainboard generations.
> >
> > version is
> >
> > FreeBSD jsli-nb 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r311687: Mon Jan  9
> > 04:07:27 CST 2017
> > jsli at 4cbsd:/personal/freebsd/obj/x64/personal/freebsd/
> fbsdsrc/sys/MINIMAL-NODEBUG
> > amd64
> >
> > and CPU is
> >
> > CPU: Pentium(R) Dual-Core CPU       T4200  @ 2.00GHz (1995.04-MHz
> K8-class
> > CPU)
> >   Origin="GenuineIntel"  Id=0x1067a  Family=0x6  Model=0x17  Stepping=10
> >
> > Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,
> APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,
> MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
> >
> > Features2=0xc00e39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,
> SSSE3,CX16,xTPR,PDCM,XSAVE,OSXSAVE>
> >   AMD Features=0x20100800<SYSCALL,NX,LM>
> >   AMD Features2=0x1<LAHF>
> >   TSC: P-state invariant, performance statistics
> >
> > Tested similar OS rev on another Intel Core 2 Duo E7400 Wolfdale (the
> same
> > generation as the Pentium T4200). The same lag also happens on it.
> >
> > BTW on both system, cpuX:timer interrupts do not fire at all and count
> > remains 0.
> It is known that LAPIC is shut down in C2 and deeper CPU sleep states on
> Core2.  FreeBSD 11 (and HEAD) started using MWAIT and requesting deep
> wait states from BIOS.  If the configuration uses LAPIC and deep sleeps
> are enabled, eventtimers do not work reliably.
>

> Default configuration should strongly prefer HPET eventtimer over LAPIC for
> machines which do not have LAPIC armed in Cx states, see r309189.  If you
> do not have any customizations of eventtimer selection, then please provide
> verbose dmesg from your boot.
>
> If you prefer to not use deep Cx and MWAIT, set loader tunable
> debug.acpi.disabled to include word "mwait", see acpi(4).  You can check
> that this worked by looking at sysctl dev.cpu.N output.
>

Thanks for the explanation. Looks eventtimer favored HPET over LAPIC
like you described on this notebook.

-Jia-Shiun.
-------------- next part --------------
kern.eventtimer.periodic: 0
kern.eventtimer.timer: HPET
kern.eventtimer.idletick: 0
kern.eventtimer.singlemul: 2
kern.eventtimer.choice: HPET(450) HPET1(440) HPET2(440) HPET3(440) LAPIC(100) i8254(100) RTC(0)
kern.eventtimer.et.i8254.quality: 100
kern.eventtimer.et.i8254.frequency: 1193182
kern.eventtimer.et.i8254.flags: 1
kern.eventtimer.et.HPET3.quality: 440
kern.eventtimer.et.HPET3.frequency: 14318180
kern.eventtimer.et.HPET3.flags: 3
kern.eventtimer.et.HPET2.quality: 440
kern.eventtimer.et.HPET2.frequency: 14318180
kern.eventtimer.et.HPET2.flags: 3
kern.eventtimer.et.HPET1.quality: 440
kern.eventtimer.et.HPET1.frequency: 14318180
kern.eventtimer.et.HPET1.flags: 3
kern.eventtimer.et.HPET.quality: 450
kern.eventtimer.et.HPET.frequency: 14318180
kern.eventtimer.et.HPET.flags: 3
kern.eventtimer.et.RTC.quality: 0
kern.eventtimer.et.RTC.frequency: 32768
kern.eventtimer.et.RTC.flags: 17
kern.eventtimer.et.LAPIC.quality: 100
kern.eventtimer.et.LAPIC.frequency: 0
kern.eventtimer.et.LAPIC.flags: 15
kern.timecounter.tsc_shift: 1
kern.timecounter.smp_tsc_adjust: 0
kern.timecounter.smp_tsc: 1
kern.timecounter.invariant_tsc: 1
kern.timecounter.fast_gettime: 1
kern.timecounter.tick: 1
kern.timecounter.choice: ACPI-fast(900) i8254(0) HPET(950) TSC(1000) dummy(-1000000)
kern.timecounter.hardware: TSC
kern.timecounter.alloweddeviation: 5
kern.timecounter.stepwarnings: 0
kern.timecounter.tc.ACPI-fast.quality: 900
kern.timecounter.tc.ACPI-fast.frequency: 3579545
kern.timecounter.tc.ACPI-fast.counter: 79078
kern.timecounter.tc.ACPI-fast.mask: 16777215
kern.timecounter.tc.i8254.quality: 0
kern.timecounter.tc.i8254.frequency: 1193182
kern.timecounter.tc.i8254.counter: 55592
kern.timecounter.tc.i8254.mask: 65535
kern.timecounter.tc.HPET.quality: 950
kern.timecounter.tc.HPET.frequency: 14318180
kern.timecounter.tc.HPET.counter: 1931486323
kern.timecounter.tc.HPET.mask: 4294967295
kern.timecounter.tc.TSC.quality: 1000
kern.timecounter.tc.TSC.frequency: 1995044550
kern.timecounter.tc.TSC.counter: 2329785074
kern.timecounter.tc.TSC.mask: 4294967295
-------------- next part --------------
Copyright (c) 1992-2017 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-CURRENT #0 r311687: Mon Jan  9 04:07:27 CST 2017
    jsli at 4cbsd:/personal/freebsd/obj/x64/personal/freebsd/fbsdsrc/sys/MINIMAL-NODEBUG amd64
FreeBSD clang version 3.9.1 (tags/RELEASE_391/final 289601) (based on LLVM 3.9.1)
VT(vga): resolution 640x480
CPU: Pentium(R) Dual-Core CPU       T4200  @ 2.00GHz (1995.04-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x1067a  Family=0x6  Model=0x17  Stepping=10
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0xc00e39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,OSXSAVE>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant, performance statistics
real memory  = 4294967296 (4096 MB)
avail memory = 4088070144 (3898 MB)
Event timer "LAPIC" quality 100
ACPI APIC Table: <ACRSYS ACRPRDCT>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s)
random: unblocking device.
ioapic0: Changing APIC ID to 4
ioapic0 <Version 2.0> irqs 0-23 on motherboard
SMP: AP CPU #1 Launched!
Timecounter "TSC" frequency 1995044550 Hz quality 1000
random: entropy device external interface
module_register_init: MOD_LOAD (vesa, 0xffffffff806ebe50, 0) error 19
kbd1 at kbdmux0
nexus0
vtvga0: <VT VGA driver> on motherboard
acpi0: <ACRSYS ACRPRDCT> on motherboard
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
atrtc0: <AT realtime clock> port 0x70-0x77 on acpi0
atrtc0: Warning: Couldn't map I/O.
Event timer "RTC" frequency 32768 Hz quality 0
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff irq 0,8 on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
Event timer "HPET" frequency 14318180 Hz quality 450
Event timer "HPET1" frequency 14318180 Hz quality 440
Event timer "HPET2" frequency 14318180 Hz quality 440
Event timer "HPET3" frequency 14318180 Hz quality 440
attimer0: <AT timer> port 0x40-0x43,0x50-0x53 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
acpi_ec0: <Embedded Controller: GPE 0x1c> port 0x62,0x66 on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pcib1: <ACPI PCI-PCI bridge> irq 16 at device 1.0 on pci0
pci1: <ACPI PCI bus> on pcib1
vgapci0: <VGA-compatible display> port 0x6000-0x607f mem 0xd2000000-0xd2ffffff,0xc0000000-0xcfffffff,0xd0000000-0xd1ffffff irq 16 at device 0.0 on pci1
acpi_video0: <ACPI video extension> on vgapci0
nvidia0: <GeForce G 105M> on vgapci0
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: Boot video device
uhci0: <Intel 82801I (ICH9) USB controller> port 0x70e0-0x70ff irq 20 at device 26.0 on pci0
usbus0 on uhci0
usbus0: 12Mbps Full Speed USB v1.0
uhci1: <Intel 82801I (ICH9) USB controller> port 0x70c0-0x70df irq 21 at device 26.1 on pci0
usbus1 on uhci1
usbus1: 12Mbps Full Speed USB v1.0
ehci0: <Intel 82801I (ICH9) USB 2.0 controller> mem 0xdb305c00-0xdb305fff irq 21 at device 26.7 on pci0
usbus2: EHCI version 1.0
usbus2 on ehci0
usbus2: 480Mbps High Speed USB v2.0
hdac0: <Intel 82801I HDA Controller> mem 0xdb300000-0xdb303fff irq 22 at device 27.0 on pci0
pcib2: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0
pci2: <ACPI PCI bus> on pcib2
pcib3: <ACPI PCI-PCI bridge> irq 16 at device 28.1 on pci0
pci3: <ACPI PCI bus> on pcib3
ath0: <Atheros 9280> mem 0xd9200000-0xd920ffff irq 17 at device 0.0 on pci3
ath0: AR9280 mac 128.2 RF5133 phy 13.0
ath0: 2GHz radio: 0x0000; 5GHz radio: 0x00c0
pcib4: <ACPI PCI-PCI bridge> irq 18 at device 28.2 on pci0
pci4: <ACPI PCI bus> on pcib4
ale0: <Atheros AR8121/AR8113/AR8114 PCIe Ethernet> port 0x2000-0x207f mem 0xd8100000-0xd813ffff irq 18 at device 0.0 on pci4
ale0: 960 Tx FIFO, 1024 Rx FIFO
ale0: Using 1 MSI messages.
miibus0: <MII bus> on ale0
atphy0: <Atheros F1 10/100/1000 PHY> PHY 0 on miibus0
atphy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto, auto-flow
ale0: Using defaults for TSO: 65518/35/2048
ale0: Ethernet address: 00:23:5a:8a:a9:3a
pcib5: <ACPI PCI-PCI bridge> irq 17 at device 28.4 on pci0
pcib5: failed to allocate initial I/O port window: 0x1000-0x1fff
pci5: <ACPI PCI bus> on pcib5
sdhci_pci0: <JMicron JMB38X SD> mem 0xd7000200-0xd70002ff irq 16 at device 0.2 on pci5
sdhci_pci0: 1 slot(s) allocated
uhci2: <Intel 82801I (ICH9) USB controller> port 0x70a0-0x70bf irq 23 at device 29.0 on pci0
usbus3 on uhci2
usbus3: 12Mbps Full Speed USB v1.0
uhci3: <Intel 82801I (ICH9) USB controller> port 0x7080-0x709f irq 19 at device 29.1 on pci0
usbus4 on uhci3
usbus4: 12Mbps Full Speed USB v1.0
uhci4: <Intel 82801I (ICH9) USB controller> port 0x7060-0x707f irq 20 at device 29.2 on pci0
usbus5 on uhci4
usbus5: 12Mbps Full Speed USB v1.0
uhci5: <Intel 82801I (ICH9) USB controller> port 0x7040-0x705f irq 18 at device 29.3 on pci0
usbus6 on uhci5
usbus6: 12Mbps Full Speed USB v1.0
ehci1: <Intel 82801I (ICH9) USB 2.0 controller> mem 0xdb305800-0xdb305bff irq 23 at device 29.7 on pci0
usbus7: EHCI version 1.0
usbus7 on ehci1
usbus7: 480Mbps High Speed USB v2.0
pcib6: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci6: <ACPI PCI bus> on pcib6
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
ahci0: <Intel ICH9M AHCI SATA controller> port 0x7108-0x710f,0x7114-0x7117,0x7100-0x7107,0x7110-0x7113,0x7020-0x703f mem 0xdb305000-0xdb3057ff irq 19 at device 31.2 on pci0
ahci0: AHCI v1.20 with 4 3Gbps ports, Port Multiplier supported
ahcich0: <AHCI channel> at channel 0 on ahci0
ahcich1: <AHCI channel> at channel 1 on ahci0
ahciem0: <AHCI enclosure management bridge> on ahci0
ichsmb0: <Intel 82801I (ICH9) SMBus controller> port 0x7000-0x701f mem 0xdb306000-0xdb3060ff irq 18 at device 31.3 on pci0
smbus0: <System Management Bus> on ichsmb0
acpi_tz0: <Thermal Zone> on acpi0
acpi_wmi0: <ACPI-WMI mapping> on acpi0
acpi_wmi1: <ACPI-WMI mapping> on acpi0
battery0: <ACPI Control Method Battery> on acpi0
acpi_acad0: <AC Adapter> on acpi0
acpi_button0: <Power Button> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_button1: <Sleep Button> on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Generic PS/2 mouse, device ID 0
orm0: <ISA Option ROM> at iomem 0xcf000-0xcffff on isa0
est0: <Enhanced SpeedStep Frequency Control> on cpu0
est1: <Enhanced SpeedStep Frequency Control> on cpu1
NULL mp in getnewvnode()
Timecounters tick every 1.000 msec
hdacc0: <Realtek ALC888 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC888 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC888 (Analog 2.0+HP/2.0)> at nid 20,21 and 24,26 on hdaa0
pcm1: <Realtek ALC888 (Left Digital)> at nid 30 on hdaa0
pcm2: <Realtek ALC888 (Onboard Analog Mic)> at nid 18 on hdaa0
hdacc1: <Lucent/Agere Systems (0x1040) HDA CODEC> at cad 1 on hdac0
unknown: <Lucent/Agere Systems (0x1040) HDA CODEC Modem Function Group> at nid 1 on hdacc1 (no driver attached)
hdacc2: <NVIDIA MCP78 HDA CODEC> at cad 3 on hdac0
hdaa1: <NVIDIA MCP78 Audio Function Group> at nid 1 on hdacc2
pcm3: <NVIDIA MCP78 (Digital)> at nid 5 on hdaa1
ugen6.1: <Intel UHCI root HUB> at usbus6
ugen3.1: <Intel UHCI root HUB> at usbus3
ugen0.1: <Intel UHCI root HUB> at usbus0
ugen5.1: <Intel UHCI root HUB> at usbus5
ugen4.1: <Intel UHCI root HUB> at usbus4
uhub0: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus6
uhub1: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
uhub2: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus4
uhub3: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
ugen1.1: <Intel UHCI root HUB> at usbus1
ugen2.1: <Intel EHCI root HUB> at usbus2
uhub4: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
uhub6: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus5
uhub5: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2
ugen7.1: <Intel EHCI root HUB> at usbus7
uhub7: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus7
ses0 at ahciem0 bus 0 scbus2 target 0 lun 0
ses0: <AHCI SGPIO Enclosure 1.00 0001> SEMB S-E-S 2.00 device
ses0: SEMB SES Device
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <WDC WD3200BEVT-22ZCT0 11.01A11> ATA8-ACS SATA 2.x device
ada0: Serial Number WD-WXE309VZ8559
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 305245MB (625142448 512 byte sectors)
cd0 at ahcich1 bus 0 scbus1 target 0 lun 0
cd0: <Optiarc DVD RW AD-7580S FX04> Removable CD-ROM SCSI device
cd0: Serial Number 30656330 2054208Q112
cd0: 150.000MB/s transfers (SATA 1.x, UDMA5, ATAPI 12bytes, PIO 8192bytes)
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed
Trying to mount root from ufs:/dev/ada0s3a [rw]...
uhub0: 2 ports with 2 removable, self powered
uhub1: 2 ports with 2 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub3: 2 ports with 2 removable, self powered
uhub4: 2 ports with 2 removable, self powered
uhub6: 2 ports with 2 removable, self powered
uhub5: 4 ports with 4 removable, self powered
uhub7: 8 ports with 8 removable, self powered
ugen1.2: <vendor 0x08ff Fingerprint Sensor> at usbus1
ugen7.2: <Chicony Electronics Co., Ltd. CNF7017> at usbus7
wlan0: Ethernet address: 00:17:c4:81:3c:8d
ale0: link state changed to DOWN


More information about the freebsd-current mailing list