From owner-freebsd-current@FreeBSD.ORG Fri Apr 4 07:03:37 2003 Return-Path: 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 7F0F337B401; Fri, 4 Apr 2003 07:03:37 -0800 (PST) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8486343F93; Fri, 4 Apr 2003 07:03:36 -0800 (PST) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.12.9/8.12.9) with ESMTP id h34F3ZMS027071 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 4 Apr 2003 10:03:36 -0500 (EST) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.11.6/8.9.1) id h34F3UT34041; Fri, 4 Apr 2003 10:03:30 -0500 (EST) (envelope-from gallatin@cs.duke.edu) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16013.40642.784712.453084@grasshopper.cs.duke.edu> Date: Fri, 4 Apr 2003 10:03:30 -0500 (EST) To: Nate Lawson In-Reply-To: References: <16012.32534.331966.216694@grasshopper.cs.duke.edu> X-Mailer: VM 6.75 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid cc: jeffr@freebsd.org cc: current@freebsd.org cc: jake@freebsd.org Subject: Giant required by uma (was Re: mbuf LOR) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2003 15:03:37 -0000 Nate Lawson writes: > > You're right about where the problem is (top of stack trace and listing > below). However, your patch causes an immediate panic on boot due to a > NULL deref. I don't think you want it to always return NULL if called > with M_NOWAIT set. :) Other ideas? > I suppose the only alternative is to "do it right" and remove Giant from the uma zone alloc code. >From looking at the code for a little while this morning, it looks like there are 3 allocators that could be called at this point in the code: 1) page_alloc(): Calls kmem_malloc(). Should be MPSAFE on NOWAIT allocations. Needs Giant on WAITOK allocations. 2) obj_alloc(): Calls vm_page_alloc() -- that's MPSAFE. Calls pmap_qenter() -- I've got no freaking clue if that's MPSAFE on all platforms. I think it is, since kmem_malloc is MPSAFE & it calls pmap_enter(), but I'm not sure. uma_small_alloc(): i386 - no uma_small_alloc, no problem alpha - uma_small_alloc is SMP safe ia64 - uma_small_alloc should be SMP safe, as it seems to be doing just the moral equivalent of PHYS_TO_K0SEG() to map the memory into the kernel. sparc64: I have no idea.. Drew > slab_zalloc + 0xdf > uma_zone_slab + 0xd8 > uma_zalloc_bucket + 0x15d > uma_zalloc_arg + 0x307 > malloc > ... > m_getcl > > (gdb) l *slab_zalloc+0xdf > 0xc02f646f is in slab_zalloc (../../../vm/uma_core.c:707). > 702 else > 703 wait &= ~M_ZERO; > 704 > 705 if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) { > 706 mtx_lock(&Giant); > 707 mem = zone->uz_allocf(zone, > 708 zone->uz_ppera * UMA_SLAB_SIZE, &flags, wait); > 709 mtx_unlock(&Giant); > 710 if (mem == NULL) { > 711 ZONE_LOCK(zone);