From nobody Tue Apr 14 14:07:33 2026 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 ACBD6332EBC for ; Tue, 14 Apr 2026 06:52:15 +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=1776149535; cv=none; b=bOlL+NcByCRqJ/mX094u8GG1tLfsg4duKieV8pI5hui5ypb9rZ3CZJELh7QHHX0ZEQF55SXvEWJM2px1btuVra9LAKQlnpHiaUmxXgsDxWfwp2mosWedvVyCyGjnujRmWz1UkMjcRErKmisUqJHnAtbmRu4V1XJFaZSEIZTapyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776149535; c=relaxed/simple; bh=kIgQxPIstY5Hnf2wEsVfMAa0QL5Z30y6cxFvGVD83Vw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TCPw7A/LJNoe7GvLofWWcXbkkyOHCBXBZh3YBSqKT1zrFjBEcQ1wcR69Va3OpWg306ys1g9Sdki6aMJkcGjOPJR8IDGwulq8zRF6m6RAEFTZRSBvuRfFxK5ujt83+cAYLvXyAutpIzD1n8/EgtgamRsrXPuMBoMzG3qqQKZ3Q+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l3OfO1zr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l3OfO1zr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F241C19425; Tue, 14 Apr 2026 06:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776149535; bh=kIgQxPIstY5Hnf2wEsVfMAa0QL5Z30y6cxFvGVD83Vw=; h=From:To:Cc:Subject:Date:From; b=l3OfO1zr+4AQtU5i3EXFDuZK9ABQGbrNJ7sYLgItekge5HMATapGwK4GvA2hApyyx I1Dwc5fjPTnR7lQ8IsGoQEOSkVk9tarUG8F0LRPaftZNYVwkVXH1vkitYZu1uRkghc BwJhkI8/s/Oaj0jLkQ0VJAS+aG/92A4BZLVDYGp629tGpDPcxLwyEAm2uL5Et74ZG5 Vl917h5pkpKHzBOJ/QsRYhpGNyzdkmyhG4GuXvcoYNOr4NXxbxmswyt1iFrp1uz6AL Nc2xaBGx98FhBywR1H/ovvXg3l7uduOuPMnLGyuxVgfg1ST8TAEE3sewS71C8y3Czu xEqzqzYldOavQ== From: Arnd Bergmann To: Andrew Morton , Johannes Weiner Cc: Arnd Bergmann , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Muchun Song , Baolin Wang , Davidlohr Bueso , Koichiro Den , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] mm/vmscan: avoid false-positive -Wuninitialized warning Date: Tue, 14 Apr 2026 08:51:58 +0200 Message-Id: <20260414065206.3236176-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann When the -fsanitize=3Dbounds sanitizer is enabled, 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= =3Duninitialized] 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. Shut up the warning by adding a fake initialization to the two instances of this variable that can run into that corner case. Link: https://lore.kernel.org/all/CAJHvVcjtFW86o5FoQC8MMEXCHAC0FviggaQsd5Em= iCHP+1fBpg@mail.gmail.com/ Signed-off-by: Arnd Bergmann --- v2: replace the earlier more invasive cleanup with a trivial workaround --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d3312c51f3f2..f829435d2807 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4760,7 +4760,7 @@ static int scan_folios(unsigned long nr_to_scan, stru= ct lruvec *lruvec, static int get_tier_idx(struct lruvec *lruvec, int type) { int tier; - struct ctrl_pos sp, pv; + struct ctrl_pos sp, pv =3D {}; =20 /* * To leave a margin for fluctuations, use a larger gain factor (2:3). @@ -4779,7 +4779,7 @@ static int get_tier_idx(struct lruvec *lruvec, int ty= pe) =20 static int get_type_to_scan(struct lruvec *lruvec, int swappiness) { - struct ctrl_pos sp, pv; + struct ctrl_pos sp, pv =3D {}; =20 if (swappiness <=3D MIN_SWAPPINESS + 1) return LRU_GEN_FILE; --=20 2.39.5