Peformance issues with r278325
K. Macy
kmacy at freebsd.org
Fri Mar 18 20:11:16 UTC 2016
On Friday, March 18, 2016, John Baldwin <jhb at freebsd.org> wrote:
> 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
> <javascript:;>> wrote:
> > >
> > > On Fri, Mar 18, 2016 at 1:37 PM, John Baldwin <jhb at freebsd.org
> <javascript:;>> 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();
> }
>
>
>
In a VM the thread is pinned to the _vcpu_. You have no control over what
physical core the underlying thread is running on. If the vcpu is migrated
to a different package there is a possibility of the next TSC reading be a
lower value. The rdtsc instruction reads the value of the physical core.
Although I doubt this is a problem in practice, it is a possibility if
vcpus are not pinned for the lifetime of the VM.
-M
> John Baldwin
> _______________________________________________
> freebsd-hackers at freebsd.org <javascript:;> mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org
> <javascript:;>"
>
More information about the freebsd-hackers
mailing list