diff --git a/tests/page_fault4.c b/tests/page_fault4.c new file mode 100644 index 0000000..67cfd09 --- /dev/null +++ b/tests/page_fault4.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +#define MEMSIZE (128 * 1024 * 1024) + +char *testcase_description = "Separate file private mapping page read fault"; + +void testcase(unsigned long long *iterations, unsigned long nr) +{ + char tmpfile[] = "/tmp/willitscale.XXXXXX"; + int fd = mkstemp(tmpfile); + unsigned long pgsize = getpagesize(); + + assert(fd >= 0); + assert(ftruncate(fd, MEMSIZE) == 0); + unlink(tmpfile); + + while (1) { + unsigned long i; + char cc __attribute__((unused)); + + char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE, fd, 0); + assert(c != MAP_FAILED); + + for (i = 0; i < MEMSIZE; i += pgsize) { + cc = *(volatile char *)(c + i); + (*iterations)++; + } + + munmap(c, MEMSIZE); + } +}