[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <q48550n6-94sq-90pr-6qrn-64r4r6429970@onlyvoer.pbz>
Date: Wed, 29 Oct 2025 16:48:43 -0400 (EDT)
From: Nicolas Pitre <npitre@...libre.com>
To: David Laight <david.laight.linux@...il.com>
cc: Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org,
u.kleine-koenig@...libre.com, Oleg Nesterov <oleg@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Biju Das <biju.das.jz@...renesas.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Li RongQing <lirongqing@...du.com>,
Yu Kuai <yukuai3@...wei.com>, Khazhismel Kumykov <khazhy@...omium.org>,
Jens Axboe <axboe@...nel.dk>, x86@...nel.org
Subject: Re: [PATCH v4 next 9/9] lib: test_mul_u64_u64_div_u64: Test the
32bit code on 64bit
On Wed, 29 Oct 2025, David Laight wrote:
> There are slight differences in the mul_u64_add_u64_div_u64() code
> between 32bit and 64bit systems.
>
> Compile and test the 32bit version on 64bit hosts for better test
> coverage.
>
> Signed-off-by: David Laight <david.laight.linux@...il.com>
Reviewed-by: Nicolas Pitre <npitre@...libre.com>
> ---
>
> Changes for v4:
> - Fix build on non x86-64
>
> lib/math/test_mul_u64_u64_div_u64.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/lib/math/test_mul_u64_u64_div_u64.c b/lib/math/test_mul_u64_u64_div_u64.c
> index a3c5e54f37ef..57d5c7158b10 100644
> --- a/lib/math/test_mul_u64_u64_div_u64.c
> +++ b/lib/math/test_mul_u64_u64_div_u64.c
> @@ -74,6 +74,10 @@ done
> */
>
> static u64 test_mul_u64_add_u64_div_u64(u64 a, u64 b, u64 c, u64 d);
> +#if __LONG_WIDTH__ >= 64
> +#define TEST_32BIT_DIV
> +static u64 test_mul_u64_add_u64_div_u64_32bit(u64 a, u64 b, u64 c, u64 d);
> +#endif
>
> static int __init test_run(unsigned int fn_no, const char *fn_name)
> {
> @@ -100,6 +104,12 @@ static int __init test_run(unsigned int fn_no, const char *fn_name)
> result = test_mul_u64_add_u64_div_u64(a, b, 0, d);
> result_up = test_mul_u64_add_u64_div_u64(a, b, d - 1, d);
> break;
> +#ifdef TEST_32BIT_DIV
> + case 2:
> + result = test_mul_u64_add_u64_div_u64_32bit(a, b, 0, d);
> + result_up = test_mul_u64_add_u64_div_u64_32bit(a, b, d - 1, d);
> + break;
> +#endif
> }
>
> tests += 2;
> @@ -131,6 +141,10 @@ static int __init test_init(void)
> return -EINVAL;
> if (test_run(1, "test_mul_u64_u64_div_u64"))
> return -EINVAL;
> +#ifdef TEST_32BIT_DIV
> + if (test_run(2, "test_mul_u64_u64_div_u64_32bit"))
> + return -EINVAL;
> +#endif
> return 0;
> }
>
> @@ -152,6 +166,21 @@ static void __exit test_exit(void)
>
> #include "div64.c"
>
> +#ifdef TEST_32BIT_DIV
> +/* Recompile the generic code for 32bit long */
> +#undef test_mul_u64_add_u64_div_u64
> +#define test_mul_u64_add_u64_div_u64 test_mul_u64_add_u64_div_u64_32bit
> +#undef BITS_PER_ITER
> +#define BITS_PER_ITER 16
> +
> +#define mul_u64_u64_add_u64 mul_u64_u64_add_u64_32bit
> +#undef mul_u64_long_add_u64
> +#undef add_u64_long
> +#undef mul_add
> +
> +#include "div64.c"
> +#endif
> +
> module_init(test_init);
> module_exit(test_exit);
>
> --
> 2.39.5
>
>
Powered by blists - more mailing lists