From owner-freebsd-current Mon Nov 25 14:44:30 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2519537B404; Mon, 25 Nov 2002 14:44:29 -0800 (PST) Received: from tesla.distributel.net (nat.MTL.distributel.NET [66.38.181.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id F1C6343EA9; Mon, 25 Nov 2002 14:44:27 -0800 (PST) (envelope-from bmilekic@unixdaemons.com) Received: (from bmilekic@localhost) by tesla.distributel.net (8.11.6/8.11.6) id gAPMhFN75898; Mon, 25 Nov 2002 17:43:15 -0500 (EST) (envelope-from bmilekic@unixdaemons.com) Date: Mon, 25 Nov 2002 17:43:15 -0500 From: Bosko Milekic To: Andrew Gallatin Cc: Julian Elischer , Robert Watson , Luigi Rizzo , current@freebsd.org Subject: Re: mbuf header bloat ? Message-ID: <20021125174315.C75673@unixdaemons.com> References: <15840.8629.324788.887872@grasshopper.cs.duke.edu> <15841.17237.826666.653505@grasshopper.cs.duke.edu> <20021125130005.A75177@unixdaemons.com> <15842.27547.385354.151541@grasshopper.cs.duke.edu> <20021125160122.A75673@unixdaemons.com> <15842.37927.919140.910293@grasshopper.cs.duke.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <15842.37927.919140.910293@grasshopper.cs.duke.edu>; from gallatin@cs.duke.edu on Mon, Nov 25, 2002 at 04:20:39PM -0500 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Nov 25, 2002 at 04:20:39PM -0500, Andrew Gallatin wrote: > I'm not sure what you mean. The problem is that Giant inhibits > scaling on SMPs and I want to get all network drivers out from under > it, not just mine. > > Requiring Giant for mbuf allocations effectivly defeats your elegant, > cleverly designed mbuf allocator with lock-free per-cpu caches, etc. > And it introduces all kinds of windows for races and locking errors if > SMP safe drivers must drop all their mutexes and grab Giant for mbuf > allocations. > > And you cannot grab Giant inside the mbuf allocation code itself > because the mutex rules prohibit acquiring Giant while holding any > other locks. From mutex(9): > > Giant > If Giant must be acquired, it must be acquired prior to acquiring other > mutexes. Put another way: it is impossible to acquire Giant non-recur- > sively while holding another mutex. It is possible to acquire other > mutexes while holding Giant, and it is possible to acquire Giant recur- > sively while holding other mutexes. Well, first of all, I never call kmem_malloc() with any locks held so this argument about grabbing Giant while other locks are held is not applicable in my case. Given that you call the allocator with locks held, then you should only be doing so with M_DONTWAIT as an M_TRYWAIT call may result in a call to m_drain() which - if you are holding any locks - may lead to lock order reversals. So given that you can only call the allocator with M_DONTWAIT for device drivers or any other code paths holding locks, then it would make sense to just make the M_DONTWAIT case never call the VM routines as well. Either that, or make sure that a call to kmem_malloc() with M_DONTWAIT can do its job without requiring Giant (is this possible?) > Emperically, I vaguely remember marking my driver as SMP safe (with > witness and invariants off, of course) provided something like a > 30-40% performance increase on a dual 1GHz PIII system. It was still > not as fast as stable, but the current/stable performance difference > was no longer embarrassing. > > Drew > -- Bosko Milekic * bmilekic@unixdaemons.com * bmilekic@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message