aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/mm/vm_util.c
diff options
context:
space:
mode:
authorMuhammad Usama Anjum <[email protected]>2025-07-07 07:33:20 +0000
committerAndrew Morton <[email protected]>2025-07-20 01:59:44 +0000
commitf73858d5ef93cb880aca64d826b4e3ca8b55365a (patch)
tree9b506cc5750aa9401172456989755a8a006dff75 /tools/testing/selftests/mm/vm_util.c
parentDocs/mm/damon/maintainer-profile: update for mm-new tree (diff)
downloadkernel-f73858d5ef93cb880aca64d826b4e3ca8b55365a.tar.gz
kernel-f73858d5ef93cb880aca64d826b4e3ca8b55365a.zip
selftests/mm: pagemap_scan ioctl: add PFN ZERO test cases
Add test cases to test the correctness of PFN ZERO flag of pagemap_scan ioctl. Test with normal pages backed memory and huge pages backed memory. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Muhammad Usama Anjum <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Muhammad Usama Anjum <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'tools/testing/selftests/mm/vm_util.c')
-rw-r--r--tools/testing/selftests/mm/vm_util.c23
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;
+}