]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/mm: fix usage of FORCE_READ() in cow tests
authorKevin Brodsky <kevin.brodsky@arm.com>
Thu, 22 Jan 2026 17:02:19 +0000 (17:02 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 31 Jan 2026 22:22:41 +0000 (14:22 -0800)
Commit 5bbc2b785e63 ("selftests/mm: fix FORCE_READ to read input value
correctly") modified FORCE_READ() to take a value instead of a pointer.
It also changed most of the call sites accordingly, but missed many of
them in cow.c.  In those cases, we ended up with the pointer itself being
read, not the memory it points to.

No failure occurred as a result, so it looks like the tests work just fine
without faulting in.  However, the huge_zeropage tests explicitly check
that pages are populated, so those became skipped.

Convert all the remaining FORCE_READ() to fault in the mapped page, as was
originally intended.  This allows the huge_zeropage tests to run again (3
tests in total).

Link: https://lkml.kernel.org/r/20260122170224.4056513-5-kevin.brodsky@arm.com
Fixes: 5bbc2b785e63 ("selftests/mm: fix FORCE_READ to read input value correctly")
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: SeongJae Park <sj@kernel.org>
Reviewed-by: wang lian <lianux.mm@gmail.com>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Usama Anjum <Usama.Anjum@arm.com>
Cc: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/cow.c

index accfd198dbda8408267e6fd6f5eb377b63497ae4..83b3563be26b65f450752bde8b3160c3c486625e 100644 (file)
@@ -1612,8 +1612,8 @@ static void run_with_huge_zeropage(non_anon_test_fn fn, const char *desc)
         * the first sub-page and test if we get another sub-page populated
         * automatically.
         */
-       FORCE_READ(mem);
-       FORCE_READ(smem);
+       FORCE_READ(*mem);
+       FORCE_READ(*smem);
        if (!pagemap_is_populated(pagemap_fd, mem + pagesize) ||
            !pagemap_is_populated(pagemap_fd, smem + pagesize)) {
                ksft_test_result_skip("Did not get THPs populated\n");
@@ -1663,8 +1663,8 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)
        }
 
        /* Fault the page in. */
-       FORCE_READ(mem);
-       FORCE_READ(smem);
+       FORCE_READ(*mem);
+       FORCE_READ(*smem);
 
        fn(mem, smem, pagesize);
 munmap:
@@ -1719,8 +1719,8 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)
        }
 
        /* Fault the page in. */
-       FORCE_READ(mem);
-       FORCE_READ(smem);
+       FORCE_READ(*mem);
+       FORCE_READ(*smem);
 
        fn(mem, smem, pagesize);
 munmap:
@@ -1773,8 +1773,8 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
        }
 
        /* Fault the page in. */
-       FORCE_READ(mem);
-       FORCE_READ(smem);
+       FORCE_READ(*mem);
+       FORCE_READ(*smem);
 
        fn(mem, smem, hugetlbsize);
 munmap: