mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
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/20250707073321.106431-1-usama.anjum@collabora.com Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: David Hildenbrand <david@redhat.com> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
0b473f9e6e
commit
f73858d5ef
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user