From patchwork Sat Jan 11 01:52:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13935705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3A8CE77188 for ; Sat, 11 Jan 2025 01:52:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 209B66B00A5; Fri, 10 Jan 2025 20:52:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B9776B00A6; Fri, 10 Jan 2025 20:52:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 081046B00A7; Fri, 10 Jan 2025 20:52:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DDFB46B00A5 for ; Fri, 10 Jan 2025 20:52:03 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 84EF2453BD for ; Sat, 11 Jan 2025 01:52:03 +0000 (UTC) X-FDA: 82993495326.02.8454F3F Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) by imf08.hostedemail.com (Postfix) with ESMTP id 0EA8D160005 for ; Sat, 11 Jan 2025 01:52:00 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=uHWgUBVu; spf=pass (imf08.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.48 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=reject) header.from=fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736560321; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=mP0S0/hetl37KKU6OGYjZej4S1+ufaaiYqUUpIhXELw=; b=T3DiAm77GfdNhQs7c9bGn7yjTRsp17dIm5cvAUz85uh2a8dVjxz2JeiwMPahry5GkHvnAo YEZ4spfRnjBfk3dddxjcB48EXu3DLh/um7a1KVeIsOpwXvfiEav30RbxMGv2N3355JakGR XTT28OGBVkn/5pmGVDvuXMvGig62r6o= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=uHWgUBVu; spf=pass (imf08.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.48 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=reject) header.from=fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736560321; a=rsa-sha256; cv=none; b=ei2k+8T0Y5m5a/CK6E0WqZnZCENkBOI730U8MtygR+z/b/yYyTlqnUshczsoWjUhYUrzIi waoGfqJfUaWbSLQC0mguvj9/YY5w5U9rWnp/rA+FJuWuKIYEZHPdM0HT1JVOx2kBOqoSI5 ITMHu+47JyaL//e7m3spKDn/BrydqRM= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1736560322; x=1768096322; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ipz0XOEX3hHMPW7TaIL/Z5uIdOC6vPzcRUOftNTfjeI=; b=uHWgUBVu3C0OETmzdzg3VzbMm1lBQ+b3B6Re5BXLnl1yjpevxNHUsiI6 mHWhCOxNLF8SIE4NXFWAncCeXG5jjr5BElZhxkAG/L2Pw7mn6MP2dc8By 2o5HrZ4c9aBJbZBwLJiTuTcqvXWAkk+/PQyUNPyXqzOiOxVvD0Qh3NDWb cg4XaJSlWBKpCmG+WJnV0amJwtE64N9Yf8yzATwAWdoz9uhOvt8bUaoS0 sZZe/IQWs5uZNCaqY/fJrj+mkPxAMRT2/Wbnxs0ERRxt+crk1yO9sLb3c ZGhs1FvaejRpSf5ApVORn0CEfDihXMvkTFXsoG/1OQJBU+r5Mmz7Ncui0 g==; X-CSE-ConnectionGUID: IWOVXWN9Rku/9b6OL1Z6UA== X-CSE-MsgGUID: 9zRjUoJzSJ6nw4xKnVuklw== X-IronPort-AV: E=McAfee;i="6700,10204,11311"; a="186248243" X-IronPort-AV: E=Sophos;i="6.12,305,1728918000"; d="scan'208";a="186248243" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) 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-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 0C57DD4809 for ; Sat, 11 Jan 2025 10:51:57 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id D0D59D7731 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-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 5B01A6BA40 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 MIME-Version: 1.0 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 X-Rspamd-Queue-Id: 0EA8D160005 X-Stat-Signature: 5yqj5nzqxx3js56k9c1rt1wx9iwoa3yh X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736560320-239481 X-HE-Meta: U2FsdGVkX1/Vou2tmWRADttm2ZIShgufE+eyCzt1bAbqdwXxtRNm3TSDs+izyL2Qr8HBWhs2wY3VrtV7n+CPsRiXznK1MSwya+ONKbz0EtWLOYYSpGuGU2ua5+HqO+H363kXHdCZJvIBbAKbnfO6wzY48BgWpU4RUIaq/Yyg2+11Iy80ucmbwKqVPt//hVr3XqWYXxdrVDsERTglp2jeL9+cNqeztG/sDPIjm6Kve2VQMlI3WHPpTqdQE3E+kqVlB1e+yPtW1V/O8yKM5s+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nTUmf1yBlFb2Io= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 balancing operations") Signed-off-by: Li Zhijian Tested-by: Donet Tom Reviewed-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_head *folio_list, struct folio_batch free_folios; LIST_HEAD(ret_folios); LIST_HEAD(demote_folios); - unsigned int nr_reclaimed = 0; + unsigned int nr_reclaimed = 0, nr_demoted = 0; unsigned int pgactivate = 0; bool do_demote_pass; struct swap_iocb *plug = NULL; @@ -1522,8 +1522,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, /* 'folio_list' is always empty here */ /* Migrate folios selected for demotion */ - stat->nr_demoted = demote_folio_list(&demote_folios, pgdat); - nr_reclaimed += stat->nr_demoted; + nr_demoted = demote_folio_list(&demote_folios, pgdat); + nr_reclaimed += nr_demoted; + stat->nr_demoted += 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 */