All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] mm: mm_init: use div64_ul() instead of do_div()
  2026-06-01 12:11 [PATCH] mm: mm_init: use div64_ul() instead of do_div() Giorgi Tchankvetadze
@ 2026-06-01 11:15 ` Mike Rapoport
  2026-06-01 15:26   ` Giorgi Tchankvetadze
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2026-06-01 11:15 UTC (permalink / raw)
  To: Giorgi Tchankvetadze; +Cc: Andrew Morton, linux-mm, linux-kernel

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@gmail.com>
> ---
>  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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: mm_init: use div64_ul() instead of do_div()
  2026-06-01 15:26   ` Giorgi Tchankvetadze
@ 2026-06-01 12:04     ` Mike Rapoport
  2026-06-01 15:47       ` Giorgi Tchankvetadze
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2026-06-01 12:04 UTC (permalink / raw)
  To: Giorgi Tchankvetadze; +Cc: Andrew Morton, linux-mm, linux-kernel

On Mon, Jun 01, 2026 at 07:26:00PM +0400, Giorgi Tchankvetadze wrote:
> On Mon, Jun 1, 2026 at 3:15 PM Mike Rapoport <rppt@kernel.org> wrote:
> >
> > Can you describe what are the actual visible effects?
> >
> 
> Hey Mike.
> The only benefit and effect is a semantic cleanup, it better
> communicates the intent of the division and resolves the Coccinelle
> static analysis warning.

Can you please add something along these lines to the changelog?
 
> --
> Giorgi

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] mm: mm_init: use div64_ul() instead of do_div()
@ 2026-06-01 12:11 Giorgi Tchankvetadze
  2026-06-01 11:15 ` Mike Rapoport
  0 siblings, 1 reply; 5+ messages in thread
From: Giorgi Tchankvetadze @ 2026-06-01 12:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mike Rapoport, linux-mm, linux-kernel, Giorgi Tchankvetadze

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.

Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
---
 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: mm_init: use div64_ul() instead of do_div()
  2026-06-01 11:15 ` Mike Rapoport
@ 2026-06-01 15:26   ` Giorgi Tchankvetadze
  2026-06-01 12:04     ` Mike Rapoport
  0 siblings, 1 reply; 5+ messages in thread
From: Giorgi Tchankvetadze @ 2026-06-01 15:26 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-mm, linux-kernel

On Mon, Jun 1, 2026 at 3:15 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> Can you describe what are the actual visible effects?
>

Hey Mike.
The only benefit and effect is a semantic cleanup, it better
communicates the intent of the division and resolves the Coccinelle
static analysis warning.

--
Giorgi


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: mm_init: use div64_ul() instead of do_div()
  2026-06-01 12:04     ` Mike Rapoport
@ 2026-06-01 15:47       ` Giorgi Tchankvetadze
  0 siblings, 0 replies; 5+ messages in thread
From: Giorgi Tchankvetadze @ 2026-06-01 15:47 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-mm, linux-kernel

On Mon, Jun 1, 2026 at 4:04 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> Can you please add something along these lines to the changelog?
>

Sure thing.  I will make sure to fix the changelon in v2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-01 12:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01 12:11 [PATCH] mm: mm_init: use div64_ul() instead of do_div() Giorgi Tchankvetadze
2026-06-01 11:15 ` Mike Rapoport
2026-06-01 15:26   ` Giorgi Tchankvetadze
2026-06-01 12:04     ` Mike Rapoport
2026-06-01 15:47       ` Giorgi Tchankvetadze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.