Commit 513ab44a authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

zdtm: add test for prctl(PR_SET_THP_DISABLE)

Verify that enabling / disabling THP with prctl(PR_SET_THP_DISABLE) does
not change VMA flags
Signed-off-by: 's avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 0493724c
......@@ -208,6 +208,7 @@ TST_NOFILE := \
netns_sub_veth \
unlink_multiple_largefiles \
config_inotify_irmap \
thp_disable \
# jobctl00 \
ifneq ($(SRCARCH),arm)
......@@ -500,6 +501,7 @@ mntns_shared_bind02: CFLAGS += -DSHARED_BIND02
mntns_root_bind02: CFLAGS += -DROOT_BIND02
maps02: get_smaps_bits.o
mlock_setuid: get_smaps_bits.o
thp_disable: get_smaps_bits.o
inotify01: CFLAGS += -DINOTIFY01
unlink_fstat01+: CFLAGS += -DUNLINK_OVER
unlink_fstat04: CFLAGS += -DUNLINK_FSTAT04
......
#include <sys/prctl.h>
#include <sys/mman.h>
#include "zdtmtst.h"
#include "get_smaps_bits.h"
#ifndef MADV_DONTDUMP
#define MADV_DONTDUMP 16
#endif
const char *test_doc = "Test prctl(THP_DISABLE) behaviour";
const char *test_author = "Mike Rapoport <rppt@linux.ibm.com>";
#define MEM_SIZE (8192)
int main(int argc, char **argv)
{
unsigned long orig_flags = 0, new_flags = 0;
unsigned long orig_madv = 0, new_madv = 0;
void *area;
test_init(argc, argv);
area = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (area == MAP_FAILED) {
pr_perror("mmap failed");
return -1;
}
test_msg("Fetch existing flags/adv\n");
if (get_smaps_bits((unsigned long)area, &orig_flags, &orig_madv))
return -1;
if (prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0)) {
pr_perror("Disabling THP failed");
return -1;
}
test_daemon();
test_waitsig();
if (prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0)) {
pr_perror("Enabling THP failed");
return -1;
}
test_msg("Fetch restored flags/adv\n");
if (get_smaps_bits((unsigned long)area, &new_flags, &new_madv))
return -1;
if (orig_flags != new_flags) {
pr_err("Flags are changed %lx -> %lx\n", orig_flags, new_flags);
fail();
return -1;
}
if (orig_madv != new_madv) {
pr_err("Madvs are changed %lx -> %lx\n", orig_madv, new_madv);
fail();
return -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