From owner-freebsd-hackers@freebsd.org Thu Oct 29 12:33:44 2015 Return-Path: Delivered-To: freebsd-hackers@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 A6F39A123B4 for ; Thu, 29 Oct 2015 12:33:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C00E81BF9; Thu, 29 Oct 2015 12:33:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id t9TCXcQw049685 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 29 Oct 2015 14:33:38 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua t9TCXcQw049685 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id t9TCXc85049684; Thu, 29 Oct 2015 14:33:38 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 29 Oct 2015 14:33:38 +0200 From: Konstantin Belousov To: Andriy Gapon Cc: Alexander Motin , freebsd-hackers , Poul-Henning Kamp , Jung-uk Kim Subject: Re: instability of timekeeping Message-ID: <20151029123338.GU2257@kib.kiev.ua> References: <56261398.60102@FreeBSD.org> <56261FE6.90302@FreeBSD.org> <56274FFC.2000608@FreeBSD.org> <20151021184850.GX2257@kib.kiev.ua> <562F3E2F.2010100@FreeBSD.org> <20151027115810.GU2257@kib.kiev.ua> <562F8109.4050203@FreeBSD.org> <20151027140403.GB2257@kib.kiev.ua> <5630FC3B.2070908@FreeBSD.org> <5631FB66.4000007@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5631FB66.4000007@FreeBSD.org> User-Agent: Mutt/1.5.24 (2015-08-30) 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-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2015 12:33:44 -0000 On Thu, Oct 29, 2015 at 12:56:38PM +0200, Andriy Gapon wrote: > On 28/10/2015 18:47, Andriy Gapon wrote: > > In either case I am going to add a few more trace points in et_start and the > > HPET timer code and see if I can catch anything interesting there. > > Okay, more data: > https://people.freebsd.org/~avg/timekeeping-ktr.2.patch > https://people.freebsd.org/~avg/timekeeping.2.ktrdump.txt > > I think that the snippet (amended with some notes of mine) makes it painfully > obvious that the timer interrupt got very delayed when all CPUs entered the idle > state. > I do not see anything that could suggest a FreeBSD bug. > > There is another sad discovery. Turns out that my CPU model provides two ways > of doing C1E magic. The sane one: the north bridge logic in the CPU performs a > read of a configured LVL3 register so that C3 is entered. The insane one: the > CPU NB performs a write of a configured value to a configured SMI register, so > that the SMI is generated and an SMM handler does the job (probably reading from > LVL2 or LVL3). Looking at MSR C001_0055 I see that my BIOS has chosen the > insane approach[*], quite unfortunately. Bugs in the SMM code are not unheard > of, to put it mildly, so that could be an explanation for my problem. > > So, I guess I'll just disable C1E and end this investigation. > > [*] > $ cpucontrol -m 0xc0010055 /dev/cpuctl0 > > > MSR 0xc0010055: 0x00000000 0x083400b0 > > SmiOnCmpHalt: SMI on chip multi-processing halt. > - write 0x34 to port 0xb0 What if you enable C3 (in OS, and possibly BIOS), but disable C1E ? Does the issue with jitter persist ?