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 B704734FF41 for ; Fri, 13 Feb 2026 16:58:43 +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=1771001923; cv=none; b=e4IahJvOV2l25Hw27d0UBPLtlRjzBJfNYDI44McFIM107rzt4DMR3cBttMSO2LVs10zFS4PL1cWGxRTkEyA5oEOjN0uFC1X5wMk5/Jbn8i/BGLn06QbsLh7GIjKcByVncB0vqJqw72Wakx7epFcbSO9TgyAAmBnl+Zwm+KDnslE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771001923; c=relaxed/simple; bh=r9SFGqR92Fs20HO4JolD+pt0pW/zrKMLfOUDHfwJ95M=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=azV43XwJYw8K6RMUySGqNIRTSki77nB7T3DF1svbg5OB4CaIP3WLo8jkgB5Q0YSqaiDpel+vDYFaDsM/7tciygMMkRD5HwAwbVORNw8Njrzvg7sqzQUoErcO/NRIi5rY43y77LLIZXne+cKXLiAwW132M2JRsCc7u0f4g7il37A= 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=fjWm5zFm; 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="fjWm5zFm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E28D1C19421; Fri, 13 Feb 2026 16:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1771001923; bh=r9SFGqR92Fs20HO4JolD+pt0pW/zrKMLfOUDHfwJ95M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fjWm5zFmBi+HFOZUFT8lO339NLFh+VE9s/5khZImm3kWAU1wgPW9lvoDfTJuXgqOT uK6JswN6Ym0CLElSIPd8I6Bzjxn/nQ5B0qTUT44fW7nT4U+bXBJIdnEkB0qQiDAPrW ieP/quKnqWB88KmYr7JCaR/FEO/tiwIHPnQVKgPk= Date: Fri, 13 Feb 2026 08:58:42 -0800 From: Andrew Morton To: Arnd Bergmann Cc: Johannes Weiner , Axel Rasmussen , Yuanchu Xie , Arnd Bergmann , Wei Xu , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Baolin Wang , Kairui Song , Davidlohr Bueso , Koichiro Den , Jiayuan Chen , Bertrand Wlodarczyk , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/vmscan: avoid false-positive -Wuninitialized warning Message-Id: <20260213085842.0654f70a73ec05d88908ec25@linux-foundation.org> In-Reply-To: <20260213123902.3466040-1-arnd@kernel.org> References: <20260213123902.3466040-1-arnd@kernel.org> 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 13 Feb 2026 13:38:56 +0100 Arnd Bergmann wrote: > From: Arnd Bergmann > > When the -fsanitize=bounds sanitizer is enabled, Is this an option in current kernels? > gcc-16 sometimes runs > into a corner case in the read_ctrl_pos() pos function, where it sees > possible undefined behavior from the 'tier' index overflowing, presumably > in the case that this was called with a negative tier: > > In function 'get_tier_idx', > inlined from 'isolate_folios' at mm/vmscan.c:4671:14: > mm/vmscan.c: In function 'isolate_folios': > mm/vmscan.c:4645:29: error: 'pv.refaulted' is used uninitialized [-Werror=uninitialized] > > Part of the problem seems to be that read_ctrl_pos() has unusual calling > conventions since commit 37a260870f2c ("mm/mglru: rework type selection") > where passing MAX_NR_TIERS makes it accumulate all tiers but passing a > smaller positive number makes it read a single tier instead. > > Avoid this case by splitting read_ctrl_pos() into two separate helpers > that each only do one of the two cases. This avoids the warning as far > as I can tell, and seems a bit easier to understand to me. > > Signed-off-by: Arnd Bergmann > --- > This is currently the only such warning I get from gcc-16.0.1, and > none from any other version. > > I'm not overly happy about having to work around it with a random > code chance, but hopefully the version I ended up with makes > sense regardless. Seems a large change just to squish a compiler warning. People might prefer a simple - struct ctrl_pos sp, pv; + struct ctrl_pos sp, pv = {}; ?