Commit b1aca099 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

test: add test that verifies proper intraction between lazy-pages and THP

Acked-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 9d45bb39
...@@ -20,6 +20,7 @@ TST_NOFILE = \ ...@@ -20,6 +20,7 @@ TST_NOFILE = \
socket-tcp \ socket-tcp \
socket-tcp6 \ socket-tcp6 \
shmem \ shmem \
lazy-thp \
TST_FILE = \ TST_FILE = \
......
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <linux/limits.h>
#include "zdtmtst.h"
#define N_PAGES 1024
const char *test_doc = "Test interaction between THP and lazy-pages";
/* The test is based on example by Adrian Reber <areber@redhat.com> */
const char *test_author = "Mike Rapoport <rppt@linux.vnet.ibm.com>";
int main(int argc, char ** argv)
{
char *mem, *org, *m;
int count;
test_init(argc, argv);
/* we presume that malloc returns not page aliged address */
mem = malloc(PAGE_SIZE * N_PAGES);
org = malloc(PAGE_SIZE);
if (!mem || !org) {
fail("malloc failed\n");
exit(1);
}
memset(mem, 0x42, PAGE_SIZE * N_PAGES);
memset(org, 0x42, PAGE_SIZE);
test_daemon();
while (test_go()) {
for (count = 0; count < N_PAGES; count += 2) {
m = mem + (count * PAGE_SIZE) + 128;
*m = count;
}
for (count = 0; count < N_PAGES; count++) {
m = mem+(count*PAGE_SIZE);
org[128] = (count % 2 == 0) ? count : 0x42;
if (memcmp(org, m, PAGE_SIZE)) {
fail("memory corruption\n");
return 1;
}
}
sleep(1);
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment