--- memtester-orig/memtester-4.3.0/tests.c 2012-06-09 23:45:22.000000000 +0200 +++ memtester-4.3.0/tests.c 2018-06-24 18:08:03.194020598 +0200 @@ -11,14 +11,17 @@ * This file contains the functions for the actual tests, called from the * main routine in memtester.c. See other comments in that file. * */ +#define _GNU_SOURCE #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> +#include <sys/mman.h> +#define MADV_SOFT_OFFLINE 101 #include "types.h" #include "sizes.h" #include "memtester.h" @@ -46,10 +49,14 @@ (ul) *p1, (ul) *p2, physaddr); } else { fprintf(stderr, "FAILURE: 0x%08lx != 0x%08lx at offset 0x%08lx.\n", (ul) *p1, (ul) *p2, (ul) (i * sizeof(ul))); + void *page1 = (void*)(((unsigned long)p1) & ~0xfffUL); + void *page2 = (void*)(((unsigned long)p2) & ~0xfffUL); + if (madvise(page1, 0x1000, MADV_SOFT_OFFLINE)) perror("madvise1"); + if (madvise(page2, 0x1000, MADV_SOFT_OFFLINE)) perror("madvise1"); } /* printf("Skipping to next test..."); */ r = -1; } }