From ab33ae2d95359cabb9e211127c64fe2016e79f96 Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Mon, 10 Apr 2017 22:41:50 +0300 Subject: [PATCH] test/maps01: document mmap() failures Arm32 devices often have poor amount of RAM. E.g., RPI2 board has only 1Gb memory. This lead to failures with maps01 test, which tries to mmap() 1Gb of memory. The failures of test is not very evident - let's document mmap() errors here to blow some light on the situation. Acked-by: Cyrill Gorcunov Signed-off-by: Dmitry Safonov Signed-off-by: Andrei Vagin --- test/zdtm/static/maps01.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/test/zdtm/static/maps01.c b/test/zdtm/static/maps01.c index 8940119ef..119d7a6a4 100644 --- a/test/zdtm/static/maps01.c +++ b/test/zdtm/static/maps01.c @@ -11,10 +11,10 @@ #include #include "zdtmtst.h" -#define MEM_SIZE (1L << 30) -#define MEM_OFFSET (1L << 29) +#define MEM_SIZE (1LU << 30) +#define MEM_OFFSET (1LU << 29) #define MEM_OFFSET2 (MEM_SIZE - PAGE_SIZE) -#define MEM_OFFSET3 (20 * PAGE_SIZE) +#define MEM_OFFSET3 (20LU * PAGE_SIZE) const char *test_doc = "Test shared memory"; const char *test_author = "Andrew Vagin > 20); goto err; + } p = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) + if (p == MAP_FAILED) { + pr_err("Failed to mmap %ld Mb shared anonymous R/W memory\n", + MEM_SIZE >> 20); goto err; + } p2 = mmap(NULL, MEM_OFFSET, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (p2 == MAP_FAILED) + if (p2 == MAP_FAILED) { + pr_err("Failed to mmap %lu Mb anonymous memory\n", + MEM_OFFSET >> 20); goto err; + } pid = test_fork(); if (pid < 0) { + pr_err("Fork failed with %d\n", pid); goto err; } else if (pid == 0) { void *p3; p3 = mmap(NULL, MEM_OFFSET3, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (p3 == MAP_FAILED) + if (p3 == MAP_FAILED) { + pr_err("Failed to mmap %lu Mb anonymous R/W memory\n", + MEM_OFFSET3 >> 20); goto err; + } crc = ~0; datagen(m + MEM_OFFSET, PAGE_SIZE, &crc);