From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9083E1C5F1B for ; Sun, 9 Aug 2026 14:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786285609; cv=none; b=e33/xU37ZvFLktOkR1xWHUnjIHU93m+/ObFLhE6nbLKMj9NOi8t1XidE8CjIqSyISK6JLbuUGwsHcNy54b8nmtsuN354Alum6aDFVKAneTfuIF/9bcKXyOkM4P/pfrDO1OJQHQ4V7Os9K6TUE1YnIJzW1mU7JwzdePh+bJLaFvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786285609; c=relaxed/simple; bh=hjE3acST3qY1nlKmyMw9orY+chL9tZ3eWEhPAN2N4Vc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=J5Imc01FEpvxhSYlcKg132Yc5kdr2PEXagp+I9vjnrxnpTKTgmsSQcn9RZ5j/mVLCHJkKDcuNsgmXRVQ7NS9tpzoUuJJ7pROVk00mATShUMw67cFTNKSKyHFV5fLJN2REnDooorpF//7syA+zj2yVEEYI778+PTgMRPuRHKwzBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=S6DufPc2; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="S6DufPc2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=NmfHFZFlRMH+AE36QnnPJkTyHKY6El3hxsPbGLP+Ls0=; b=S6DufPc2O/YT32LMuSA/AdqWCyNQhAcJy23Bz2nopamNml4tVXCG++BHKSbkrB aGLyCWmzlVwaRavJjsLKVjh5RiMDqtjgOuE3pZC3ild5KoqysFbEnfYbIYX20b9j TZEzo0Y4XQ7fHG3IgqLdiCmAtvPc+23/ynCSx4FOX2zvQ= Received: from [198.18.0.1] (unknown []) by gzsmtp5 (Coremail) with SMTP id QCgvCgDXFzX0jXhqGeCwLQ--.53195S2; Sun, 09 Aug 2026 22:26:00 +0800 (CST) Message-ID: Date: Sun, 9 Aug 2026 22:25:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] mm/mm_init: compute hash mask with unsigned arithmetic To: Mike Rapoport Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Longlong Xia References: <20260809123119.3811851-1-xialonglong2025@163.com> From: Longlong Xia In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:QCgvCgDXFzX0jXhqGeCwLQ--.53195S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFy5Cr15KFW5KrW7AryUAwb_yoW8XrWxpF W8t3W8KayDZFsFk3sFvFZxXrn8JaySyrsxGw4jyF4UZrn8CFn0qF4kK398ua9xtr48Wa1a 9F4kXa4kXa1YkaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UczV8UUUUU= X-CM-SenderInfo: x0ldz0pqjo00rjsqjki6rwjhhfrp/xtbC3BhaU2p4jfhvtwAA3y 在 2026/8/9 22:03, Mike Rapoport 写道: > Hi, > > On Sun, Aug 09, 2026 at 08:31:19PM +0800, Longlong Xia wrote: >> From: Longlong Xia >> >> 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 >> --- >> 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 >>