Subject: pstat -f
To: Current Users <current-users@netbsd.org>
From: Chavdar Ivanov <ci4ic4@gmail.com>
List: current-users
Date: 12/29/2007 21:35:09
Hi,

This stops working on my i386 -current system after a few minutes. I
can't pinpoint to any particular program causing it - usually after
Gnome and Firefox with a few tabs open (but it may be just a
coincidence). I get :-

% cat screenlog.0
lisa# pstat -f
370/1772 open files
   LOC   TYPE    FLG     CNT  MSG    DATA   USE IFLG OFFSET
e0e26b84 file         R    0    0  ccaa7910   0    1  0
e0e26bc8 file         R    1    0  ccaa7cbc   0    0  0
....
cc8eaf24 file        RW    5    0  cb2beb04   0    0  1334
cc8eaf68 socket      RW    1    0  c1dccd20   0    0  0
lisa# /usr/local/bin/@home.wpi
add net default: gateway 192.168.2.1
wpi0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ssid wg15
        powersave off
        bssid 00:04:e2:af:a3:40 chan 4
        address: 00:13:02:b5:74:0f
        media: IEEE802.11 autoselect (OFDM24 mode 11g)
        status: active
        inet 192.168.2.201 netmask 0xffffff00 broadcast 192.168.2.255
        inet6 fe80::213:2ff:feb5:740f%wpi0 prefixlen 64 scopeid 0x1
lisa# pstat -f
370/1772 open files
   LOC   TYPE    FLG     CNT  MSG    DATA   USE IFLG OFFSET
e0e26b84 file         R    0    0  ccaa7910   0    1  0
e0e26bc8 file         R    0    0  e0f342a0   0    1  227
....
cc8eaf68 socket      RW    1    0  c1dccd20   0    0  0
lisa# pstat -f
705/1772 open files
   LOC   TYPE    FLG     CNT  MSG    DATA   USE IFLG OFFSET
dfbe40f8 file         R    0    0  dfc76008   0    1  43
dfbe413c socket      RW    0    0        0    0    1  0
dfbe4180 file         R    0    0  cc9fed74   0    1  0
cd11b55c socket      RW    1    0  c230ae18   1    0  0
...
cc8eaee0 file        WA   12    0  cd46fcc0   0    0  4472842
cc8eaf24 file        RW    5    0  cb2beb04   0    0  1334
cc8eaf68 socket      RW    1    0  c1dccd20   0    0  0
lisa# pstat -f
pstat: sysctl: KERN_FILE: Cannot allocate memory
lisa#

Here is the ktruss output, if of any help:-

pstat: sysctl: KERN_FILE: Cannot allocate memory
  1545      1 ktruss   emul(netbsd)
  1545      1 ktruss   fktrace                     = 0
  1545      1 ktruss   fcntl(0x4, 0x3, 0)          = 1
  1545      1 ktruss   fcntl(0x4, 0x4, 0x1)        = 0
  1545      1 pstat    emul(netbsd)
  1545      1 pstat    execve("/usr/sbin/pstat", 0xbfbfdbb0,
0xbfbfdbbc) JUSTRETURN
  1545      1 pstat    mmap(0, 0x8000, 0x3, 0x1002, 0xffffffff, 0, 0,
0) = 0xbbbe9000
  1545      1 pstat    open("/usr/libexec/ld.elf_so", 0, 0) = 3
  1545      1 pstat    __fstat30(0x3, 0xbfbfd6bc)  = 0
  1545      1 pstat    mmap(0, 0x37, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe8000
  1545      1 pstat    close(0x3)                  = 0
  1545      1 pstat    munmap(0xbbbe8000, 0x37)    = 0
  1545      1 pstat    open("/etc/ld.so.conf", 0, 0) = 3
  1545      1 pstat    __fstat30(0x3, 0xbfbfd3bc)  = 0
  1545      1 pstat    mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe8000
  1545      1 pstat    munmap(0xbbbe8000, 0x1000)  = 0
  1545      1 pstat    mmap(0, 0x7000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbbe2000
  1545      1 pstat    mmap(0xbbbe8000, 0x1000, 0x3, 0x12, 0x3, 0,
0x5000, 0) = 0xbbbe8000
  1545      1 pstat    mmap(0xbbbe9000, 0, 0x3, 0x1012, 0xffffffff, 0,
0, 0) = 0xbbbe9000
  1545      1 pstat    close(0x3)                  = 0
  1545      1 pstat    open("/usr/lib/libkvm.so.5", 0, 0xbfbfd3bc) = 3
  1545      1 pstat    __fstat30(0x3, 0xbfbfd3bc)  = 0
  1545      1 pstat    mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe1000
  1545      1 pstat    munmap(0xbbbe1000, 0x1000)  = 0
  1545      1 pstat    mmap(0, 0xe9000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbaf9000
  1545      1 pstat    mmap(0xbbbcb000, 0x7000, 0x3, 0x12, 0x3, 0,
0xd2000, 0) = 0xbbbcb000
  1545      1 pstat    mmap(0xbbbd2000, 0x10000, 0x3, 0x1012,
0xffffffff, 0, 0, 0) = 0xbbbd2000
  1545      1 pstat    close(0x3)                  = 0
  1545      1 pstat    __sysctl(0xbfbfdae4, 0x2, 0x804d738,
0xbfbfdaec, 0, 0) = 0
  1545      1 pstat    getegid()                   = 2
  1545      1 pstat    getgid()                    = 0, 2
  1545      1 pstat    setegid(0)                  = 0
  1545      1 pstat    setegid(0x2)                = 0
  1545      1 pstat    __sysctl(0xbfbfce78, 0x2, 0xbbbd9b9c,
0xbfbfce80, 0, 0) = 0
  1545      1 pstat    __sysctl(0xbfbfcdd4, 0x2, 0xbfbfce2c,
0xbfbfce30, 0, 0) = 0
  1545      1 pstat    readlink("/usr/lib/libc.so.12", 0xbfbfce85, 0x400) = 1
  1545      1 pstat    issetugid()                 = 1
  1545      1 pstat    break(0x804d8ac)            = 0
  1545      1 pstat    break(0x804d8ac)            = 0
  1545      1 pstat    break(0x8100000)            = 0
  1545      1 pstat    mmap(0, 0x100000, 0x3, 0x14001002, 0xffffffff,
0, 0, 0) = 0xbb900000
  1545      1 pstat    __sysctl(0xbfbfd1f8, 0x2, 0xbbbe08a0,
0xbfbfd200, 0, 0) = 0
  1545      1 pstat    __sysctl(0xbfbfd2dc, 0x2, 0xbbbe8be1,
0xbfbfd2e4, 0, 0) = 0
  1545      1 pstat    __stat30("/etc/malloc.conf", 0xbfbfd25c) = 0
  1545      1 pstat    open("/netbsd", 0, 0)       = 3
  1545      1 pstat    fcntl(0x3, 0x2, 0x1)        = 0
  1545      1 pstat    __fstat30(0x3, 0xbfbfd25c)  = 0
  1545      1 pstat    open("/dev/mem", 0, 0)      = 5
  1545      1 pstat    fcntl(0x5, 0x2, 0x1)        = 0
  1545      1 pstat    open("/dev/kmem", 0, 0)     = 6
  1545      1 pstat    fcntl(0x6, 0x2, 0x1)        = 0
  1545      1 pstat    open("/dev/drum", 0, 0)     = 7
  1545      1 pstat    fcntl(0x7, 0x2, 0x1)        = 0
  1545      1 pstat    close(0x7)                  = 0
  1545      1 pstat    getgid()                    = 0, 2
  1545      1 pstat    setgid(0)                   = 0
  1545      1 pstat    open("/dev/ksyms", 0, 0)    = 7
  1545      1 pstat    fcntl(0x7, 0x2, 0x1)        = 0
  1545      1 pstat    pread(0x7, 0xbfbfd278, 0x20, 0, 0, 0) = 32
       "\^?ELF\^A\^A\^A\0\0\0\0\0\0\0\0\0\^B\0\^C\0\^A\0\0\0\0\0\^P\M-@4\0\0"
  1545      1 pstat    __fstat30(0x7, 0xbfbfd1e8)  = 0
  1545      1 pstat    pread(0x7, 0xbfbfd264, 0x34, 0, 0, 0) = 52
       "\^?ELF\^A\^A\^A\0\0\0\0\0\0\0\0\0\^B\0\^C\0\^A\0\0\0\0\0\^P\M-@4\0\0"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-B\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-M\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-X\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-`\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-j\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    ioctl(0x7, KIOCGSYMBOL, 0xbfbfd25c) = 0
       "\M-u\M-<\^D\bL\M-R\M-?\M-?"
  1545      1 pstat    close(0x7)                  = 0
  1545      1 pstat    pread(0x5, 0xbfbfd2f0, 0x4, 0, 0xc0a13098, 0) = 4
       "\M-l\^F\0\0"
  1545      1 pstat    __sysctl(0xbfbfd2b0, 0x2, 0, 0xbfbfd2b8, 0, 0) = 0
  1545      1 pstat    __sysctl(0xbfbfd2b0, 0x2, 0xbb902000,
0xbfbfd2b8, 0, 0) Err#12 ENOMEM
  1545      1 pstat    write(0x2, 0xbfbfcb14, 0x7) = 7
       "pstat: "
  1545      1 pstat    write(0x2, 0xbfbfcb44, 0x11) = 17
       "sysctl: KERN_FILE"
  1545      1 pstat    write(0x2, 0xbbbc4e2c, 0x2) = 2
       ": "
  1545      1 pstat    issetugid()                 = 1
  1545      1 pstat    issetugid()                 = 1
  1545      1 pstat    open("/dev/ksyms", 0, 0xbfbfc4a4) Err#2 ENOENT
  1545      1 pstat    open("/usr/share/nls/nls.alias.db", 0, 0xbfbfc508) = 7
  1545      1 pstat    fcntl(0x7, 0x2, 0x1)        = 0
  1545      1 pstat    __fstat30(0x7, 0xbfbfc498)  = 0
  1545      1 pstat    mmap(0, 0x5f0, 0x1, 0x2, 0x7, 0, 0, 0) = 0xbbaf8000
  1545      1 pstat    close(0x7)                  = 0
  1545      1 pstat    munmap(0xbbaf8000, 0x5f0)   = 0
  1545      1 pstat    open("/usr/share/nls/nls.alias", 0, 0xbfbfc928) = 7
  1545      1 pstat    __fstat30(0x7, 0xbfbfc928)  = 0
  1545      1 pstat    mmap(0, 0x10be, 0x1, 0x1, 0x7, 0, 0, 0) = 0xbbaf7000
  1545      1 pstat    close(0x7)                  = 0
  1545      1 pstat    munmap(0xbbaf7000, 0x10be)  = 0
  1545      1 pstat    write(0x2, 0xbfbfcb14, 0x17) = 23
       "Cannot allocate memory\n"
  1545      1 pstat    exit(0)
(248)-~#


From this moment on, I cannot run 'pstat -f' at all, even if I stop
all memory hogging programs.

(248)-~# uname -a
NetBSD lisa 4.99.46 NetBSD 4.99.46 (GENERIC) #2: Sat Dec 29 15:13:03
GMT 2007  root@lisa:/usr/obj/sys/arch/i386/compile/GENERIC i386
(249)-~# file /usr/sbin/pstat
/usr/sbin/pstat: setgid ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), for NetBSD 4.99.45, dynamically linked (uses shared
libs), not stripped

(same with the original 4.99.45 kernel).

The kernel is GENERIC + the following in GENERIC.local:

...
i915drm* at vga?         # Intel i915, i945 DRM driver
pseudo-device   putter
file-system     PUFFS           # experimental - Userspace file system support
options         VGA_POST
options         X86EMU          # 386 Real Mode emulator

There is enough memory:

# top -n
load averages:  0.16,  0.12,  0.09    up 0 days,  1:08   21:36:25
84 processes:  83 sleeping, 1 on processor
CPU0 states:     % user,     % nice,     % system,     % interrupt,     % idle
CPU1 states:     % user,     % nice,     % system,     % interrupt,     % idle
Memory: 316M Act, 64K Inact, 7208K Wired, 69M Exec, 60M File, 556M Free
Swap: 1025M Total, 1025M Free

  PID USERNAME PRI NICE   SIZE   RES STATE      TIME   WCPU    CPU COMMAND
  854 ci        85    0  4832K   78M select/1   1:55  6.59%  6.59% firefox-bin
  752 root      85    0  1836K   26M select/0   1:03  0.73%  0.73% Xorg
  551 root      85    0   764K 2120K select/0   0:22  0.00%  0.00% famd
  739 ci        85    0   500K 8776K select/0   0:10  0.00%  0.00% npviewer.bin
  895 ci        85    0  4832K   21M select/0   0:07  0.00%  0.00% gnome-termin
 1034 ci        85    0  4832K   16M select/0   0:05  0.00%  0.00% metacity
    0 root     125    0     0K   80M schedu/0   0:02  0.00%  0.00% [system]
  656 ci        85    0  4832K   23M select/0   0:02  0.00%  0.00% gnome-panel
  851 ci        85    0  5856K   23M select/0   0:02  0.00%  0.00% nautilus
  502 ci        85    0  4832K   17M select/0   0:02  0.00%  0.00% mixer_applet
 1258 ci        85    0  4832K   17M select/0   0:01  0.00%  0.00% wnck-applet
  569 mysql     85    0  6880K   14M select/1   0:01  0.00%  0.00% mysqld
  194 ci        85    0  4832K   12M select/0   0:01  0.00%  0.00% gconfd-2
  175 ci        85    0  4832K   10M select/0   0:01  0.00%  0.00% multiload-ap
 1512 ci        85    0  4832K 4308K select/1   0:01  0.00%  0.00% gnome-screen
 1205 root      43    0   752K  972K CPU/0      0:00  0.00%  0.00% top
  498 ci        85    0  4832K   17M select/0   0:00  0.00%  0.00% stickynotes_
  133 named     85    0  2784K   16M sigwai/0   0:00  0.00%  0.00% named
....

I don't see any other problems with the system otherwise (not that
this is a problem for me, but it may lead to something).
-- 
----------------------------------------------------------------
/dev/random says:
	We live in a quiet neighborhood - they all use silencers.
----------------------------------------------------------------
Chavdar Ivanov   | Talbot Way, Small Heath Business Park
Delcam UK        | Birmingham B10 0HJ, United Kingdom
Customer Support | (+44)121-6831014
----------------------------------------------------------------