Re: [PATCH] mm/damon/paddr: avoid truncation warning in high-address KUnit test

From: Enze Li

Date: Wed Nov 18 2026 - 08:19:04 EST




On 2026/11/18 01:04, Aveline Noir wrote:
> Hi SJ, Andrew,
>
> The kernel test robot caught this issue in my earlier addr_unit KUnit
> patch. Feel free to fold this fix into that patch.
>
> Thanks,
> Aveline Noir
>
> -- >8 --
> When phys_addr_t is 32-bit, Sparse warns about truncating the u64 address
> passed to damon_pa_core_addr() in damon_test_pa_addr_over_4g(). The
> runtime kunit_skip() does not prevent Sparse from checking that
> conversion.
>
> Compile the high-address assertions only with CONFIG_PHYS_ADDR_T_64BIT,
> and keep the test skipped otherwise.
>
> Fixes: 7a983cc1b573 ("mm/damon/paddr: add KUnit tests for addr_unit conversion")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/20261117170155.fEdeuuhm-lkp@xxxxxxxxx/
> Signed-off-by: Aveline Noir <jm5905938@xxxxxxxxx>

Reviewed-by: Enze Li <lienze@xxxxxxxxxx>

Thanks,
Enze

> ---
> The reported warning is gone with the original i386 config, Clang 22.1.8
> and Sparse v0.6.5-rc1-21-g84ec0658. All executed DAMON KUnit tests passed
> on x86_64 and i386 with and without PAE; the high-address case skips
> without PAE.
> ---
> mm/damon/tests/paddr-kunit.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/damon/tests/paddr-kunit.h b/mm/damon/tests/paddr-kunit.h
> index 9839cc233071..2b11f0e67a12 100644
> --- a/mm/damon/tests/paddr-kunit.h
> +++ b/mm/damon/tests/paddr-kunit.h
> @@ -26,15 +26,16 @@ static void damon_test_pa_core_addr(struct kunit *test)
>
> static void damon_test_pa_addr_over_4g(struct kunit *test)
> {
> +#ifdef CONFIG_PHYS_ADDR_T_64BIT
> unsigned long addr = 0xffffffffUL;
> unsigned long addr_unit = 0x1000;
> u64 pa = 0xffffffff000ULL;
>
> - if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT))
> - kunit_skip(test, "phys_addr_t is 32-bit");
> -
> KUNIT_EXPECT_EQ(test, damon_pa_phys_addr(addr, addr_unit), pa);
> KUNIT_EXPECT_EQ(test, damon_pa_core_addr(pa, addr_unit), addr);
> +#else
> + kunit_skip(test, "phys_addr_t is 32-bit");
> +#endif
> }
>
> static struct kunit_case damon_paddr_test_cases[] = {
>
> ---
> base-commit: 7a983cc1b57309a875a9e07a934c9944bf3d088d
> change-id: 20261118-fix-damon-paddr-sparse-20261118-fb08902768d7