From owner-freebsd-bugs Mon Oct 12 12:40:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA23094 for freebsd-bugs-outgoing; Mon, 12 Oct 1998 12:40:04 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA23040 for ; Mon, 12 Oct 1998 12:39:59 -0700 (PDT) (envelope-from dag-erli@ifi.uio.no) Received: from hall.ifi.uio.no (2602@hall.ifi.uio.no [129.240.65.11]) by ifi.uio.no (8.8.8/8.8.7/ifi0.2) with SMTP id VAA25036; Mon, 12 Oct 1998 21:39:34 +0200 (MET DST) Received: from localhost (dag-erli@localhost) by hall.ifi.uio.no ; Mon, 12 Oct 1998 19:39:32 GMT Mime-Version: 1.0 To: dg@root.com Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory' References: <199810121931.MAA02205@implode.root.com> Organization: University of Oslo, Department of Informatics X-url: http://www.stud.ifi.uio.no/~dag-erli/ X-other-addresses: 'finger dag-erli@ifi.uio.no' for a list X-disclaimer-1: The views expressed in this article are mine alone, and do X-disclaimer-2: not necessarily coincide with those of any organisation or X-disclaimer-3: company with which I am or have been affiliated. X-Stop-Spam: http://www.cauce.org/ From: dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?= ) Date: 12 Oct 1998 21:39:28 +0200 In-Reply-To: David Greenman's message of "Mon, 12 Oct 1998 12:31:08 -0700" Message-ID: Lines: 41 X-Mailer: Gnus v5.5/Emacs 19.34 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.freebsd.org id MAA23066 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org David Greenman writes: > It should pad "size" with a few processes worth (perhaps increase it by > 10%...size += size / 10). Yes. Do I have your approval to commit the following patch: Index: kvm_proc.c =================================================================== RCS file: /home/ncvs/src/lib/libkvm/kvm_proc.c,v retrieving revision 1.21 diff -u -r1.21 kvm_proc.c --- kvm_proc.c 1998/09/16 04:17:46 1.21 +++ kvm_proc.c 1998/10/12 19:39:14 @@ -302,10 +302,16 @@ _kvm_syserr(kd, kd->program, "kvm_getprocs"); return (0); } - kd->procbase = (struct kinfo_proc *)_kvm_malloc(kd, size); - if (kd->procbase == 0) - return (0); - st = sysctl(mib, op == KERN_PROC_ALL ? 3 : 4, kd->procbase, &size, NULL, 0); + kd->procbase = 0; + do { + size += size / 10; + kd->procbase = (struct kinfo_proc *)_kvm_realloc(kd, + size); + if (kd->procbase == 0) + return (0); + st = sysctl(mib, op == KERN_PROC_ALL ? 3 : 4, + kd->procbase, &size, NULL, 0); + } while (st == -1 && errno == ENOMEM); if (st == -1) { _kvm_syserr(kd, kd->program, "kvm_getprocs"); return (0); DES -- Dag-Erling Smørgrav - dag-erli@ifi.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message