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 4A5DA1DFE33; Wed, 6 Nov 2024 12:35:46 +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=1730896546; cv=none; b=jqFLqWMzDdevoULpFoZxhGWLxegSWSj48FINnxv1Z2iQp826z8CDKymI7YUZ9evRTMiNPKlhj9864W0Tu3wuHeyQugiDbG+vassW2k8CWOVpjfofBkDMitwqPA3m958Zm/FOsp2z+GEDimOGlWc75391PfsXnXx3mePDRLzE7Is= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730896546; c=relaxed/simple; bh=YuqQFOaGOAiVHjM6S13nrwdRk4GfdWKiDQh+Wrba0SU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Stv2YxNx55qlT8f0J+Yq3GzLIC1+ql7cTqh5JBwHMzVN1C5FyHYi0gRW6c37CxX1XdwfM7Q9YESYPGDNIsVH4WgukBmcUs2CumKnaFxCICH0pz2TdXkPFbjQT6PGf51w7GXazlX6SaCFv1iQlevZGIM3OhOeM3WlEocupexlS/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C/1/pdxJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C/1/pdxJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97DCFC4CECD; Wed, 6 Nov 2024 12:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730896546; bh=YuqQFOaGOAiVHjM6S13nrwdRk4GfdWKiDQh+Wrba0SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C/1/pdxJNHYGmvGuGOgLSiMb2svsg9C7jddTaVJxHRt4d7uB+qZzF/0sNAgpStoBc 4GwuuosKquvdH1MhVa6qNz1NvLWBDOwc53oevlnDYDUBDVf0I1PG4t+rZD4aLouYdM MuluN+C4oxdE0bBAzYk2Jilb/DdtFKMOrMoFi6gI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gregory Price , Yang Shi , Davidlohr Bueso , Shakeel Butt , "Huang, Ying" , Oscar Salvador , Dave Hansen , Wei Xu , Andrew Morton , Sasha Levin Subject: [PATCH 6.11 202/245] vmscan,migrate: fix page count imbalance on node stats when demoting pages Date: Wed, 6 Nov 2024 13:04:15 +0100 Message-ID: <20241106120324.219898278@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120319.234238499@linuxfoundation.org> References: <20241106120319.234238499@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gregory Price [ Upstream commit 35e41024c4c2b02ef8207f61b9004f6956cf037b ] When numa balancing is enabled with demotion, vmscan will call migrate_pages when shrinking LRUs. migrate_pages will decrement the the node's isolated page count, leading to an imbalanced count when invoked from (MG)LRU code. The result is dmesg output like such: $ cat /proc/sys/vm/stat_refresh [77383.088417] vmstat_refresh: nr_isolated_anon -103212 [77383.088417] vmstat_refresh: nr_isolated_file -899642 This negative value may impact compaction and reclaim throttling. The following path produces the decrement: shrink_folio_list demote_folio_list migrate_pages migrate_pages_batch migrate_folio_move migrate_folio_done mod_node_page_state(-ve) <- decrement This path happens for SUCCESSFUL migrations, not failures. Typically callers to migrate_pages are required to handle putback/accounting for failures, but this is already handled in the shrink code. When accounting for migrations, instead do not decrement the count when the migration reason is MR_DEMOTION. As of v6.11, this demotion logic is the only source of MR_DEMOTION. Link: https://lkml.kernel.org/r/20241025141724.17927-1-gourry@gourry.net Fixes: 26aa2d199d6f ("mm/migrate: demote pages during reclaim") Signed-off-by: Gregory Price Reviewed-by: Yang Shi Reviewed-by: Davidlohr Bueso Reviewed-by: Shakeel Butt Reviewed-by: "Huang, Ying" Reviewed-by: Oscar Salvador Cc: Dave Hansen Cc: Wei Xu Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 368ab3878fa6e..75b858bd6aa58 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1099,7 +1099,7 @@ static void migrate_folio_done(struct folio *src, * not accounted to NR_ISOLATED_*. They can be recognized * as __folio_test_movable */ - if (likely(!__folio_test_movable(src))) + if (likely(!__folio_test_movable(src)) && reason != MR_DEMOTION) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + folio_is_file_lru(src), -folio_nr_pages(src)); -- 2.43.0