From ebd2e88c9a69dd25363b67e7df95bdb2da7bb8b3 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 7 May 2014 22:20:29 +0400 Subject: [PATCH] zdtm: maps05 -- Test a flood of small VMAs Here we test a big number of small VMAs to survive c/r. The main idea is to use a big number of IOVs needed for page transferring. Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- test/zdtm.sh | 1 + test/zdtm/live/static/Makefile | 1 + test/zdtm/live/static/maps05.c | 91 ++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 test/zdtm/live/static/maps05.c diff --git a/test/zdtm.sh b/test/zdtm.sh index b4f9282a7..bd15453bf 100755 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -12,6 +12,7 @@ static/maps00 static/maps01 static/maps02 static/maps04 +static/maps05 static/maps_file_prot static/mprotect00 static/mtime_mmap diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index 39ffe0b98..c045552f3 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -66,6 +66,7 @@ TST_NOFILE = \ maps02 \ maps03 \ maps04 \ + maps05 \ xids00 \ groups \ file_fown \ diff --git a/test/zdtm/live/static/maps05.c b/test/zdtm/live/static/maps05.c new file mode 100644 index 000000000..c5bea2f2d --- /dev/null +++ b/test/zdtm/live/static/maps05.c @@ -0,0 +1,91 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zdtmtst.h" + +const char *test_doc = "Create a bunch of small VMAs and test they survive transferring\n"; +const char *test_author = "Cyrill Gorcunov "; + +#define NR_MAPS 4096 + +#define NR_MAPS_1 (NR_MAPS + 0) +#define NR_MAPS_2 (NR_MAPS + 1) + +#define MAPS_SIZE_1 (140 << 10) +#define MAPS_SIZE_2 (8192) + +int main(int argc, char *argv[]) +{ + void *map[NR_MAPS + 2] = { }, *addr; + size_t i, summary; + + test_init(argc, argv); + + summary = NR_MAPS * 2 * 4096 + MAPS_SIZE_1 + MAPS_SIZE_2 + (1 << 20); + + addr = mmap(NULL, summary, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (addr == MAP_FAILED) { + err("Can't mmap"); + return 1; + } + munmap(addr, summary); + + for (i = 0; i < NR_MAPS; i++) { + map[i] = mmap(i > 0 ? map[i - 1] + 8192 : addr, 4096, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (map[i] == MAP_FAILED) { + err("Can't mmap"); + return 1; + } else { + /* Dirtify it */ + int *v = (void *)map[i]; + *v = i; + } + } + + map[NR_MAPS_1] = mmap(map[NR_MAPS_1 - 1] + 8192, MAPS_SIZE_1, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); + if (map[NR_MAPS_1] == MAP_FAILED) { + err("Can't mmap"); + return 1; + } else { + /* Dirtify it */ + int *v = (void *)map[NR_MAPS_1]; + *v = i; + test_msg("map-1: %p %p\n", map[NR_MAPS_1], map[NR_MAPS_1] + MAPS_SIZE_1); + } + + map[NR_MAPS_2] = mmap(map[NR_MAPS_1] + MAPS_SIZE_1, MAPS_SIZE_2, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); + if (map[NR_MAPS_2] == MAP_FAILED) { + err("Can't mmap"); + return 1; + } else { + /* Dirtify it */ + int *v = (void *)map[NR_MAPS_2]; + *v = i; + test_msg("map-2: %p %p\n", map[NR_MAPS_2], map[NR_MAPS_2] + MAPS_SIZE_2); + } + + test_daemon(); + test_waitsig(); + + for (i = 0; i < NR_MAPS; i++) { + int *v = (void *)map[i]; + + if (*v != i) { + fail("Data corrupted at page %lu", (unsigned long)i); + return 1; + } + } + + pass(); + return 0; +}