From owner-freebsd-hackers@freebsd.org Fri Mar 18 19:56:22 2016 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 57F8CAD5823 for ; Fri, 18 Mar 2016 19:56:22 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::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 38B8F1BC7; Fri, 18 Mar 2016 19:56:22 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 4FD48B93A; Fri, 18 Mar 2016 15:56:21 -0400 (EDT) From: John Baldwin To: Stanislav Sedov Cc: Ryan Stone , Adrian Chadd , Konstantin Belousov , "freebsd-hackers@freebsd.org" Subject: Re: Peformance issues with r278325 Date: Fri, 18 Mar 2016 12:38:42 -0700 Message-ID: <3213721.SRyKE0LtiG@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <59BA610B-3754-43D6-839D-84FEE8F13CF7@FreeBSD.org> References: <59BA610B-3754-43D6-839D-84FEE8F13CF7@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 18 Mar 2016 15:56:21 -0400 (EDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2016 19:56:22 -0000 On Friday, March 18, 2016 11:58:19 AM Stanislav Sedov wrote: > > > On Mar 18, 2016, at 11:49 AM, Ryan Stone wrote: > > > > On Fri, Mar 18, 2016 at 1:37 PM, John Baldwin wrote: > > I think I'll likely just convert it to use a direct > > TSC delay loop always in HEAD (assuming that verifies ok in testing as well). > > > > Couldn't that work incorrectly on VM guests? The tsc is not guaranteed to be monotonic in that environment. > > > > Another concern is SMP systems where the clock is not synchronized. SMP TSC requires > a complicated setup procedure on the system boot which is not followed properly by all > vendors, and I have seen some recent systems with SMP TSC skew. > > I'm afraid that using TSC in this code will make FreeBSD unusable on such (arguably buggy) > systems. Eh, SMP does not matter here. DELAY() already uses TSC on FreeBSD. The current thread is pinned to a single CPU in lapic_ipi_wait(). The idea would be to do this: deadline = rdtsc() + freq * delay / 1000000; while (rdtsc() < deadline) { if (APIC_DELSTAT_IDLE) return (1); ia32_pause(); } -- John Baldwin