Re: [lockup] Re: objrmap-core-1 (rmap removal for file mappings to avoid 4:4 in <=16G machines)

From: Ingo Molnar
Date: Tue Mar 09 2004 - 14:41:14 EST



* Andrea Arcangeli <andrea@xxxxxxx> wrote:

> > > how fast is the system you tried this on? If it's faster than the 500
> > > MHz box i tried it on then please try the attached test-mmap3.c.
> > > (which is still not doing anything extreme.)
> >
> > also, please run it on an UP kernel.
>
> I will, thanks for the hint.

test-mmap3.c attached. It locked up my UP box so hard that i couldnt
even switch consoles - i turned the box off after 30 minutes.

Ingo
/*
* Copyright (C) Ingo Molnar, 2004
*
* Create 80 MB worth of finegrained mappings to a shmfs file,
* and spawn 32 processes.
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>

/* 80 MB of mappings */
#define CACHE_PAGES 20000

#define PAGE_SIZE 4096
#define CACHE_SIZE (CACHE_PAGES*PAGE_SIZE)
#define WINDOW_PAGES (CACHE_PAGES*9/10)
#define WINDOW_SIZE (WINDOW_PAGES*PAGE_SIZE)
#define WINDOW_START 0x48000000

int main(void)
{
char *data, *ptr, filename[100];
char empty_page [PAGE_SIZE];
int i, fd;

sprintf(filename, "/dev/shm/cache%d", getpid());
fd = open(filename, O_RDWR|O_CREAT|O_TRUNC,S_IRWXU);
unlink(filename);

for (i = 0; i < CACHE_PAGES; i++)
write(fd, empty_page, PAGE_SIZE);
data = mmap(0, WINDOW_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED , fd, 0);

for (i = 0; i < WINDOW_PAGES; i++) {
ptr = (char*) mmap(data + i*PAGE_SIZE, PAGE_SIZE,
PROT_READ|PROT_WRITE, MAP_SHARED | MAP_FIXED,
fd, (WINDOW_PAGES-i)*PAGE_SIZE);
(*ptr)++;
}
printf("%d pages mapped - sleeping until Ctrl-C.\n", WINDOW_PAGES);
fork(); fork(); fork(); fork(); fork();
pause();

return 0;
}