From nobody@FreeBSD.ORG  Sat Dec 11 11:42:45 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 1614414D16; Sat, 11 Dec 1999 11:42:45 -0800 (PST)
Message-Id: <19991211194245.1614414D16@hub.freebsd.org>
Date: Sat, 11 Dec 1999 11:42:45 -0800 (PST)
From: mitja@ksop-cscp.si
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: 3.3-RELEASE Kernel freeze 
X-Send-Pr-Version: www-1.0

>Number:         15420
>Category:       kern
>Synopsis:       3.3-RELEASE Kernel freeze
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 11 11:50:01 PST 1999
>Closed-Date:    Wed Jun 6 14:05:40 PDT 2001
>Last-Modified:  Wed Jun 06 14:05:58 PDT 2001
>Originator:     Mitja Horvat
>Release:        3.3-RELEASE
>Organization:
>Environment:
FreeBSD weha.nonet.si 3.3-RELEASE FreeBSD 3.3-RELEASE #7: Thu Dec  9 00:21:47 CET 1999     root@weha.nonet.si:/usr/src/sys/compile/WOW  i386
>Description:
Kernel freezes under heavy VM load.
>How-To-Repeat:
Spawn few programs that chew up all memory. 
The bug may not show up immediately, so run the programs few times.

This script triggers the problem on two PCs I tested on:
--------------------------------->8--------------------------------
#!/bin/sh
cat << EOF > qq.c
void main(void) {
        for(;;)
                memset(malloc(1000000), 0, 1000000);
}
EOF
cc qq.c -o qq
./qq &
./qq &
./qq &
./qq &
wait
rm -f qq qq.c
--------------------------------->8--------------------------------

>Fix:
The following kernel patch fixes the problem for me, but since this is my 
first FreeBSD hacking attempt, I'm not sure if it's OK.
--------------------------------->8--------------------------------
--- vm_pageout.c.orig   Fri Dec 10 01:49:54 1999
+++ vm_pageout.c        Fri Dec 10 01:54:22 1999
@@ -1136,8 +1136,8 @@
         * make sure that we have swap space -- if we are low on memory and
         * swap -- then kill the biggest process.
         */
-       if ((vm_swap_size == 0 || swap_pager_full) &&
-           ((cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min)) {
+       if (vm_swap_size == 0 || swap_pager_full || 
+          (cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min) {
                bigproc = NULL;
                bigsize = 0;
                for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
--------------------------------->8--------------------------------


>Release-Note:
>Audit-Trail:

From: Mitja Horvat <mitja@ksop-cscp.si>
To: freebsd-gnats-submit@freebsd.org, mitja@ksop-cscp.si
Cc:  
Subject: Re: kern/15420: 3.3-RELEASE Kernel freeze
Date: Sun, 12 Dec 1999 19:19:10 +0100

 In the last bug report I sent the wrong patch. Sorry for the inconvenience.
 The right patch is this:
 --------------------------------->8--------------------------------
 --- vm_pageout.c.orig   Mon Aug 30 00:42:11 1999
 +++ vm_pageout.c        Sun Dec 12 18:16:38 1999
 @@ -1136,8 +1136,9 @@
          * make sure that we have swap space -- if we are low on memory and
          * swap -- then kill the biggest process.
          */
 -       if ((vm_swap_size == 0 || swap_pager_full) &&
 -           ((cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min)) {
 +       if (vm_swap_size == 0 &&   
 +          (cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min ||
 +          swap_pager_full) {
                 bigproc = NULL;
                 bigsize = 0;
                 for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
 --------------------------------->8--------------------------------
 
 Regards,
 Mitja
 
 

From: Mitja Horvat <mitja@ksop-cscp.si>
To: freebsd-gnats-submit@freebsd.org, mitja@ksop-cscp.si
Cc:  
Subject: Re: kern/15420: 3.3-RELEASE Kernel freeze
Date: Mon, 13 Dec 1999 18:36:32 +0100

 After rerunning the tests with more processes (10+) I noticed that random
 kernel freezes were still happening. After digging a bit around the swapper
 code I came up with a third patch.  My machine with this patch applied is
 stable although running for three hours with 15 memory hogs.
 -------------------------------->8-------------------------------------------
         diff -u sys.orig/vm/vm_pageout.c sys/vm/vm_pageout.c
         --- sys.orig/vm/vm_pageout.c    Sun Aug 29 18:33:38 1999
         +++ sys/vm/vm_pageout.c Mon Dec 13 17:20:38 1999
         @@ -1136,8 +1136,9 @@
                  * make sure that we have swap space -- if we are low on memory and
                  * swap -- then kill the biggest process.
                  */
 -       if ((vm_swap_size == 0 || swap_pager_full) &&
 -           ((cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min)) {
 +       if (vm_swap_size == 0 &&
 +           (cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min ||
 +           swap_pager_full) {
                 bigproc = NULL;
                 bigsize = 0;
                 for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
 @@ -1174,7 +1175,7 @@
                         bigproc->p_nice = PRIO_MIN;
                         resetpriority(bigproc);
                         wakeup(&cnt.v_free_count);
 -               }
 +               }
         }
         return force_wakeup;
  }
 -------------------------------->8-------------------------------------------
 Regards,
 Mitja
 
 

From: Mitja Horvat <mitja@ksop-cscp.si>
To: freebsd-gnats-submit@freebsd.org, mitja@ksop-cscp.si
Cc:  
Subject: Re: kern/15420: 3.3-RELEASE Kernel freeze
Date: Tue, 14 Dec 1999 15:40:33 +0100

 Hi again, in the previous post I appended the wrong patch again.
 Please forgive me, I have a lot of other things to do besides this ;)
 The patch is now uuencoded.
 Regards,
 Distracted Mitja ;)
 begin 644 vm-3.3-RELEASE.patch
 M9&EF9B`M=2!S>7,N;W)I9R]V;2]S=V%P7W!A9V5R+F,@<WES+W9M+W-W87!?
 M<&%G97(N8PHM+2T@<WES+F]R:6<O=FTO<W=A<%]P86=E<BYC"5-U;B!!=6<@
 M,CD@,3@Z,S,Z,C<@,3DY.0HK*RL@<WES+W9M+W-W87!?<&%G97(N8PE-;VX@
 M1&5C(#$S(#$W.C(P.C(U(#$Y.3D*0$`@+3$X-2PQ,2`K,3@U+#$Q($!`"B!S
 M=&%T:6,@7U]I;FQI;F4@=F]I9`H@<W=A<'-I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!A9V5O=70N8PE-;VX@
 M1&5C(#$S(#$W.C(P.C,X(#$Y.3D*0$`@+3$Q,S8L."`K,3$S-BPY($!`"B`)
 M("H@;6%K92!S=7)E('1H870@=V4@:&%V92!S=V%P('-P86-E("TM(&EF('=E
 M(&%R92!L;W<@;VX@;65M;W)Y(&%N9`H@"2`J('-W87`@+2T@=&AE;B!K:6QL
 M('1H92!B:6=G97-T('!R;V-E<W,N"B`)("HO"BT):68@*"AV;5]S=V%P7W-I
 M>F4@/3T@,"!\?"!S=V%P7W!A9V5R7V9U;&PI("8F"BT)("`@("@H8VYT+G9?
 M9G)E95]C;W5N="`K(&-N="YV7V-A8VAE7V-O=6YT*2`\(&-N="YV7V9R965?
 M;6EN*2D@>PHK"6EF("AV;5]S=V%P7W-I>F4@/3T@,"`F)@HK"2`@("`H8VYT
 M+G9?9G)E95]C;W5N="`K(&-N="YV7V-A8VAE7V-O=6YT*2`\(&-N="YV7V9R
 M965?;6EN('Q\(`HK"2`@("!S=V%P7W!A9V5R7V9U;&PI('L*(`D)8FEG<')O
 M8R`]($Y53$P["B`)"6)I9W-I>F4@/2`P.PH@"0EF;W(@*'`@/2!A;&QP<F]C
 M+FQH7V9I<G-T.R!P("$](#`[('`@/2!P+3YP7VQI<W0N;&5?;F5X="D@>PI`
 M0"`M,3$W-"PW("LQ,3<U+#<@0$`*(`D)"6)I9W!R;V,M/G!?;FEC92`](%!2
 M24]?34E..PH@"0D)<F5S971P<FEO<FET>2AB:6=P<F]C*3L*(`D)"7=A:V5U
 M<"@F8VYT+G9?9G)E95]C;W5N="D["BT)"7T**PD)?2`*(`E]"B`)<F5T=7)N
 2(&9O<F-E7W=A:V5U<#L*('T*
 `
 end
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Wed Jun 6 14:05:40 PDT 2001 
State-Changed-Why:  
timed out 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=15420 
>Unformatted:
