From 57359ce1cfd0d409c556377384a315db85395fc9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 18 Feb 2017 23:14:27 +0000 Subject: [PATCH] stress-iomix: force page to be be read even on high optimization levels Signed-off-by: Colin Ian King --- stress-iomix.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stress-iomix.c b/stress-iomix.c index 204c71fdb..ff3b0c895 100644 --- a/stress-iomix.c +++ b/stress-iomix.c @@ -356,10 +356,16 @@ static void stress_iomix_rd_wr_mmap(const args_t *args, const int fd) PROT_READ | PROT_WRITE, flags, fd, posn); } for (i = 0; i < SIZEOF_ARRAY(mmaps); i++) { - char buffer[page_size]; - if (mmaps[i] != MAP_FAILED) { - memcpy(buffer, mmaps[i], page_size); + size_t j; + uint64_t sum = 0; + uint8_t *buffer = (uint8_t *)mmaps[i]; + + /* Force page data to be read */ + for (j = 0; j < page_size; j++) + sum += buffer[j]; + uint64_put(sum); + stress_strnrnd(mmaps[i], page_size); (void)shim_msync(mmaps[i], page_size, (mwc32() & 1) ? MS_ASYNC : MS_SYNC);