Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2016 11:12:57 -0700
From:      John Baldwin <jhb@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r297039 - head/sys/x86/x86
Message-ID:  <1866602.Bp7VFd5f42@ralph.baldwin.cx>
In-Reply-To: <20160319032216.GZ1741@kib.kiev.ua>
References:  <201603181948.u2IJmndg063765@repo.freebsd.org> <20160319032216.GZ1741@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1866602.Bp7VFd5f42>