From 27db1d9a0452201ac17cd427b95a107e381aa7af Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Fri, 30 Jun 2017 20:31:44 +0200 Subject: [PATCH] s390:zdtm: Add test for tasks > 4TB If the kernel contains patch ee71d16d22 ("s390/mm: make TASK_SIZE independent from the number of page table levels") we are able to checkpoint tasks > 4TB. Add a testcase to verify this. Signed-off-by: Michael Holzheu Signed-off-by: Andrei Vagin --- test/zdtm/static/Makefile | 1 + test/zdtm/static/s390x_mmap_high.c | 64 +++++++++++++++++++++++++++ test/zdtm/static/s390x_mmap_high.desc | 1 + 3 files changed, 66 insertions(+) create mode 100644 test/zdtm/static/s390x_mmap_high.c create mode 100644 test/zdtm/static/s390x_mmap_high.desc diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index 08cc3d9cc..0dba4b454 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -171,6 +171,7 @@ TST_NOFILE := \ macvlan \ cr_veth \ sock_peercred \ + s390x_mmap_high \ # jobctl00 \ ifneq ($(SRCARCH),arm) diff --git a/test/zdtm/static/s390x_mmap_high.c b/test/zdtm/static/s390x_mmap_high.c new file mode 100644 index 000000000..5eb06e6bc --- /dev/null +++ b/test/zdtm/static/s390x_mmap_high.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#include "zdtmtst.h" + +#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */ +#define MAP_SIZE 0x1000 +#define VAL 0x77 + +const char *test_doc = "Verify that tasks > 4TB can be checkpointed"; +const char *test_author = "Michael Holzheu "; + +/* + * Map memory at the very end of the 8 PB address space + */ +int main(int argc, char **argv) +{ + void *addr = (void *) TASK_SIZE_LEVEL_4 - MAP_SIZE; + char *buf; + int i; + + + test_init(argc, argv); + + /* + * Skip test if kernel does not have the following fix: + * + * ee71d16d22 ("s390/mm: make TASK_SIZE independent from the number + * of page table levels") + */ + if (munmap(addr, MAP_SIZE) == -1) { + test_daemon(); + test_waitsig(); + skip("Detected kernel without 4 level TASK_SIZE fix"); + pass(); + return 0; + } + + /* Map memory at the very end of the 8 PB address space */ + buf = mmap(addr, MAP_SIZE, PROT_WRITE | PROT_READ, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + if (buf == MAP_FAILED) { + pr_perror("Could not create mapping"); + exit(1); + } + /* Initialize buffer with data */ + memset(buf, VAL, MAP_SIZE); + + test_daemon(); + test_waitsig(); + + /* Verify that we restored the data correctly */ + for (i = 0; i < MAP_SIZE; i++) { + if (buf[i] == VAL) + continue; + fail("%d: %d != %d\n", i, buf[i], VAL); + goto out; + } + pass(); +out: + return 0; +} diff --git a/test/zdtm/static/s390x_mmap_high.desc b/test/zdtm/static/s390x_mmap_high.desc new file mode 100644 index 000000000..8621263f2 --- /dev/null +++ b/test/zdtm/static/s390x_mmap_high.desc @@ -0,0 +1 @@ +{'arch': 's390x'}