Peformance issues with r278325

John Baldwin jhb at freebsd.org
Fri Mar 18 19:56:22 UTC 2016


On Friday, March 18, 2016 11:58:19 AM Stanislav Sedov wrote:
> 
> > On Mar 18, 2016, at 11:49 AM, Ryan Stone <rysto32 at gmail.com> wrote:
> > 
> > On Fri, Mar 18, 2016 at 1:37 PM, John Baldwin <jhb at freebsd.org> 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


More information about the freebsd-hackers mailing list