[CRIU] [PATCH v1] test: fix bug with huge PAGE_SIZE in transition/maps008

Eugene Batalov eabatalov89 at gmail.com
Thu Sep 8 11:21:19 PDT 2016


Before this patch vma sizes were hardcoded and weren't derived
from PAGE_SIZE value.
But all the actions with these vmas are based on PAGE_SIZE value.
That's why maps008 on PowerPC with "huge" PAGE_SIZE of 64k was simply
terminating due to invalid memory access.

This commit sets vma sizes to safe values derived from PAGE_SIZE.
New sizes are enough to perform all the actions test does with vmas.

Cc: Laurent Dufour <ldufour at linux.vnet.ibm.com>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 test/zdtm/transition/maps008.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/test/zdtm/transition/maps008.c b/test/zdtm/transition/maps008.c
index b05ee7f..4a3e2a5 100644
--- a/test/zdtm/transition/maps008.c
+++ b/test/zdtm/transition/maps008.c
@@ -195,9 +195,7 @@ struct test_sync {
 };
 struct test_sync *test_sync;
 
-size_t mem1_size = 1L << 20;
-size_t mem2_size = 1L << 21;
-size_t mem3_size = 1L << 22;
+size_t mem1_size, mem2_size, mem3_size;
 uint8_t *mem1, *mem2, *mem3;
 
 #define CRC_EPOCH_OFFSET (PAGE_SIZE - sizeof(uint32_t))
@@ -288,8 +286,8 @@ static int proc131_func(task_waiter_t *setup_waiter)
 
 static int proc13_func(task_waiter_t *setup_waiter)
 {
-	size_t MEM1_HOLE_START = 10 * MEM_PERIOD;
-	size_t MEM1_HOLE_SIZE = 3 * MEM_PERIOD;
+	size_t MEM1_HOLE_START = 2 * MEM_PERIOD;
+	size_t MEM1_HOLE_SIZE = 1 * MEM_PERIOD;
 	uint32_t crc_epoch = 0;
 
 	pstree->proc13 = getpid();
@@ -376,7 +374,7 @@ static int proc112_func(task_waiter_t *setup_waiter)
 
 static int proc11_func(task_waiter_t *setup_waiter)
 {
-	const size_t MEM3_START_CUT = 5 * MEM_PERIOD;
+	const size_t MEM3_START_CUT = 1 * MEM_PERIOD;
 	const size_t MEM3_END_CUT = 2 * MEM_PERIOD;
 	void *mem3_old = mem3;
 	size_t mem3_size_old = mem3_size;
@@ -425,11 +423,23 @@ static int proc11_func(task_waiter_t *setup_waiter)
 	return 0;
 }
 
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MB(n) ((n) * (1UL << 20))
+
 static int proc1_func(void)
 {
 	uint32_t crc_epoch = 0;
 	uint8_t *mem2_old = NULL;
 
+	/*
+	 * Min mem size:
+	 * At least 5 mem periods for mem pages and vma holes.
+	 * At least 1 MB mem size not to test on tiny working set.
+	 */
+	mem1_size = MEM_PERIOD * MAX(5, MB(1) / MEM_PERIOD + 1);
+	mem2_size = mem1_size * 2;
+	mem3_size = mem2_size * 3;
+
 	futex_set(&test_sync->datagen, 1);
 	pstree->proc1 = getpid();
 	mem1 = mmap_ashmem(mem1_size);
-- 
1.9.1



More information about the CRIU mailing list