Re: [PATCH] mm: mm_init: use div64_ul() instead of do_div()
From: Mike Rapoport
Date: Mon Jun 01 2026 - 07:21:38 EST
Hi,
On Mon, Jun 01, 2026 at 04:11:23PM +0400, Giorgi Tchankvetadze wrote:
> Fixes Coccinelle/coccicheck warning reported by do_div.cocci.
>
> Compared to do_div(), div64_ul() does not implicitly cast the divisor and
> does not unnecessarily calculate the remainder.
Can you describe what are the actual visible effects?
> Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@xxxxxxxxx>
> ---
> mm/mm_init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index db5568cf36e1..4d335eb799e6 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2426,7 +2426,7 @@ void *__init alloc_large_system_hash(const char *tablename,
> /* limit allocation size to 1/16 total memory by default */
> if (max == 0) {
> max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4;
> - do_div(max, bucketsize);
> + max = div64_ul(max, bucketsize);
> }
> max = min(max, 0x80000000ULL);
>
> --
> 2.52.0
>
--
Sincerely yours,
Mike.