From nobody Sun Feb 8 19:43:40 2026 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) (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 E703A28F3 for ; Sat, 11 Jan 2025 01:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736560392; cv=none; b=nmw0QfiR6yRjQsxab6x1lYgsB+BPtJt4yLopRaoZNPY5jGAMvMrKXqNTvMazh6VIpHUQZYSnOz4vCuvBawkivaL5t8uddh+45xROzISmB1RD4iug6HrJkLaWm9dsHYDeI77p8r7UoPdjgKnZgoQal2sAlY+vw2INHxw21ujgLVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736560392; c=relaxed/simple; bh=ipz0XOEX3hHMPW7TaIL/Z5uIdOC6vPzcRUOftNTfjeI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=k2nz86IV7iJmn0ZTK2VyCjwupKCMPB7VXsC9W4yZKNNOhZTFTO63/oyBwT70aGbAhJyuCtvSvEQrhrbdG/BE9r3TMxU4kimitQNAnpRfyCXnntjFDjHWw3whsAyiifOOxTVHSbFIXm5sNVlBlME2xI29pzmC3lMCdjgVwOoPhfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=GsjuvdFd; arc=none smtp.client-ip=207.54.90.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="GsjuvdFd" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1736560391; x=1768096391; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ipz0XOEX3hHMPW7TaIL/Z5uIdOC6vPzcRUOftNTfjeI=; b=GsjuvdFdvd/tbgrXtYhWeqait+S3N0lLPWpJjSTvF6yaAEkXLjchfavE xECKOy+euC0lFbGmOd1VBAC/4wzUDznO6XwS/2yUlRwSrlNUT158QhfQA q/ryOin+6zRwY6IirT09bsRX/C1qJMEqunj2ekq/ETfVcMbGzwfKQbgnW WC6j1r3NwnphgCBcl1PzNw82hoZCKPyUoKGnwzzuXlH5fBSLzV7zK1mzO TG/S55yccXBdFuOFtNheqOO6fAKAXkj3DUVV4QvEEYR0HQgG3nQmFR8h6 1nZ76TB9bsDhvvlrlT3qMI48BtWaCdUWn8JMpmCuHo+fGBHA9P1moOaPz w==; X-CSE-ConnectionGUID: wIObi43eROKaovB8ufFibQ== X-CSE-MsgGUID: I2mf77XrTYWoDrmwgGalPA== X-IronPort-AV: E=McAfee;i="6700,10204,11311"; a="186248242" X-IronPort-AV: E=Sophos;i="6.12,305,1728918000"; d="scan'208";a="186248242" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2025 10:51:59 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 0D95FC2260 for ; Sat, 11 Jan 2025 10:51:57 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id D6D1FD5018 for ; Sat, 11 Jan 2025 10:51:56 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 5B6432007B70D for ; Sat, 11 Jan 2025 10:51:56 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 7E06D1A006C; Sat, 11 Jan 2025 09:51:55 +0800 (CST) From: Li Zhijian To: linux-mm@kvack.org Cc: Kaiyang Zhao , Andrew Morton , linux-kernel@vger.kernel.org, Li Zhijian Subject: [PATCH v2] mm/vmscan: Accumulate nr_demoted for accurate demotion statistics Date: Sat, 11 Jan 2025 09:52:53 +0800 Message-ID: <20250111015253.425693-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 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 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28916.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28916.003 X-TMASE-Result: 10-4.501400-10.000000 X-TMASE-MatchedRID: RtHHqK+8YWMM5CG8CYBPxQA+Y0oNaxbQG24YVeuZGmOyujf0MQZGbQkf UtJU3fWZ+u+xXVO1LUB+X7GTqLHPoeBRuAss+FbmEXjPIvKd74BUENBIMyKD0bqln+jYe7Zhy9C x8ATXSndhhL+8zADGa4Ay6p60ZV62fJ5/bZ6npdjGVuWouVipctAp0lv4PsUxrIfQRIfzzi+YBW QmkhALaz2R1jgjgk+wj96U0IrMFMLKpUKLjPC0hBdVyA12+RLDujUvtWFzAVL+YYH0e4vyVRFlt GxCTkwFQHVA+r1vGdZmQDEDCMiuswfP8fSSIvISoYC0cwOOST0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Content-Type: text/plain; charset="utf-8" In the shrink_folio_list() function, demote_folio_list() can be called 2 times. Currently stat->nr_demoted will only store the last nr_demoted( the later nr_demoted is always zero, the former nr_demoted will get lost), as a result number of demoted pages is not accurate. Accumulate the nr_demoted count across multiple calls to demote_folio_list(), ensuring accurate reporting of demotion statistics. Fixes: f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balanc= ing operations") Signed-off-by: Li Zhijian Reviewed-by: Donet Tom Tested-by: Donet Tom --- Cc: Kaiyang Zhao Cc: Andrew Morton Kaiyang, I removed you ACKED tag for V1, please review again Andrew, Please drop the v1 from the mm-hotfixs-unstable if V2 is accepted. V2: Introudce a local nr_demoted to fix it's counted 2 times by nr_reclaimed = wrongly. --- mm/vmscan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9a859b7d18d7..7f0624b98aa8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1053,7 +1053,7 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, struct folio_batch free_folios; LIST_HEAD(ret_folios); LIST_HEAD(demote_folios); - unsigned int nr_reclaimed =3D 0; + unsigned int nr_reclaimed =3D 0, nr_demoted =3D 0; unsigned int pgactivate =3D 0; bool do_demote_pass; struct swap_iocb *plug =3D NULL; @@ -1522,8 +1522,9 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, /* 'folio_list' is always empty here */ =20 /* Migrate folios selected for demotion */ - stat->nr_demoted =3D demote_folio_list(&demote_folios, pgdat); - nr_reclaimed +=3D stat->nr_demoted; + nr_demoted =3D demote_folio_list(&demote_folios, pgdat); + nr_reclaimed +=3D nr_demoted; + stat->nr_demoted +=3D nr_demoted; /* Folios that could not be demoted are still in @demote_folios */ if (!list_empty(&demote_folios)) { /* Folios which weren't demoted go back on @folio_list */ --=20 2.44.0