From owner-freebsd-current@freebsd.org Sun Jan 15 20:20:21 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65909CB12B8 for ; Sun, 15 Jan 2017 20:20:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E9431A65 for ; Sun, 15 Jan 2017 20:20:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v0FKK9EA054382 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 15 Jan 2017 22:20:09 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v0FKK9EA054382 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v0FKK9qu054379; Sun, 15 Jan 2017 22:20:09 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 15 Jan 2017 22:20:09 +0200 From: Konstantin Belousov To: Jia-Shiun Li Cc: freebsd-current Subject: Re: TSC as timecounter makes system lag Message-ID: <20170115202008.GL2349@kib.kiev.ua> References: <20170113120534.GC2349@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jan 2017 20:20:21 -0000 On Sun, Jan 15, 2017 at 10:35:26PM +0800, Jia-Shiun Li wrote: > Sorry just saw this. Bad Gmail. > > > On Fri, Jan 13, 2017 at 8:05 PM, Konstantin Belousov > 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@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 > APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI, > > MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> > > > > > > Features2=0xc00e39d > SSSE3,CX16,xTPR,PDCM,XSAVE,OSXSAVE> > > > AMD Features=0x20100800 > > > AMD Features2=0x1 > > > 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. I still do not understand. Is the sysctl output below from the pristine boot where no timecounter/eventtimer reconfiguration were done ? Show me exact command which you used to revive the machine. Do not describe it by words, copy/paste from the console. > > -Jia-Shiun. > 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 > 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@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 > Features2=0xc00e39d > AMD Features=0x20100800 > AMD Features2=0x1 > TSC: P-state invariant, performance statistics > real memory = 4294967296 (4096 MB) > avail memory = 4088070144 (3898 MB) > Event timer "LAPIC" quality 100 > ACPI APIC Table: > 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 irqs 0-23 on motherboard > SMP: AP CPU #1 Launched! This is not a verbose dmesg.