From owner-svn-src-all@freebsd.org Mon Mar 21 18:15:57 2016 Return-Path: Delivered-To: svn-src-all@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 38F31AD8DC8; Mon, 21 Mar 2016 18:15:57 +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 136291AD7; Mon, 21 Mar 2016 18:15:57 +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 253D7B9C5; Mon, 21 Mar 2016 14:15:56 -0400 (EDT) From: John Baldwin To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r297039 - head/sys/x86/x86 Date: Mon, 21 Mar 2016 11:12:57 -0700 Message-ID: <1866602.Bp7VFd5f42@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <20160319032216.GZ1741@kib.kiev.ua> References: <201603181948.u2IJmndg063765@repo.freebsd.org> <20160319032216.GZ1741@kib.kiev.ua> 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); Mon, 21 Mar 2016 14:15:56 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2016 18:15:57 -0000 On Saturday, March 19, 2016 05:22:16 AM Konstantin Belousov wrote: > On Fri, Mar 18, 2016 at 07:48:49PM +0000, John Baldwin wrote: > > > > - for (x = 0; x < delay; x += 5) { > > + for (x = 0; x < delay; x++) { > > if ((lapic_read_icr_lo() & APIC_DELSTAT_MASK) == > > APIC_DELSTAT_IDLE) > > return (1); > > - DELAY(5); > > + DELAY(1); > > } > > return (0); > > } > > Ideally we would structure the loop differently. I think it is more > efficient WRT latency to only block execution by ia32_pause(), and > compare the the getbinuptime() results to calculate spent time, on each > loop step. Yes. I've thought about using the TSC directly to do that, but folks are worried about the TSC being unstable due to vcpus in a VM migrating across physical CPUs. DELAY() does seem to DTRT in that case assuming the hypervisor doesn't advertise an invariant TSC via cpuid. We'd have to essentially duplicate DELAY() (really delay_tc()) inline. -- John Baldwin