On 1/22/26 18:02, Kevin Brodsky wrote:
Many cow tests rely on FORCE_READ() to populate pages. Introduce a
helper to make sure that the pages are actually populated, and fail
otherwise.

Suggested-by: David Hildenbrand (Red Hat) <[email protected]>
Signed-off-by: Kevin Brodsky <[email protected]>
---
  tools/testing/selftests/mm/cow.c | 43 ++++++++++++++++++++++++--------
  1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 83b3563be26b..d9c69c04b67d 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -75,6 +75,18 @@ static bool range_is_swapped(void *addr, size_t size)
        return true;
  }
+static bool populate_page_checked(char *addr)
+{
+       bool ret;
+
+       FORCE_READ(*addr);
+       ret = pagemap_is_populated(pagemap_fd, addr);
+       if (!ret)
+               ksft_print_msg("Failed to populate page\n");
+
+       return ret;
+}

LGTM.

On second thought, this primarily catches if someone breaks FORCE_READ() ... which hopefully doesn't happen that often? ;)

Because if the read succeeded, surely there must be something in the page tables.

--
Cheers

David

Reply via email to