From dtc@scrooge.ee.swin.oz.au  Thu Sep 11 16:09:19 1997
Received: from scrooge.ee.swin.oz.au (scrooge.ee.swin.oz.au [136.186.4.20])
          by hub.freebsd.org (8.8.7/8.8.7) with SMTP id QAA02239
          for <freebsd-gnats-submit@freebsd.org>; Thu, 11 Sep 1997 16:09:17 -0700 (PDT)
Received: (from dtc@localhost) by scrooge.ee.swin.oz.au (8.6.9/8.6.9) id JAA27052 for freebsd-gnats-submit@freebsd.org; Fri, 12 Sep 1997 09:12:28 +1000
Message-Id: <199709112312.JAA27052@scrooge.ee.swin.oz.au>
Date: Fri, 12 Sep 1997 09:12:27 +1000 (EST)
From: Douglas Thomas Crosher  <dtc@scrooge.ee.swin.oz.au>
To: freebsd-gnats-submit@freebsd.org
Subject: System lockup which appears to be VM related.

>Number:         4513
>Category:       kern
>Synopsis:       System lockup appears to be VM related.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 11 16:10:01 PDT 1997
>Closed-Date:    Tue May 29 10:59:16 PDT 2001
>Last-Modified:  Tue May 29 10:59:49 PDT 2001
>Originator:     Douglas
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Swinburne University of Technology
>Environment:

Pentium 133, 128M Ram, 512M swap. Freebsd 3.0-current Sep 11, 1997.

>Description:

I've noticed the machine locking up for roughly 2 minutes.

The keyboard will still accept interrupts and the VT switching still
works, but only the VT at the point of lockup will accept
anything. All processes appear to have halted but the VT reported load
average climbs to about 5. There is some very light disk activity,
very roughly a blink every 10 seconds. After about 2 minutes the
system resumes and starts paging heavily. This behaviour was not seen
in a current system from July.

>How-To-Repeat:

The code below reproduces the problem. The number of pages allocated
needed to be adjusted to the machines memory size which was 128M. The
lockup occurs after 4-6 iterations.

-=-=-

#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>

#define NUM_PAGES 2*16384 /* Adjust to the machines memory size. */

main()
{
  int n,i;
  int max=10;
  int x;

  if (mmap(0x9000000,NUM_PAGES*4096,
	   PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_ANON,-1,0)
      == -1)
    printf("mmap erorr\n");

  for (n=0;n<max;n++) {
    int page;
    
    printf("Itteration %d\n",n);
    
    /* Write to pages randomly */
    for (page=0;page<NUM_PAGES;page++) {
      int  *addr = (int *)((void *)0x9000000 + 4096*page);
      int  j;
      if (random()%4 == 0)
	for (j=0; j<1024; j++)
	  addr[j] = (int)addr;
    }
      
    /* Zero pages using unmap */
    for (page=0;page<NUM_PAGES;page++) {
      int  *addr = (int *)((void *)0x9000000 + 4096*page);
      if (random()%16 == 0) {
	int rem=NUM_PAGES-page;
	int num=random()%8;
	int j;
	
	if (num>rem)
	  num=rem;
	if (munmap((void *)addr,4096*num)==-1)
	  printf("munmap erorr\n");
	if (mmap((void *)addr,4096*num,
		 PROT_READ|PROT_WRITE|PROT_EXEC,
		 MAP_PRIVATE|MAP_ANON,-1,0) ==-1)
	  printf("mmap erorr\n");
      }
    }
    
    /* Read from pages at random. */
    for (page=0;page<NUM_PAGES;page++) {
      int  *addr = (int *)((void *)0x9000000 + 4096*page);
      if (random()%4 == 0)
	x += addr[0];
    }
  }
}

-=-=-

>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Tue May 29 10:59:16 PDT 2001 
State-Changed-Why:  
timed out 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=4513 
>Unformatted:
Misdirected email from PR pending/4964, copied by fenner
Sun Nov  9 02:08:10 PST 1997

From: "John S. Dyson" <toor@dyson.iquest.net>
Reply-To: dyson@FreeBSD.ORG
To: dtc@scrooge.ee.swin.oz.au (Douglas Thomas Crosher)
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: System lockup which appears to be VM related.

Douglas Thomas Crosher said:
>
>   if (mmap(0x9000000,NUM_PAGES*4096,
>          PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_ANON,-1,0)
>       == -1)
>     printf("mmap erorr\n");
>
You really do need to specify MAP_FIXED in the mmap above.  It is likely
that you are allocating too much memory and your X server or other important
process is getting killed due to lack of swap space.

--
John
dyson@freebsd.org
jdyson@nc.com

