*BSD News Article 75377


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!usenet.eel.ufl.edu!news-res.gsl.net!news.gsl.net!news.mathworks.com!newsfeed.internetmci.com!demos!news1.relcom.ru!news.spb.su!arcom.rcom.spb.su!satisfy.kiae.su!carrier.kiev.ua!cmr.kiev.ua!archer
From: archer@cmr.kiev.ua (Alexander Litvin)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: PANIC!
Date: 4 Aug 1996 13:29:44 GMT
Organization: Lucky Net Ltd.
Lines: 123
Distribution: world
Message-ID: <4u28k8$uig@merin.carrier.kiev.ua>
NNTP-Posting-Host: cmr.kiev.ua
X-Newsreader: TIN [version 1.2 PL2]


Hello, All!

I don't know, may be it's not right place to post, but...

So, I tried to figure out how would FreeBSD behave under heavy load.
For this purpose I wrote the simple program. It creates 200 copies 
of itself, and then each copy tries to give system some work, that 
is opens a file and writes into it randomly and also allocates memory, 
uses it and frees memory afterwards. Here it is:

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

int main()
   {
   int incarnation;        /* Program incarnation */
   int i,j;                /* Counters */
   int descriptor;         /* File descriptor */
   int PID,status;         /* Self-explaining */
   char buffer[512];       /* Buffer for file operations */
   int written;            /* Bytes written */
   char name[10];          /* For file name */
   double t;               /* Temporary */
   char* p=NULL;           /* Dinamic allocated memory pointer */

   for(incarnation=0;incarnation<200;incarnation++)
      {
      PID=fork();   /* Let's create another incarnation */
      if(PID==-1)
         {
         printf("Cannot create another process, %d\n",incarnation);
         break;
         }
      if(!PID)
         break;
      }

   sprintf(name,"%d",getpid());
   descriptor=open(name,O_CREAT|O_WRONLY,0777); /* Create temporary file */ 
   
   if(descriptor==-1)
      {
      printf("Cannot create another file, %d\n",incarnation);
      exit(-1);
      }

   srand(incarnation);   /* Make some randomization */

   for(i=0;i<1000;i++)   /* Do some work */
      {
      written=write(descriptor,buffer,512);

      if(written!=512)
         {
         printf("Cannot write file, %d\n",incarnation);
         close(descriptor);
         if(p)
            free(p);
         exit(-1);
         }

      /* We'll write into file at random position */
      t=((double)rand()/(double)RAND_MAX)*32255.;      
      lseek(descriptor,(int)t,SEEK_SET);
      
      if(p)      /* Use some VM as well */
         {
         for(j=0;j<0xffff;j++)
            p[j]='Z'; 
         free(p);
         p=NULL;
         }
      else
         {
         p=(char*)malloc(0xffff*sizeof(char));
         if(!p)
            {
            printf("Cannot allocate memory, %d\n",incarnation);
            close(descriptor);
            exit(-1);
            }
         for(j=0;j<0xffff;j++)
            p[j]='z';
         }
      }

   close(descriptor);
   if(p)
      free(p);

   wait(&status);
   return 0;
   }

I ran at at one 2.1 box: AMD 5x86-133, ISA/PCI, 24M ram, 1.2G IDE hard
disk, and at two 2.1.5 boxes: Pentium 100, ISA/PCI, 16M ram, Adaptec 7850
SCSI adapter, Seagate 2G SCSI hard disk, and Pentium 75, ISA/PCI, 16M ram,
1.2G hard disk. 
Each system crashes with message like:

kernel page directory invalid pdir=0x52e063 va=0xc000
                                   ^^^^^^^^
                                   actual numbers may differ
panic: invalid page directory

Crash is more or less severe from time to time. Sometimes system will
work well with 200 processes, but crash with 300 - it depends.

I don't see any reason for such system behaviour. I'm not sure it's
melfunction, but will be grateful to hear any comments. For we would
like to use FreeBSD as a server for http, ftp, nntp, and other
services, and we're very concerned with it's stability. I of course 
know that ftp.freebsd.org sustains very heavy load, but...
At least, system should refuse to give servicies when overloaded, but
(from my point of view) it shouldn't crash!

P.S. May be the program is simply buggy - forgive the dummy in that case.

--
Litvin Alexander                      <archer@cmr.kiev.ua>