diff options
Diffstat (limited to 'tools/testing/selftests/mm/vm_util.c')
| -rw-r--r-- | tools/testing/selftests/mm/vm_util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c index 1d434772fa54..9dafa7669ef9 100644 --- a/tools/testing/selftests/mm/vm_util.c +++ b/tools/testing/selftests/mm/vm_util.c @@ -532,3 +532,26 @@ void *sys_mremap(void *old_address, unsigned long old_size, old_size, new_size, flags, (unsigned long)new_address); } + +bool detect_huge_zeropage(void) +{ + int fd = open("/sys/kernel/mm/transparent_hugepage/use_zero_page", + O_RDONLY); + bool enabled = 0; + char buf[15]; + int ret; + + if (fd < 0) + return 0; + + ret = pread(fd, buf, sizeof(buf), 0); + if (ret > 0 && ret < sizeof(buf)) { + buf[ret] = 0; + + if (strtoul(buf, NULL, 10) == 1) + enabled = 1; + } + + close(fd); + return enabled; +} |
