Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm: check that FORCE_READ() succeeded

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.

Link: https://lkml.kernel.org/r/20260122170224.4056513-6-kevin.brodsky@arm.com
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: 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: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Usama Anjum <Usama.Anjum@arm.com>
Cc: wang lian <lianux.mm@gmail.com>
Cc: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kevin Brodsky and committed by
Andrew Morton
20d3fac4 bce1dabd

+33 -10
+33 -10
tools/testing/selftests/mm/cow.c
··· 75 75 return true; 76 76 } 77 77 78 + static bool populate_page_checked(char *addr) 79 + { 80 + bool ret; 81 + 82 + FORCE_READ(*addr); 83 + ret = pagemap_is_populated(pagemap_fd, addr); 84 + if (!ret) 85 + ksft_print_msg("Failed to populate page\n"); 86 + 87 + return ret; 88 + } 89 + 78 90 struct comm_pipes { 79 91 int child_ready[2]; 80 92 int parent_ready[2]; ··· 1561 1549 } 1562 1550 1563 1551 /* Read from the page to populate the shared zeropage. */ 1564 - FORCE_READ(*mem); 1565 - FORCE_READ(*smem); 1552 + if (!populate_page_checked(mem) || !populate_page_checked(smem)) { 1553 + log_test_result(KSFT_FAIL); 1554 + goto munmap; 1555 + } 1566 1556 1567 1557 fn(mem, smem, pagesize); 1568 1558 munmap: ··· 1626 1612 * the first sub-page and test if we get another sub-page populated 1627 1613 * automatically. 1628 1614 */ 1629 - FORCE_READ(*mem); 1630 - FORCE_READ(*smem); 1615 + if (!populate_page_checked(mem) || !populate_page_checked(smem)) { 1616 + log_test_result(KSFT_FAIL); 1617 + goto munmap; 1618 + } 1619 + 1631 1620 if (!pagemap_is_populated(pagemap_fd, mem + pagesize) || 1632 1621 !pagemap_is_populated(pagemap_fd, smem + pagesize)) { 1633 1622 ksft_test_result_skip("Did not get THPs populated\n"); ··· 1680 1663 } 1681 1664 1682 1665 /* Fault the page in. */ 1683 - FORCE_READ(*mem); 1684 - FORCE_READ(*smem); 1666 + if (!populate_page_checked(mem) || !populate_page_checked(smem)) { 1667 + log_test_result(KSFT_FAIL); 1668 + goto munmap; 1669 + } 1685 1670 1686 1671 fn(mem, smem, pagesize); 1687 1672 munmap: ··· 1738 1719 } 1739 1720 1740 1721 /* Fault the page in. */ 1741 - FORCE_READ(*mem); 1742 - FORCE_READ(*smem); 1722 + if (!populate_page_checked(mem) || !populate_page_checked(smem)) { 1723 + log_test_result(KSFT_FAIL); 1724 + goto munmap; 1725 + } 1743 1726 1744 1727 fn(mem, smem, pagesize); 1745 1728 munmap: ··· 1794 1773 } 1795 1774 1796 1775 /* Fault the page in. */ 1797 - FORCE_READ(*mem); 1798 - FORCE_READ(*smem); 1776 + if (!populate_page_checked(mem) || !populate_page_checked(smem)) { 1777 + log_test_result(KSFT_FAIL); 1778 + goto munmap; 1779 + } 1799 1780 1800 1781 fn(mem, smem, hugetlbsize); 1801 1782 munmap: