mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Giorgi Tchankvetadze via B4 Relay <devnull+giorgitchankvetadze1997.gmail.com@kernel.org>
To: Mike Rapoport <rppt@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
Subject: [PATCH v2] mm: mm_init: use div64_ul() instead of do_div()
Date: Tue, 02 Jun 2026 15:32:45 +0400	[thread overview]
Message-ID: <20260602-mm-div64-cleanup-v1-1-bf5d67d89d93@gmail.com> (raw)

From: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>

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.

There are no functional changes. The benefit is purely a semantic cleanup
that better communicates the intent of the division and resolves the
static analysis warning.

Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
---
v2:
- Add changelog text explaining that the change is a semantic cleanup
  with no functional impact, as requested by Mike Rapoport.
---
 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 f9f8e1af921cda91d812cffdad2f1a0698cfd6ac..4e0909a721d227b097653ed6aaa019960a7c3383 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2412,7 +2412,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);
 

---
base-commit: 6f3ed7fec72fc8979b2a8c7219c0a9fcfc8d07b5
change-id: 20260602-mm-div64-cleanup-50ad2020f2da

Best regards,
-- 
Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>



             reply	other threads:[~2026-06-02 11:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 11:32 Giorgi Tchankvetadze via B4 Relay [this message]
2026-06-02 13:11 ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260602-mm-div64-cleanup-v1-1-bf5d67d89d93@gmail.com \
    --to=devnull+giorgitchankvetadze1997.gmail.com@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=giorgitchankvetadze1997@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®