Bug 13532

Summary: bad vm mfs interaction
Product: Base System Reporter: proett <proett>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description proett 1999-09-01 22:50:00 UTC
Using a memory file system and a memory intensive program at the same
time can result in the system hanging.  Running the program below twice
results in a gradual death spiral.  Most procs are waiting on "newbuf".
Here is the output of "top" after things froze:

last pid: 30140;  load averages:  3.05,  1.65,  1.24   up 24+21:50:02  13:30:19
32 processes:  5 running, 26 sleeping, 1 stopped
CPU states:  0.4% user,  0.0% nice,  0.0% system,  1.6% interrupt, 98.1% idle
Mem: 15M Active, 27M Inact, 14M Wired, 1968K Cache, 7336K Buf, 804K Free
Swap: 200M Total, 127M Used, 72M Free, 64% Inuse

  PID USERNAME PRI NICE  SIZE    RES STATE    TIME   WCPU    CPU COMMAND
  238 nobody    -2  20 14272K 10520K newbuf 465.2H  0.88%  0.88% setiathome
  272 root     -18   0 15112K     0K wswbuf  20.6H  0.00%  0.00% XF86_S3
  210 root       2   0   788K     0K select  12:01  0.00%  0.00% <moused>
  114 root       2 -12  1032K   172K select   9:19  0.00%  0.00% xntpd
   90 root       2   0   404K    60K select   4:59  0.00%  0.00% routed
  170 root       2   0  1304K     0K RUN      0:33  0.00%  0.00% <sendmail>
  166 root      10   0   980K     0K RUN      0:30  0.00%  0.00% <cron>
  105 root       2   0   820K     0K RUN      0:25  0.00%  0.00% <syslogd>
 9812 root       2   0  1320K     0K RUN      0:09  0.00%  0.00% <sshd1>
   30 root     -18   0   101M  7592K wswbuf   0:06  0.00%  0.00% mount_mfs
30086 root       2   0  1312K   156K select   0:02  0.00%  0.00% sshd1
30140 proett    -2   0 25204K  4256K newbuf   0:02  0.00%  0.00% suck
  140 root       2   0  1008K     0K select   0:02  0.00%  0.00% <amd>
  118 daemon     2   0   836K     0K select   0:01  0.00%  0.00% <portmap>
  244 root       2   0  1560K     0K select   0:01  0.00%  0.00% <sshd2>
30132 proett    28   0  1560K   316K RUN      0:01  0.00%  0.00% top
  269 root       2   0  2108K     0K select   0:01  0.00%  0.00% <xdm>
...

How-To-Repeat: Run this program twice on a system that uses mfs as /tmp.

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

#define XSIZE   4096

main()
{
        char    *buf;
        int     fsok, memok;
        int     fd;

        fd = open("/tmp/suck.out", O_WRONLY|O_CREAT|O_TRUNC, 0644);
        if (fd == -1) {
                perror("open");
                exit(1);
        }

        fsok = memok = 1;
        while (fsok || memok) {
                if (memok) {
                        buf = malloc(XSIZE);
                        if (buf == NULL) {
                                perror("malloc");
                                memok = 0;
                        }
                }
                if (fsok) {
                        if (write(fd, buf, XSIZE) != XSIZE) {
                                perror("write");
                                fsok = 0;
                        }
                }
        }
        printf("sleeping...\n");
        sleep(500);
        return 0;
}
Comment 1 ed hudson 2000-04-18 19:28:51 UTC
i've just tried this old bug on a 4.0-RELEASE system, with no crashes.
when i last tried this (3.3-RELEASE), it hosed my system strait away.
Comment 2 Poul-Henning Kamp freebsd_committer freebsd_triage 2001-05-29 19:22:07 UTC
State Changed
From-To: open->closed

Issue resolved.