On 17.09.25 14:27, Lance Yang wrote:
From: Lance Yang lance.yang@linux.dev
The madv_populate and soft-dirty kselftests currently fail on systems where CONFIG_MEM_SOFT_DIRTY is disabled.
Introduce a new helper softdirty_supported() into vm_util.c/h to ensure tests are properly skipped when the feature is not enabled.
Signed-off-by: Lance Yang lance.yang@linux.dev
[...]
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c index 56e9bd541edd..ac41d10454a5 100644 --- a/tools/testing/selftests/mm/vm_util.c +++ b/tools/testing/selftests/mm/vm_util.c @@ -449,6 +449,25 @@ bool check_vmflag_pfnmap(void *addr) return check_vmflag(addr, "pf"); } +bool softdirty_supported(void) +{
- char *addr;
- bool supported = false;
- const size_t pagesize = getpagesize();
- /* New mappings are expected to be marked with VM_SOFTDIRTY (sd). */
- addr = mmap(0, pagesize, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
- if (!addr)
ksft_exit_fail_msg("mmap failed\n");
- if (check_vmflag(addr, "sd"))
supported = true;
Reading the code again, this could just be
supported = check_vmflag(addr, "sd");
LGTM
Acked-by: David Hildenbrand david@redhat.com