Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 1996 22:19:17 +0300 (EET DST)
From:      "Litvin Alexander B. <litvin@cmr.kiev.ua>" <archer@cmr.kiev.ua>
To:        hackers@freebsd.org
Subject:   "Panick" - help needed...
Message-ID:  <Pine.BSD/.3.91.960808221623.14971A-100000@cmr.kiev.ua>

next in thread | raw e-mail | index | archive | help

Hello, All!

I was advised by J.K.Habbard to send this into freebsd.hackers, so
here my "problem" goes...

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>
                +--------------------+
                |"Must-die" must die!|
                +--------------------+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSD/.3.91.960808221623.14971A-100000>