lkml.org 
[lkml]   [2004]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [lockup] Re: objrmap-core-1 (rmap removal for file mappings to avoid 4:4 in <=16G machines)

* Ingo Molnar <mingo@elte.hu> wrote:

> To reproduce, run the attached, very simple test-mmap.c code (as
> unprivileged user) which maps 80MB worth of shared memory in a
> finegrained way, creating ~19K vmas, and sleeps. Keep this process
> around.

or run the attached test-mmap2.c code, which simulates a very small DB
app using only 1800 vmas per process: it only maps 8 MB of shm and
spawns 32 processes. This has an even more lethal effect than the
previous code.

Ingo
/*
* Copyright (C) Ingo Molnar, 2004
*
* Create 8 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>

/* 8 MB of mappings */
#define CACHE_PAGES 2000

#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;
}

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.165 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site