*BSD News Article 69243


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!inferno.mpx.com.au!news.unimelb.EDU.AU!munnari.OZ.AU!news.mel.connect.com.au!news.mira.net.au!inquo!bofh.dot!in-news.erinet.com!imci5!imci4!newsfeed.internetmci.com!panix!not-for-mail
From: tls@panix.com (Thor Lancelot Simon)
Newsgroups: comp.unix.bsd.misc
Subject: Why does this program panic 4.4BSD?
Date: 23 May 1996 17:18:27 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Lines: 40
Message-ID: <4o2kn3$21u@panix2.panix.com>
Reply-To: tls@rek.tjls.com
NNTP-Posting-Host: panix2.panix.com

I've been playing around for ways to generate some baseline load on the VM
system as part of a benchmark I'm writing to approximate the application we
develop where I work.

The following code appears to quite reliably panic every 4.4 derivative I've
run it on, when run by an ordinary, unprivileged user.  In fact, I suspect
that it rather irritated the folks who run the BSDi machine I occasionally
use... I was rather surprised that it caused such lossage there, too.

Yes, I know that it never unlocks the 0-1MB range of the allocation.  That's
a bug. :-)  But still, holding that 1MB in core shouldn't cause utter,
near-instantaneous lossage, should it?

The system doesn't appear to crash for values of MEGS < 4; with MEGS=4 it
seems, unsurprisingly enough, to crash after about four seconds.

#define MEGS 4
#ifdef sun
#include <fcntl.h>
#include <sys/mman.h> #endif #include <sys/types.h> main() { int i; char *c;
 
#ifndef sun
c = malloc(MEGS * 1024 * 1024);
#else
c = mmap(0, (MEGS * 1024 * 1024), PROT_READ, MAP_SHARED, open("/dev/zero",
O_RDONLY), 0 );
#endif
while(1) {
for(i = 0; i < MEGS; i++) {
        if(i != 0)
        	munlock((caddr_t)c + (i - 1) * 1024 * 1024, 1 * 1024 * 1024);
        mlock((caddr_t)c + i * 1024 * 1024, (1 * 1024 * 1024));
        sleep(1);
}
}
}
-- 
Thor Lancelot Simon	                                          tls@panix.COM

              If you're looking for a patsy, why not try the entire human race?