On 2025/9/17 21:08, David Hildenbrand wrote:
On 17.09.25 14:27, Lance Yang wrote:
From: Lance Yang <lance.y...@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.


Oops, I missed "Suggested-by:" here ... will add in v3.

Signed-off-by: Lance Yang <lance.y...@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");

Nice. Will do ;)



LGTM

Acked-by: David Hildenbrand <da...@redhat.com>

Thanks,
Lance


Reply via email to