From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 9 00:30:25 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AD6516A420 for ; Wed, 9 Jan 2008 00:30:25 +0000 (UTC) (envelope-from kris@FreeBSD.org) Received: from weak.local (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 72C1713C467; Wed, 9 Jan 2008 00:30:24 +0000 (UTC) (envelope-from kris@FreeBSD.org) Message-ID: <4784159E.9040905@FreeBSD.org> Date: Wed, 09 Jan 2008 01:30:22 +0100 From: Kris Kennaway User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Bharma Ji References: <67beabb0801081555v4ca3b729x294322fa724afa09@mail.gmail.com> In-Reply-To: <67beabb0801081555v4ca3b729x294322fa724afa09@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Graceful failure instead of panicking in kmem_malloc X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2008 00:30:25 -0000 Bharma Ji wrote: > In FreeBSD 6_2, if kmem_malloc is unable to find space it panics. The > relevant code is in vm_kern.c > if ((flags & M_NOWAIT) == 0) > panic("kmem_malloc(%ld): kmem_map too small: %ld > total allocated", > (long)size, (long)map->size); > > Is there any way to make the system log and then gracefully shut off instead > of panicking? Not really, because those actions require memory allocation. The real fix is to either a) avoid running out of memory in the first place by tuning vm.kmem_size b) perhaps trying harder to avoid panicking by first trying to more aggressively reclaim memory. You can try http://www.freebsd.org/~pjd/patches/vm_kern.c.2.patch which implements b) (patch against 7.0, but might apply to 6.2 unchanged). Kris