non random mmap
Dear All,
I have an AMD64x2 4400 using Debian/Sid/AMD64
I have a self built 2.6.16.18 kernel.
I want to have the mmap system call behaving predictably and in a
reproducable manner (because I am debugging a copying garbage collector).
Here is a simple test program
################################################################
// file testmmap.c
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int
main (int argc, char **argv)
{
int kilob = 64;
void *p;
if (argc > 1)
kilob = atoi (argv[1]);
p =
mmap ((void *) 0, (size_t) (kilob << 10), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, (int) -1, (off_t) 0);
if (p == MAP_FAILED)
{
perror ("mmap");
exit (1);
};
printf ("got %d kilobytes at %p - %p\n", kilob, p,
(char *) p + (kilob << 10));
return 0;
}
/// eof testmmap.c
################################################################
I am compiling it with
gcc -W -O testmmap.c -o testmmap
chpax -rx ./testmmap
but this does not help, the mmapped area has still a random address
glinka ~/tmp 19:03 % ./testmmap
got 64 kilobytes at 0x2aef52951000 - 0x2aef52961000
glinka ~/tmp 19:07 % ./testmmap
got 64 kilobytes at 0x2ba6e78c5000 - 0x2ba6e78d5000
glinka ~/tmp 19:07 % ./testmmap
got 64 kilobytes at 0x2b6fe1edf000 - 0x2b6fe1eef000
What did I forget to do?
Is there some sysctl or kernel config to do?
(I googled for RANDMMAP without clues)
Regards
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France
Reply to: