Re: [PATCH v6 1/5] vdso/math64: Use OPTIMIZER_HIDE_VAR() in __iter_div_u64_rem()
From: Thomas Weißschuh
Date: Thu Oct 01 2026 - 03:00:00 EST
On Wed, Sep 30, 2026 at 11:44:56PM +0800, Zhan Xusheng wrote:
(...)
> Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
> ---
> include/vdso/math64.h | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/include/vdso/math64.h b/include/vdso/math64.h
> index 22ae212f8b28..c628d6cf447c 100644
> --- a/include/vdso/math64.h
> +++ b/include/vdso/math64.h
> @@ -2,15 +2,16 @@
> #ifndef __VDSO_MATH64_H
> #define __VDSO_MATH64_H
>
> -static __always_inline u32
> -__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
> +static __always_inline u32 __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
> {
> u32 ret = 0;
>
> while (dividend >= divisor) {
> - /* The following asm() prevents the compiler from
> - optimising this loop into a modulo operation. */
> - asm("" : "+rm"(dividend));
> + /*
> + * Prevent the compiler from optimising this loop into a
> + * modulo operation.
> + */
> + OPTIMIZER_HIDE_VAR(dividend);
This still requires '#include <linux/compiler.h>'.
See https://lore.kernel.org/lkml/202609300626.zwNjKaO6-lkp@xxxxxxxxx/
>
> dividend -= divisor;
> ret++;
> --
> 2.43.0
>