From: Mike Rapoport <rppt@kernel.org>
To: Longlong Xia <xialonglong2025@163.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Longlong Xia <xialonglong@kylinos.cn>
Subject: Re: [PATCH 1/1] mm/mm_init: compute hash mask with unsigned arithmetic
Date: Sun, 9 Aug 2026 17:03:37 +0300 [thread overview]
Message-ID: <aniIuZa53OBqCMbB@kernel.org> (raw)
In-Reply-To: <20260809123119.3811851-1-xialonglong2025@163.com>
Hi,
On Sun, Aug 09, 2026 at 08:31:19PM +0800, Longlong Xia wrote:
> From: Longlong Xia <xialonglong@kylinos.cn>
>
> alloc_large_system_hash() allows up to 2^31 buckets, so log2qty can
> reach 31. At that limit, the current expression relies on signed
> integer wrapping to produce the unsigned hash mask.
>
> Use an unsigned literal so the mask is computed with unsigned
> arithmetic. Supported compiler settings already produce the same
> result, so this is a source-level cleanup with no functional change.
If complier already takes care of this then why do we want this patch?
> Assisted-by: Codex:gpt-5.6-sol
> Signed-off-by: Longlong Xia <xialonglong@kylinos.cn>
> ---
> 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 498d62c4ece3..1883fe923ffb 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2469,7 +2469,7 @@ void *__init alloc_large_system_hash(const char *tablename,
> if (_hash_shift)
> *_hash_shift = log2qty;
> if (_hash_mask)
> - *_hash_mask = (1 << log2qty) - 1;
> + *_hash_mask = (1U << log2qty) - 1;
>
> return table;
> }
> --
> 2.43.0
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-08-09 14:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 12:31 [PATCH 1/1] mm/mm_init: compute hash mask with unsigned arithmetic Longlong Xia
2026-08-09 14:03 ` Mike Rapoport [this message]
2026-08-09 14:25 ` Longlong Xia
2026-08-10 1:14 ` Andrew Morton
2026-08-10 3:21 ` Matthew Wilcox
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=aniIuZa53OBqCMbB@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xialonglong2025@163.com \
--cc=xialonglong@kylinos.cn \
/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