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 0920C329E5A; Fri, 27 Mar 2026 02:15:25 +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=1774577726; cv=none; b=dthh41AsSWfOySQ2XTzVj2gR1qsPBaD4WHTxr1nL1q2r4XtbWZxoYCyDGlobQfgTXnODnbtmejn/7xYmb6Gl0AV6D959Ft2SlarF7Qkok9t3vUGRtkI2TJRBMiht8by4a2xI8ETPX9z/LUOcSIDdMtXgedafL4MgAiIuu7oKu38= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577726; c=relaxed/simple; bh=CtAWkGMvmgaWzI6n1vOUwGCglJtxx00IEzrd0BAI64Y=; h=Date:To:From:Subject:Message-Id; b=A4zrK0Epm+7OWkKWktlocWJeKCmZPEaaL/KAa3LFwWOQRHFciRJ1PKTLfDCssiS7IFGhswPIV8vX8NMy4Ms4GNXYGhGfRYvG+xKff/MDHqqw/V3nRk/x7RfiUfZjo+2BKnQEmRtqp18WTX5libYPxvpi8aD1Wib2MIaNH+dm0gw= 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=AIKx6qeW; 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="AIKx6qeW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79721C19423; Fri, 27 Mar 2026 02:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774577725; bh=CtAWkGMvmgaWzI6n1vOUwGCglJtxx00IEzrd0BAI64Y=; h=Date:To:From:Subject:From; b=AIKx6qeWVQHVSCKMHAMmFpWVSQS776sQ3eQT5zr1OZ1ON3FNdUA1Zk3GAc/NVW5I3 u4+oRRv+GOk6zVKb798zQrw8TJchlokduRe0kE/PLIMsOl6Ncobp4pq42BC+xwNvXi kJaoIIeU67Usp7atDwk0zQslk8T7oETwJWXjPNdQ= Date: Thu, 26 Mar 2026 19:15:24 -0700 To: mm-commits@vger.kernel.org,zhengqi.arch@bytedance.com,yuanchu@google.com,weixugc@google.com,stable@vger.kernel.org,shakeel.butt@linux.dev,mhocko@kernel.org,ljs@kernel.org,koichiro.den@canonical.com,kasong@tencent.com,hannes@cmpxchg.org,david@kernel.org,dave@stgolabs.net,baolin.wang@linux.alibaba.com,axelrasmussen@google.com,arnd@arndb.de,akpm@linux-foundation.org From: Andrew Morton Subject: [to-be-updated] mm-vmscan-avoid-false-positive-wuninitialized-warning.patch removed from -mm tree Message-Id: <20260327021525.79721C19423@smtp.kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm/vmscan: avoid false-positive -Wuninitialized warning has been removed from the -mm tree. Its filename was mm-vmscan-avoid-false-positive-wuninitialized-warning.patch This patch was dropped because an updated version will be issued ------------------------------------------------------ From: Arnd Bergmann Subject: mm/vmscan: avoid false-positive -Wuninitialized warning Date: Fri, 13 Feb 2026 13:38:56 +0100 When the -fsanitize=bounds 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=uninitialized] This can happen with CONFIG_UBSAN_ARRAY_BOUNDS=y. The actual warning only shows up in some configurations with that, so either there is some other dependency, or an element of chance based on gcc optimizations. 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. Link: https://lkml.kernel.org/r/20260213123902.3466040-1-arnd@kernel.org Signed-off-by: Arnd Bergmann Cc: Axel Rasmussen Cc: Baolin Wang Cc: David Hildenbrand Cc: Davidlohr Bueso Cc: Johannes Weiner Cc: Kairui Song Cc: Koichiro Den Cc: Lorenzo Stoakes (Oracle) Cc: Michal Hocko Cc: Qi Zheng Cc: Shakeel Butt Cc: Wei Xu Cc: Yuanchu Xie Cc: Signed-off-by: Andrew Morton --- mm/vmscan.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) --- a/mm/vmscan.c~mm-vmscan-avoid-false-positive-wuninitialized-warning +++ a/mm/vmscan.c @@ -3125,20 +3125,15 @@ struct ctrl_pos { static void read_ctrl_pos(struct lruvec *lruvec, int type, int tier, int gain, struct ctrl_pos *pos) { - int i; struct lru_gen_folio *lrugen = &lruvec->lrugen; int hist = lru_hist_from_seq(lrugen->min_seq[type]); pos->gain = gain; - pos->refaulted = pos->total = 0; - - for (i = tier % MAX_NR_TIERS; i <= min(tier, MAX_NR_TIERS - 1); i++) { - pos->refaulted += lrugen->avg_refaulted[type][i] + - atomic_long_read(&lrugen->refaulted[hist][type][i]); - pos->total += lrugen->avg_total[type][i] + - lrugen->protected[hist][type][i] + - atomic_long_read(&lrugen->evicted[hist][type][i]); - } + pos->refaulted = lrugen->avg_refaulted[type][tier] + + atomic_long_read(&lrugen->refaulted[hist][type][tier]); + pos->total = lrugen->avg_total[type][tier] + + lrugen->protected[hist][type][tier] + + atomic_long_read(&lrugen->evicted[hist][type][tier]); } static void reset_ctrl_pos(struct lruvec *lruvec, int type, bool carryover) @@ -4775,6 +4770,24 @@ static int get_tier_idx(struct lruvec *l return tier - 1; } +static void aggregate_ctrl_pos(struct lruvec *lruvec, int type, int gain, + struct ctrl_pos *pos) +{ + struct lru_gen_folio *lrugen = &lruvec->lrugen; + int hist = lru_hist_from_seq(lrugen->min_seq[type]); + + pos->gain = gain; + pos->refaulted = pos->total = 0; + + for (int i = 0; i < MAX_NR_TIERS; i++) { + pos->refaulted += lrugen->avg_refaulted[type][i] + + atomic_long_read(&lrugen->refaulted[hist][type][i]); + pos->total += lrugen->avg_total[type][i] + + lrugen->protected[hist][type][i] + + atomic_long_read(&lrugen->evicted[hist][type][i]); + } +} + static int get_type_to_scan(struct lruvec *lruvec, int swappiness) { struct ctrl_pos sp, pv; @@ -4788,8 +4801,8 @@ static int get_type_to_scan(struct lruve * Compare the sum of all tiers of anon with that of file to determine * which type to scan. */ - read_ctrl_pos(lruvec, LRU_GEN_ANON, MAX_NR_TIERS, swappiness, &sp); - read_ctrl_pos(lruvec, LRU_GEN_FILE, MAX_NR_TIERS, MAX_SWAPPINESS - swappiness, &pv); + aggregate_ctrl_pos(lruvec, LRU_GEN_ANON, swappiness, &sp); + aggregate_ctrl_pos(lruvec, LRU_GEN_FILE, MAX_SWAPPINESS - swappiness, &pv); return positive_ctrl_err(&sp, &pv); } _ Patches currently in -mm which might be from arnd@arndb.de are bug-avoid-format-attribute-warning-for-clang-as-well.patch ubsan-turn-off-kmsan-inside-of-ubsan-instrumentation.patch