From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4FA3B8C1F for ; Mon, 10 Aug 2026 01:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786324443; cv=none; b=cK/xn9YyPb1IJWSQIb7f3EyajJRnyO+A9JVnAngyW8nKirU0BSMRfPThIVoe3w5XXh5vFtokacnS6kZqbLTiSl/wyVm9P8/5Gvl6CE49XDcBxo3zhq7KRabqwKeJuLeXgRMXVxzHvbfTl0UcRHhSmwiFWZanVVYO1nO9ufr8S0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786324443; c=relaxed/simple; bh=oOaGMZxiZvCVtr4E2KMFWEdD83y5oZN2zXiXwIRvHGA=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=hpyYbg36uaTMBH5ruqvhzE02i2vG6KW3xH5JT1FpdAQS8qR80l5paXri0IEmshmPnYLwo9tuX6JD0J3LQy+pFlExDFpY71CeS6li3FTFPPyDiIUgAZ6TLR5dIOTR4+ZyDnYF+t6QGtK54Ktkg0oW0m9wLtYsuF7pOC+Y2uKVAPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=o2KUorhb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="o2KUorhb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 935A01F00A3A; Mon, 10 Aug 2026 01:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786324441; bh=XJf0z6sUiaazaZvfWd5l1yYgeWUpiziiNrcD8oTAC9o=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=o2KUorhbWIilkehLn/42i4as5RFncyUcX+gnOmLSRVchtqBty0Ya2HAdFtKfoCtNi hvsWMcNSbZ13TjfnWE2LjMLDooSpR/VI1qO+IGUIshRLjvsmFhINCAHX3cxkSaj42o RfONb0zUc8kYIhajHpMvLBv7bZkvhbhGybi1w81M= Date: Sun, 9 Aug 2026 18:14:00 -0700 From: Andrew Morton To: Longlong Xia Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Longlong Xia Subject: Re: [PATCH 1/1] mm/mm_init: compute hash mask with unsigned arithmetic Message-Id: <20260809181400.148e68eff30394f6b029f4d1@linux-foundation.org> In-Reply-To: References: <20260809123119.3811851-1-xialonglong2025@163.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sun, 9 Aug 2026 22:25:35 +0800 Longlong Xia wrote: > 在 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. It's a very small thing, but I believe the patch improves the code. I mean, we erroneously compute a large negative number then subtract 1 from it then copy that larger negative number into a signed scalar. The copied bit pattern happens to be what we'd have got if the code had been correct, but the code isn't correct!