From root@shell1.dragondata.com  Sun Oct 11 22:09:15 1998
Received: from shell1.dragondata.com (shell1.dragondata.com [204.137.237.8])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA05687
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 11 Oct 1998 22:09:14 -0700 (PDT)
          (envelope-from root@shell1.dragondata.com)
Received: (from root@localhost)
	by shell1.dragondata.com (8.8.8/8.8.8) id AAA12737;
	Mon, 12 Oct 1998 00:09:09 -0500 (CDT)
	(envelope-from root)
Message-Id: <199810120509.AAA12737@shell1.dragondata.com>
Date: Mon, 12 Oct 1998 00:09:09 -0500 (CDT)
From: "home.dragondata.com" <root@shell1.dragondata.com>
Reply-To: root@shell1.dragondata.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: w/top/etc randomly fail with 'Cannot allocate memory'
X-Send-Pr-Version: 3.2

>Number:         8275
>Category:       bin
>Synopsis:       w/top/etc randomly fail with 'Cannot allocate memory'
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 11 22:10:00 PDT 1998
>Closed-Date:    Mon Jan 4 16:16:40 PST 1999
>Last-Modified:  Mon Jan  4 16:16:56 PST 1999
>Originator:     home.dragondata.com
>Release:        FreeBSD 2.2.7-RELEASE i386
>Organization:
DragonData Internet Services
>Environment:


>Description:

bash-2.02# w
 1:09PM  up 19 days, 53 mins, 7 users, load averages: 0.01, 0.53, 0.77
USER     TTY FROM              LOGIN@  IDLE WHAT
debora   p0  p03-38.stamford. 10:13AM  2:48 -bash (bash)
tekforce p1  209-122-210-13.s 12:45PM    16 -bash (bash)
natasha  p2  205.235.55.190   Fri09AM 2days -bash (bash)
eddieb   p3  EDDIEB.uwsp.edu  12:08PM     -  (pine)
likesit  p6  gigantus.demon.n  1:03PM     5 -bash (bash)
root     p8  home             Sun06PM     - w
gigantus p9  gigantus.demon.n  1:06PM     2 -bash (bash)
You have new mail in /var/mail/root
bash-2.02# w
 1:10PM  up 19 days, 54 mins, 7 users, load averages: 0.08, 0.48, 0.73
USER     TTY FROM              LOGIN@  IDLE WHAT
w: kvm_getprocs: Cannot allocate memory: Cannot allocate memory
bash-2.02# w
 1:10PM  up 19 days, 54 mins, 7 users, load averages: 0.08, 0.48, 0.73
USER     TTY FROM              LOGIN@  IDLE WHAT
debora   p0  p03-38.stamford. 10:13AM  2:49 -bash (bash)
tekforce p1  209-122-210-13.s 12:45PM    17 -bash (bash)
natasha  p2  205.235.55.190   Fri09AM 2days -bash (bash)
eddieb   p3  EDDIEB.uwsp.edu  12:08PM     - -bash (bash)
likesit  p6  gigantus.demon.n  1:03PM     5 -bash (bash)
root     p8  home             Sun06PM     - w
gigantus p9  gigantus.demon.n  1:06PM     - pico freebee


>How-To-Repeat:

Keep hitting 'w' over and over on a busy box.

>Fix:
	
Not sure, if someone has any clues, let me know and I'll start looking
though.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Mon Oct 12 06:08:53 PDT 1998 
State-Changed-Why:  
Not a bug. 

From: dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?= )
To: root@shell1.dragondata.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory'
Date: 12 Oct 1998 15:08:24 +0200

 "home.dragondata.com" <root@shell1.dragondata.com> writes:
 > bash-2.02# w
 >  1:10PM  up 19 days, 54 mins, 7 users, load averages: 0.08, 0.48, 0.73
 > USER     TTY FROM              LOGIN@  IDLE WHAT
 > w: kvm_getprocs: Cannot allocate memory: Cannot allocate memory
                    ^^^^^^^^^^^^^^^^^^^^^^
 
 can.not ()
 ('kan-(.){a:}t; k*-'n{a:}t, ka-')
    can not
  -- cannot but   to be bound to: MUST
 
 
 al.lo.cate (vt)
 ('al-*-.k{a-}t)
 Etymology: ML i[allocatus], pp. of i[allocare], fr. L i[ad-] + 
    i[locare] to place, fr. i[locus] place -- more at  
    STALL]
 1) vt, to apportion for a specific purpose or to particular persons
    or things: DISTRIBUTE
 2) vt, ASSIGN, DESIGNATE
 syn. see allot;  -- al.lo.ca.tion, n
 (.al-*-'k{a-}-sh*n)
 
 
 mem.o.ry (n)
 ('mem-(*-)r{e-})
 Etymology: ME i[memorie], fr. MF i[memoire], fr. L i[memoria], 
    fr. i[memor] mindful; akin to OE i[mimorian] to remember, L 
    i[mora] delay, Gk i[merm{e-}ra] care, Skt i[smarati] 
    he remembers
 1) a) n, the power or process of reproducing or recalling what has been
       learnedand retained esp. through associative mechanisms
    b) n, persistent modification of structure or behavior resulting
       from an organism's activity or experience
    c) n, the store of things learned and retained as evidenced by
       recall and recognition
 2) a) n, commemorative remembrance
    b) n, the fact or condition of being remembered
 3) a) n, a particular act of recall or recollection
    b) n, an image or impression of someone or something remembered
    c) n, the time within which past events can be or are remembered
 4) n, a component in an electronic computing machine into which
    information can be inserted, stored, and extracted when needed
 Synonyms: i[syn] REMEMBRANCE, RECOLLECTION,  
    REMINISCENCE]; MEMORY applies both to the power of remembering 
    and to what is remembered; REMEMBRANCE applies to the act of 
    remembering or the fact of being remembered; RECOLLECTION adds 
    an implication of consciously bringing back to mind often with some 
    effort; REMINISCENCE suggests the recalling of incidents, 
    experience, or feelings from a remote past
 
 > >Fix:
 > Not sure, if someone has any clues, let me know and I'll start looking
 > though.
 
 Add more memory or swap to your computer.
 
 DES
 -- 
 Dag-Erling Smrgrav - dag-erli@ifi.uio.no

From: Kevin Day <toasty@home.dragondata.com>
To: dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?=)
Cc: root@shell1.dragondata.com, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory'
Date: Mon, 12 Oct 1998 10:57:53 -0500 (CDT)

 > "home.dragondata.com" <root@shell1.dragondata.com> writes:
 > > bash-2.02# w
 > >  1:10PM  up 19 days, 54 mins, 7 users, load averages: 0.08, 0.48, 0.73
 > > USER     TTY FROM              LOGIN@  IDLE WHAT
 > > w: kvm_getprocs: Cannot allocate memory: Cannot allocate memory
 >                    ^^^^^^^^^^^^^^^^^^^^^^
 > 
 > can.not ()
 > ('kan-(.){a:}t; k*-'n{a:}t, ka-')
 >    can not
 >  -- cannot but   to be bound to: MUST
 > > >Fix:
 > > Not sure, if someone has any clues, let me know and I'll start looking
 > > though.
 > 
 > Add more memory or swap to your computer.
 > 
 > DES
 > -- 
 > Dag-Erling Smrgrav - dag-erli@ifi.uio.no
 > 
 
 Sorry, I should have elaborated:
 
 Mem: 222M Active, 27M Inact, 50M Wired, 60M Cache, 8277K Buf, 18M Free
 Swap: 256M Total, 4532K Used, 252M Free, 2% Inuse
 
 How can I be running out of memory?
 
 real memory  = 402653184 (393216K bytes)
 avail memory = 391720960 (382540K bytes)
 
 With 18MB free, and 60MB sitting in a cache, I can't see that I'm out of
 just raw memory... Our of mbufs? Out of some fixed kind of memory? That's
 what I don't know - what memory am I running out of?
 
 Kevin
State-Changed-From-To: closed->open 
State-Changed-By: des 
State-Changed-When: Mon Oct 12 09:03:56 PDT 1998 
State-Changed-Why:  
Originator reports he's not low on memory. 

From: dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?= )
To: Kevin Day <toasty@home.dragondata.com>
Cc: root@shell1.dragondata.com, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory'
Date: 12 Oct 1998 20:35:27 +0200

 Kevin Day <toasty@home.dragondata.com> writes:
 > With 18MB free, and 60MB sitting in a cache, I can't see that I'm out of
 > just raw memory... Our of mbufs? Out of some fixed kind of memory? That's
 > what I don't know - what memory am I running out of?
 
 If you read the kvm_getprocs() code (in src/lib/libkvm/kvm_proc.c)
 you'll notice the only case in which it prints out an error message is
 if sysctl() fails. sysctl(3) mentions that sysctl() will fail and set
 errno to ENOMEM if "The length pointed to by oldlenp is too short to
 hold the requested value." What seems to happen is that between the
 first and the second call to sysctl, the size of the data has grown
 (because the number of running processes is growing fast), so the
 buffer we allocate is no longer big enough. The best way to fix this
 is to retry the sysctl() with a larger buffer if/when it fails with
 ENOMEM.
 
 If my reasoning is correct, the following (untested) patch should
 solve this:
 
 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 18:33:58
 @@ -302,10 +302,15 @@
                         _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 {
 +                       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);
 
 Of course, there is no guarantee that the loop will terminate before
 the process table goes full, but if you're seeing this problem in the
 first place it shouldn't take too long to fill up :)
 
 Now if only jkh will come out of his trance and answer some mail so I
 can get his approval to commit it...
 
 DES
 -- 
 Dag-Erling Smrgrav - dag-erli@ifi.uio.no
State-Changed-From-To: open->feedback 
State-Changed-By: des 
State-Changed-When: Mon Oct 12 13:38:50 PDT 1998 
State-Changed-Why:  
Fixed in -current. 


Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Mon Oct 12 13:38:50 PDT 1998 
Responsible-Changed-Why:  
So I'll remember to MFC. 
State-Changed-From-To: feedback->closed 
State-Changed-By: des 
State-Changed-When: Mon Jan 4 16:16:40 PST 1999 
State-Changed-Why:  
MFC. 
>Unformatted:
