From patchwork Wed Oct 16 14:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13838557 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 29765D2A520 for ; Wed, 16 Oct 2024 14:32:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B88A36B007B; Wed, 16 Oct 2024 10:32:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B392B6B008C; Wed, 16 Oct 2024 10:32:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B2066B0093; Wed, 16 Oct 2024 10:32:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7FDA96B007B for ; Wed, 16 Oct 2024 10:32:43 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A4BC680542 for ; Wed, 16 Oct 2024 14:32:34 +0000 (UTC) X-FDA: 82679706354.24.AC499DF Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf22.hostedemail.com (Postfix) with ESMTP id 48528C001D for ; Wed, 16 Oct 2024 14:32:28 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=AR3rHJk6; spf=pass (imf22.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729089017; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=q4/UYrkheKG89qi1j/kjpU2o34wk2+byWmCp6+7zaJQ=; b=k1OjrRoBrNHqPcuBTTIf/MbFz63NvnNnNX1yfrvqXHxP1CGeUHMwPd2/FLQs3aPMri2Not TE3TAMQfRilAgbnOH2dKnsl4OGgtheO1qMT8n69SVemW/1zQSSfIiACe9whKbvqFEI9Qi/ KJPvFJXCpUpX5Y91vExpf2z/hG5mg64= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729089017; a=rsa-sha256; cv=none; b=nHEpm1wdLJ0HKVl34oaPXslY9vsFElWAP+suO2EFuhFPvjqnQ/AU1ZNQz+OQgsf+A116jI Uxpm2QoIpVgGg9A/O50ZnU6xBTXayFhju1vU4Y0vB5m+f7eNaTMI4biqmVew113jyMN8yX TtAlsZ8bwdDlDmfU+u2K5BWZq9z0BnY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=AR3rHJk6; spf=pass (imf22.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241016143236epoutp020ba1c333790b7b1cd08f224456c415da~_9W0pH1GS1401914019epoutp02W for ; Wed, 16 Oct 2024 14:32:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241016143236epoutp020ba1c333790b7b1cd08f224456c415da~_9W0pH1GS1401914019epoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1729089156; bh=q4/UYrkheKG89qi1j/kjpU2o34wk2+byWmCp6+7zaJQ=; h=From:To:Cc:Subject:Date:References:From; b=AR3rHJk6OpTmsFtUNagVshjIjTcd4XxjTfCP/g9ON8bVQV7k5uE1DO80rTv3NHfG2 XAxrqP4P0VDm6Yb8tup3O39aRcOR0JlRQ50zl2miJTXB5d5/o+WSArZDCnScKL4jYD bxMNdDugtF5TD0P2CCzRBv+c2AdpfEJjQ1XldLCg= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20241016143235epcas1p38cfcef0e1b048d0896d81ad7e634c48f~_9W0Z4SBA0916409164epcas1p3i; Wed, 16 Oct 2024 14:32:35 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.38.249]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XTD2W3ZLfz4x9Pv; Wed, 16 Oct 2024 14:32:35 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 78.EB.09951.38ECF076; Wed, 16 Oct 2024 23:32:35 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20241016143235epcas1p216905027589e0a9c4ac44726510fbbd6~_9Wzoiw__1993219932epcas1p2K; Wed, 16 Oct 2024 14:32:35 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241016143235epsmtrp239de00befb9b684e0f3f6ba5d90636e2~_9Wzn4ef92089520895epsmtrp20; Wed, 16 Oct 2024 14:32:35 +0000 (GMT) X-AuditID: b6c32a38-b93b8700000026df-9e-670fce8374fd Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 98.04.08229.28ECF076; Wed, 16 Oct 2024 23:32:34 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.104.99]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241016143234epsmtip26ce5bc70af4e2af01fc6b47ae2bc5c00~_9WzcZzh03007630076epsmtip27; Wed, 16 Oct 2024 14:32:34 +0000 (GMT) From: Jaewon Kim To: sj@kernel.org, minchan@kernel.org, vbabka@suse.cz, kaleshsingh@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH v3] vmscan: add a vmscan event for reclaim_pages Date: Wed, 16 Oct 2024 23:32:27 +0900 Message-Id: <20241016143227.961162-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgk+LIzCtJLcpLzFFi42LZdlhTT7f5HH+6wdPdUhZz1q9hs+jePJPR ovf9KyaLpn0z2S0u75rDZnFvzX9Wi2Vf37NbHP76hslidmMfowOnx85Zd9k9Fmwq9di0qpPN Y9OnSeweJ2b8ZvHo27KK0ePMgiPsHp83yQVwRGXbZKQmpqQWKaTmJeenZOal2yp5B8c7x5ua GRjqGlpamCsp5CXmptoqufgE6Lpl5gCdp6RQlphTChQKSCwuVtK3synKLy1JVcjILy6xVUot SMkpMCvQK07MLS7NS9fLSy2xMjQwMDIFKkzIzui9/5qlYL18RXvrWqYGxqNSXYycHBICJhJv e28ydjFycQgJ7GCUuPN9PzOE84lRYsrNCUwQzjdGifMrDjLBtFxY9RWqZS+jxIlrO1ggnM+M Eg0L57KAVLEJaEu8XzCJFcQWEciSWH30ElicWaBU4u2bE8wgtrCAg8SdnttANgcHi4CqRNui MpAwr4CdxLv/E1gglslLzLz0nR0iLihxcuYTqDHyEs1bZzND1Hxll7hwSwBkjISAi8SiRRoQ YWGJV8e3sEPYUhKf3+1lg7DzJS5cfMUEUV4jsXCiIUTYXmLX1xmsIGFmAU2J9bv0IRbxSbz7 2sMKUc0r0dEmBFGtJtHy7CsrhC0j8fffMyjbQ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vOT93EyM4pLU0dzBuX/VB7xAjEwfjIUYJDmYlEd5JXbzpQrwp iZVVqUX58UWlOanFhxilOViUxHnFX/SmCAmkJ5akZqemFqQWwWSZODilGpgyFwv+bw3vSM6f s3LRBnMPiwdux/8fd7dOSygy0dg+51BL0NuIjVIy8r1TJ+hKHLqiUOR69ubeF3nvWuYFH3ny 9v+6myFn/ZuuJC5nfJZcdsV6hovS5wUrbHMuLGtdzfib+eKWD64zz4n9M/se6r5YpSXtr1eM RkQ923L3y9M4lILZ0vXjv72/snvunjLmBsXAyevmVlf3XjqzdUMeb3+paOgPVgOXY7d0RLp/ XciTmLtOxO2PQOVsEem99V+2Jyx+57Dfif96X2y+3cWN0954xk0Q33aby+W429pIs+6+efVZ zEVcPIxMYZeC3+6fdeLVL+t/Cf2sgltKxdxKdlr4i5uf/b3hvJJJuQSnY6oSS3FGoqEWc1Fx IgAh91RY2AIAAA== X-CMS-MailID: 20241016143235epcas1p216905027589e0a9c4ac44726510fbbd6 X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241016143235epcas1p216905027589e0a9c4ac44726510fbbd6 References: X-Rspamd-Queue-Id: 48528C001D X-Stat-Signature: 8n5ru19hnmp63fapz99x6rf5w56zm9oh X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729089148-969622 X-HE-Meta: U2FsdGVkX18OY/qxV3DErmGfRETKJnp05xt+vH+kH4tJizru79jAkWBQx9qgtWacN69MmbwF66TSTXpy2gDJ+b81bEpa35AQPmojEKpruJDVrF60pSU8aKkIW09s5Ce0a8/J+NDFbsJNvWZXXB2198D2D3aObFy1CNlzGLpChWmJ5e96IfhNx2wCLkQU+S4S6putLVnJG76h7P6nhEi6a6rw8ADhR0jYWQVwSMJ3Vaukqcu78c9iBHm6AVleikQQijpSDuObFkb4x3dVwMB9/SX9qqqiP+p6TqtCm+Z5bOt01UJrKrl40tVEOTuQrto0q9UwLPP/Bo/Z5FmXK1AZOQwG3EKkpDTOy2MNcUQxTkm0FgEjA2SSj9O4i47tfaPMVxC1z6+adWjD3gOdMs53bKMKK7JMml5nNCpqcDyD3W1nLLut5opYHqLOmrGXdxVcjotJoKLBKovbSNJvlubW/HKhYEqw42PeeWSiNCYyjMF1pLBYdGav5S0S/xsDUyVFqULfOhMsEr1h8GcI1pjDNpMpLgBsphcqxMccawMqUbr1pxRfy0d+zaFrxQ6KrOrCRhv8XUUVp43Nq4FwWFZFghzpf5VLU9jA+IkSmjN6tvCQ1YqD4I9fw1ROVOmawg5A73j1l/rn6OgIifws8XZJih8iBXXj3YhjOPzS8Z+EviaJ2ancYDYl/y9Dq33UP/w33ygX89wpZ6pYF9HukkqUazyfWMAM8qtz/wCh42oiEIZaN2S3Ert9mS5V7ejI24zSQNDgnSVeZifoKLnzZWdYKdWcZMvlAP1l/GIwDXGQDBOpC6ZzroVN9pboAfUGmIts1UtMtQ5EwFdYC0HcAAegF9LnnvX7tih8pm0X9FcCMPU/McoUN34yJipXVgSSPYetpJAKoaRPaRLuAKB1ofouQ5unirp9WPte4m2hiFjQoyb2Oi2Rn5gBlZkax2pP6r0uzFcyMo72K7Wji4f8b6S tkM1VSlp R4ReFSugLgbnYixuLpnW/Pffz8z9S2hZzxz85ZXKRqbADVBPGFov18fNsKUbUQF3aj0DJm2R9b1xenDU4xgoLhwAnQTH0BksAaPj9JDekaY69nq0f2wYquvPNrC6mEvjVm+AwclcdxA5RTmOwmsAIVpDTYcpR/VkbJ71flmV930SlZl3Ztw7bgPI4Ci3tGpl0qfAP2yOQJJiHswAlqkng42MbmQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The reclaim_folio_list uses a dummy reclaim_stat and is not being used. To know the memory stat, add a new trace event. This is useful how how many pages are not reclaimed or why. This is an example. mm_vmscan_reclaim_pages: nid=0 nr_scanned=112 nr_reclaimed=112 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0 Currenlty reclaim_folio_list is only called by reclaim_pages, and reclaim_pages is used by damon and madvise. In the latest Android, reclaim_pages is also used by shmem to reclaim all pages in a address_space. Signed-off-by: Jaewon Kim Acked-by: Vlastimil Babka --- v3: use sc.nr_scanned rather than new counting v2: remove reclaim_stat_add function and call the trace on each node v1: introduce a new trace event --- include/trace/events/vmscan.h | 45 +++++++++++++++++++++++++++++++++++ mm/vmscan.c | 5 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 1a488c30afa5..490958fa10de 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -346,6 +346,51 @@ TRACE_EVENT(mm_vmscan_write_folio, show_reclaim_flags(__entry->reclaim_flags)) ); +TRACE_EVENT(mm_vmscan_reclaim_pages, + + TP_PROTO(int nid, + unsigned long nr_scanned, unsigned long nr_reclaimed, + struct reclaim_stat *stat), + + TP_ARGS(nid, nr_scanned, nr_reclaimed, stat), + + TP_STRUCT__entry( + __field(int, nid) + __field(unsigned long, nr_scanned) + __field(unsigned long, nr_reclaimed) + __field(unsigned long, nr_dirty) + __field(unsigned long, nr_writeback) + __field(unsigned long, nr_congested) + __field(unsigned long, nr_immediate) + __field(unsigned int, nr_activate0) + __field(unsigned int, nr_activate1) + __field(unsigned long, nr_ref_keep) + __field(unsigned long, nr_unmap_fail) + ), + + TP_fast_assign( + __entry->nid = nid; + __entry->nr_scanned = nr_scanned; + __entry->nr_reclaimed = nr_reclaimed; + __entry->nr_dirty = stat->nr_dirty; + __entry->nr_writeback = stat->nr_writeback; + __entry->nr_congested = stat->nr_congested; + __entry->nr_immediate = stat->nr_immediate; + __entry->nr_activate0 = stat->nr_activate[0]; + __entry->nr_activate1 = stat->nr_activate[1]; + __entry->nr_ref_keep = stat->nr_ref_keep; + __entry->nr_unmap_fail = stat->nr_unmap_fail; + ), + + TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate_anon=%d nr_activate_file=%d nr_ref_keep=%ld nr_unmap_fail=%ld", + __entry->nid, + __entry->nr_scanned, __entry->nr_reclaimed, + __entry->nr_dirty, __entry->nr_writeback, + __entry->nr_congested, __entry->nr_immediate, + __entry->nr_activate0, __entry->nr_activate1, + __entry->nr_ref_keep, __entry->nr_unmap_fail) +); + TRACE_EVENT(mm_vmscan_lru_shrink_inactive, TP_PROTO(int nid, diff --git a/mm/vmscan.c b/mm/vmscan.c index 749cdc110c74..8e16f99cdd3d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2128,7 +2128,7 @@ static void shrink_active_list(unsigned long nr_to_scan, static unsigned int reclaim_folio_list(struct list_head *folio_list, struct pglist_data *pgdat) { - struct reclaim_stat dummy_stat; + struct reclaim_stat stat; unsigned int nr_reclaimed; struct folio *folio; struct scan_control sc = { @@ -2139,12 +2139,13 @@ static unsigned int reclaim_folio_list(struct list_head *folio_list, .no_demotion = 1, }; - nr_reclaimed = shrink_folio_list(folio_list, pgdat, &sc, &dummy_stat, true); + nr_reclaimed = shrink_folio_list(folio_list, pgdat, &sc, &stat, true); while (!list_empty(folio_list)) { folio = lru_to_folio(folio_list); list_del(&folio->lru); folio_putback_lru(folio); } + trace_mm_vmscan_reclaim_pages(pgdat->node_id, sc.nr_scanned, nr_reclaimed, &stat); return nr_reclaimed; }