From owner-freebsd-net@FreeBSD.ORG Mon Jan 14 22:12:18 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C6E7A9C4; Mon, 14 Jan 2013 22:12:18 +0000 (UTC) (envelope-from bryanv@daemoninthecloset.org) Received: from torment.daemoninthecloset.org (ip-static-94-242-209-234.as5577.net [94.242.209.234]) by mx1.freebsd.org (Postfix) with ESMTP id 5BBBFEAD; Mon, 14 Jan 2013 22:12:17 +0000 (UTC) Received: from sage.daemoninthecloset.org (unknown [70.114.209.60]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "sage.daemoninthecloset.org", Issuer "daemoninthecloset.org" (verified OK)) by torment.daemoninthecloset.org (Postfix) with ESMTPS id 7F86542C0858; Mon, 14 Jan 2013 23:14:14 +0100 (CET) X-Virus-Scanned: amavisd-new at daemoninthecloset.org Received: from sage.daemoninthecloset.org (sage.daemoninthecloset.org [127.0.1.1]) by sage.daemoninthecloset.org (Postfix) with ESMTP id 35D607AF0E; Mon, 14 Jan 2013 16:12:10 -0600 (CST) Date: Mon, 14 Jan 2013 16:12:09 -0600 (CST) From: Bryan Venteicher To: John Baldwin Message-ID: <1893331462.132.1358201529856.JavaMail.root@daemoninthecloset.org> In-Reply-To: <201301141657.58727.jhb@freebsd.org> Subject: Re: To SMP or not to SMP MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.51.1.14] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC23 (Mac)/7.2.0_GA_2669) Cc: Konstantin Belousov , freebsd-net@freebsd.org, Peter Jeremy X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2013 22:12:18 -0000 ----- Original Message ----- > From: "John Baldwin" > To: freebsd-net@freebsd.org > Cc: "Konstantin Belousov" , "Bryan Venteicher" , "Peter Jeremy" > > Sent: Monday, January 14, 2013 3:57:58 PM > Subject: Re: To SMP or not to SMP > > On Monday, January 14, 2013 4:07:56 pm Konstantin Belousov wrote: > > 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: > > > > > > > > ----- Original Message ----- > > > > > From: "John Baldwin" > > > > > To: freebsd-net@freebsd.org > > > > > Cc: "Barney Cordoba" , "Peter > > > > > Jeremy" > > > > > > Sent: Friday, January 11, 2013 9:39:17 AM > > > > > Subject: Re: To SMP or not to SMP > > > > > > > > > > On Thursday, January 10, 2013 02:36:59 PM Peter Jeremy wrote: > > > > > > On 2013-Jan-07 18:25:58 -0800, Barney Cordoba > > > > > > > > > > > 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? > > > > > > > > > > > > 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. > > > > > > > > > > Presumably a locked atomic op is cheaper than a function call > > > > > then? > > > > > The > > > > > current setup assumes the opposite. > > > > > > > > > > I think we should actually do this for atomics in modules on > > > > > x86: > > > > > > > > > > 1) If a module is built standalone, it should do whichever is > > > > > cheaper: > > > > > a function call or always use "LOCK". > > > > > > > > > > 2) If a module is built as part of the kernel build, it > > > > > should use > inlined > > > > > 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. > > > > > > > > > > > > > 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. > > Could you please, clarify why does UP kernel needs it ? > > Shouldn't the hypervisor context switching provide neccessary > > serialization > > anyway ? > > I thought this, too, but in the case of virtio you are presumably > sychronizing with other threads in the hypervisor itself which might > be running concurrently on another physical CPU. > Yes, that is the case to be concerned about. Although, thinking about this a bit more, in VirtIO (at least the current spec), all the shared fields are updated by either the host or guest, not both, so a UP kernel can get by without the LOCK, correct? > -- > John Baldwin >