Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jan 2013 23:07:56 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bryan Venteicher <bryanv@daemoninthecloset.org>
Cc:        freebsd-net@freebsd.org, Peter Jeremy <peter@rulingia.com>, John Baldwin <jhb@freebsd.org>
Subject:   Re: To SMP or not to SMP
Message-ID:  <20130114210756.GM2561@kib.kiev.ua>
In-Reply-To: <201301141507.50250.jhb@freebsd.org>
References:  <330287752.17.1358057713463.JavaMail.root@daemoninthecloset.org> <201301141507.50250.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--5dzPFofyJ6dbelGf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jan 14, 2013 at 03:07:50PM -0500, John Baldwin wrote:
> On Sunday, January 13, 2013 1:15:13 am Bryan Venteicher wrote:
> >=20
> > ----- Original Message -----
> > > From: "John Baldwin" <jhb@freebsd.org>
> > > To: freebsd-net@freebsd.org
> > > Cc: "Barney Cordoba" <barney_cordoba@yahoo.com>, "Peter Jeremy" <pete=
r@rulingia.com>
> > > Sent: Friday, January 11, 2013 9:39:17 AM
> > > Subject: Re: To SMP or not to SMP
> > >=20
> > > On Thursday, January 10, 2013 02:36:59 PM Peter Jeremy wrote:
> > > > On 2013-Jan-07 18:25:58 -0800, Barney Cordoba
> > > > <barney_cordoba@yahoo.com>
> > > wrote:
> > > > >I have a situation where I have to run 9.1 on an old single core
> > > > >box. Does anyone have a handle on whether it's better to build a
> > > > >non
> > > > >SMP kernel or to just use a standard SMP build with just the one
> > > > >core?
> > > >=20
> > > > Another input for this decision is kern/173322.  Currently on x86,
> > > > atomic operations within kernel modules are implemented using calls
> > > > to code in the kernel, which do or don't use lock prefixes
> > > > depending
> > > > on whethur the kernel was built as SMP.  My proposed change changes
> > > > kernel modules to inline atomic operations but always include lock
> > > > prefixes (effectively reverting r49999).  I'm appreciate anyone who
> > > > feels like testing the impact of this change.
> > >=20
> > > Presumably a locked atomic op is cheaper than a function call then?
> > >  The
> > > current setup assumes the opposite.
> > >=20
> > > I think we should actually do this for atomics in modules on x86:
> > >=20
> > > 1) If a module is built standalone, it should do whichever is cheaper:
> > >    a function call or always use "LOCK".
> > >=20
> > > 2) If a module is built as part of the kernel build, it should use in=
lined
> > >    atomics that match what the kernel does.  Thus, modules built with=
 a
> > >    non-SMP kernel would use inlined atomic ops that do not use LOCK. =
 We
> > >    have a way to detect this now (some HAVE_FOO #define added in the =
past
> > >    few years) that we didn't back when this bit of atomic.h was
> > >    written.
> > >
> >=20
> > It would be nice to have the LOCK variants available even on UP
> > kernels in non-hackish way. For VirtIO, we need to handle an guest
> > UP kernel running on an SMP host. Whether this is an #define that
> > forces the SMP atomics to be inlined, or if they're exposed with
> > an _smp suffix.=20
Could you please, clarify why does UP kernel needs it ?
Shouldn't the hypervisor context switching provide neccessary serialization
anyway ?

> >=20
> > VirtIO currently uses mb() to enforce ordering. I have a patch
> > to change to use atomic(9), but can only do so when VirtIO is
> > included in the an SMP kernel (among other constraints - must
> > have 16-bit atomic operations too).
> >=20
> > (FreeBSD's VirtIO is x86 only for now - but that will be changing
> > soon; I haven't looked if other arch's atomic(9) behave differently
> > for UP/SMP.)
>=20
> Only x86 does this weirdness.  The simplest workaround might be to require
> guest kernels to be compiled with SMP for now.
>=20
> --=20
> John Baldwin
> _______________________________________________
> freebsd-net@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"

--5dzPFofyJ6dbelGf
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQIcBAEBAgAGBQJQ9HOsAAoJEJDCuSvBvK1B56gP/0iKE8Dz7UabdPih8xmRPu96
9tVVCaaM7XC4Jr+JnO53WRuajrbj+XUETvNp81SQXxB9+4XJtpVLDyoHFOXKlMTV
kvCGYX2mgxuy/oyQaEvSEc0XpPEfxEV4DZ/7q3dtWFumQEhwYXElDMS9E/z+3zgx
5k5JeRX4U5BmratmzNmcEwRedmSuxxh5bFmbmSFkykiWyYU0jLMzMGJWwXVoNEFJ
R2Tk1Gr8M/+oHko6IjMyyiwFRr+FgP+wMB3KJfPQaZl6hLfxLWlmwM1hTuyVOeQZ
+jWHPwcS+DUMJQuD0oSSc7y3DOeSTCjQZACJI1syBWgi9SsysiF2Hf0KC+/F8FtT
L/HCFRPrSlCOpQEtBQHGFy3Ywzz8abpam7cViaJYWPsnxgd6CssDde4waLUZKUa+
iJRwtjVpmTnvtac37illdqkfhAWMNucp7w/BD+2S0O4s4GFUZvhG2wziNwmjEY8Z
u2CGcKoYNN7Xi9QWR3x6iZdFEr4dV7FPePT6cHq5PzXoz2AmZgl0aSiw0UZmuffI
sR8vrYsy2xfqaYAjpriEymGaPw1UVLoFR9nGjb4IVPE39TC9ip5n1Sv5DvhmtGkB
d2DUMzu1rURskZz0S/CC1aHc+rSyt7bwNmJZ0tlp+nW9GIg/WES7qZKNfhLTYqo+
rD2AmuUkRhWmhNbxuWoH
=V+NN
-----END PGP SIGNATURE-----

--5dzPFofyJ6dbelGf--



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