Re: [PATCH 1/1] mm/mm_init: compute hash mask with unsigned arithmetic

Longlong Xia <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <[email protected]>
在 2026/8/9 22:03, Mike Rapoport 写道:
> Hi,
>
> On Sun, Aug 09, 2026 at 08:31:19PM +0800, Longlong Xia wrote:
>> From: Longlong Xia <[email protected]>
>>
>> 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?
>   
Fair point. Since supported compilers already produce the intended 
result and this patch has no functional impact, the benefit is only 
making the unsigned arithmetic explicit. So please disregard this patch.

Thanks for the review.

Best regards,
Longlong

>> Assisted-by: Codex:gpt-5.6-sol
>> Signed-off-by: Longlong Xia <[email protected]>
>> ---
>>   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
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.