From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8BDD81990C7 for ; Thu, 11 Dec 2025 20:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765483489; cv=none; b=Bcyz400yPrDA+p5hoD6h5/AxZS+Q9Wrlfgyxvp5hBHf+uC6su8BmnWUODvzOxats7h5wZuc8d4wl7jFYxnnp+QZmW1l1f5SOvt1i1yJ6bsC5PNKnWr/KEn24bjSicWWIqaGC5XErBv4eb1oe65F0hEWyeTPpScZpOmnLFf+G/Do= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765483489; c=relaxed/simple; bh=tWPJ6Cx/h6JkS/7/YzHeKANRm/xCo+1cG3XgCtCuwiU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=hb1XcqVoqvqMd5nGkxrwEJm6Xb0NpFhi1U9seKhiiQj6i1OQsn4+LNg4Brm8jM73AzXqLMqJOtAQPT1e7nNjQ1Gi9kE97nDMRf978/WG10JElG7o4+kP7o2CSsiB28TrU8OYbbcM3g9vXwG95mijewiv+MyPiopYm7vo49se7Sg= 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=XrOBsbtw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="XrOBsbtw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05389C4CEF7; Thu, 11 Dec 2025 20:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1765483489; bh=tWPJ6Cx/h6JkS/7/YzHeKANRm/xCo+1cG3XgCtCuwiU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XrOBsbtw/XYB5npPaSynS4CV4AMBE2tY55tK5rZrPjTRu1Ksi+UU4XhlDi22CE3Lh 7tBaBeRWmxegG5MC/sLM8ADqsy9h6jyPyZft5mRFvka/pPpPov08ffOJV/IX2oU9m4 Fow9Q5ZBHE07MmhCD/rVrE8InQjUJnoTCzLLXRas= Date: Thu, 11 Dec 2025 12:04:48 -0800 From: Andrew Morton To: Yankai Xu <815559068@qq.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm/gfp: cast GFP_ZONE_TABLE entries to long to avoid shift overflow Message-Id: <20251211120448.817a352350813ae84cb600b3@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (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=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 11 Dec 2025 18:24:05 +0800 Yankai Xu <815559068@qq.com> wrote: > > When a new zone is added to enum zone_type in mmzone.h, the existing > GFP_ZONE_TABLE macro causes a compile-time shift overflow. Thanks. Please quote the compiler warning messages and describe how to reproduce this. Please include this info in the patch changelog and maintain it. > This happens > because enum zone_type is of type int. The shift is logically > valid because it has been checked by 16 * GFP_ZONES_SHIFT > BITS_PER_LONG previously. > > Fixed this by casting each value in GFP_ZONE_TABLE to type long. > > ... > > #define GFP_ZONE_TABLE ( \ > - (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT) \ > + ((long)ZONE_NORMAL << 0 * GFP_ZONES_SHIFT) \ It would be nice to find something nicer than this. Perhaps a type of something was poorly chosen.