aboutsummaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 956f66ab4a..94d81b9ec0 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -361,7 +361,19 @@ static void *do_touch_pages(void *arg)
memset_thread_failed = true;
} else {
for (i = 0; i < numpages; i++) {
- memset(addr, 0, 1);
+ /*
+ * Read & write back the same value, so we don't
+ * corrupt existing user/app data that might be
+ * stored.
+ *
+ * 'volatile' to stop compiler optimizing this away
+ * to a no-op
+ *
+ * TODO: get a better solution from kernel so we
+ * don't need to write at all so we don't cause
+ * wear on the storage backing the region...
+ */
+ *(volatile char *)addr = *addr;
addr += hpagesize;
}
}