From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 9 03:25:21 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 2A3A616A417 for ; Wed, 9 Jan 2008 03:25:20 +0000 (UTC) (envelope-from bharmaji@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.155]) by mx1.freebsd.org (Postfix) with ESMTP id 5D6D413C447 for ; Wed, 9 Jan 2008 03:25:19 +0000 (UTC) (envelope-from bharmaji@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so81769fgg.35 for ; Tue, 08 Jan 2008 19:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=wA+EBlI6BdRSTq/5gERSMOSe1kks+5EzvI5UQtHY7Y8=; b=hpMG+jbnAEoMzpIIgqbKRqWya9wQt2K67922zNobDV5LuGYZfB0VMxjqkc8nVyXAKFQztR2rPCuKegaDK+rz0BVc5fkXWrRTvJmgzwnNiXO4WMq+fJrasnFpd7aQ3kZJ7smJUlXPG9GcdT5wPmszs86hEbfEA3RXeKFwvfLoq6k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=E4bC9qnA9QitIOlOwgrgECTvbGSeOXwfM8/6NcMW0dRMKXSXrsXv5XJ/Ps3JeATIbPDhItli+IxbvpqI8WeQ4JSCqLSxI4SIt0Loe3N3qL8lXtnWuUP04bFA3X2xqb+Dgp6NwtT82Qh5tppfkwL8sGnelFNeidt7tGHWZdUh8D4= Received: by 10.78.81.20 with SMTP id e20mr51178hub.60.1199849117928; Tue, 08 Jan 2008 19:25:17 -0800 (PST) Received: by 10.78.130.18 with HTTP; Tue, 8 Jan 2008 19:25:17 -0800 (PST) Message-ID: <67beabb0801081925t67f995b8hc4cc779f88c2ba@mail.gmail.com> Date: Tue, 8 Jan 2008 19:25:17 -0800 From: "Bharma Ji" To: "Kris Kennaway" In-Reply-To: <4784159E.9040905@FreeBSD.org> MIME-Version: 1.0 References: <67beabb0801081555v4ca3b729x294322fa724afa09@mail.gmail.com> <4784159E.9040905@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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 03:25:21 -0000 Thanks for the response. I am hoping to keep some memory aside specifically for handling out of memory allocation situations. Yes the real fix is to avoid out of memory allocation. Thanks for the patch. Will try that. As a first cut I am just trying to handle failure gracefully. So asking again - if there is any way already discussed or standardized to make the system handle failures gracefully On Jan 8, 2008 4:30 PM, Kris Kennaway wrote: > 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 >