summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/mm/migration.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/mm/migration.c')
-rw-r--r--tools/testing/selftests/mm/migration.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c
index 1cec8425e3ca..379581567f27 100644
--- a/tools/testing/selftests/mm/migration.c
+++ b/tools/testing/selftests/mm/migration.c
@@ -95,12 +95,15 @@ int migrate(uint64_t *ptr, int n1, int n2)
void *access_mem(void *ptr)
{
- uint64_t y = 0;
+ volatile uint64_t y = 0;
volatile uint64_t *x = ptr;
while (1) {
pthread_testcancel();
y += *x;
+
+ /* Prevent the compiler from optimizing out the writes to y: */
+ asm volatile("" : "+r" (y));
}
return NULL;