Re: [PATCH v2] iommupt/kunit: Skip the page-table leak check on SMP

From: Jason Gunthorpe

Date: Mon Nov 16 2026 - 14:21:57 EST


On Sat, Oct 31, 2026 at 04:55:36PM +0800, fangyu.yu@xxxxxxxxxxxxxxxxx wrote:
> From: Fangyu Yu <fangyu.yu@xxxxxxxxxxxxxxxxx>
>
> NR_SECONDARY_PAGETABLE is batched per-CPU on SMP, so the global counter
> can change as pending updates are folded, even when a test has freed all
> its page tables. Comparing the global counter before and after a test
> can therefore report a false leak. A failed teardown assertion also
> aborts cleanup, causing subsequent tests to fail because the test driver
> is still registered.
>
> Only perform the leak-check assertion on non-SMP configurations, where
> there are no per-CPU vmstat deltas. Keep the tests and resource cleanup
> enabled on SMP without accessing MM's internal vmstat data structures.
>
> Fixes: bc5233c0904e ("iommupt: Add a kunit test for the IOMMU implementation")
> Signed-off-by: Fangyu Yu <fangyu.yu@xxxxxxxxxxxxxxxxx>
> ---
> Changes in v2:
> - Replace the hand-written vmstat snapshot with a non-SMP-only
> assertion, as suggested by Jason.
>
> Link to v1:
> https://lore.kernel.org/linux-iommu/20261015132024.43998-1-fangyu.yu@xxxxxxxxxxxxxxxxx/
> ---
> drivers/iommu/generic_pt/kunit_iommu_pt.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason