From nobody Tue Nov 26 17:39:31 2024 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (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 68C90208D97 for ; Wed, 16 Oct 2024 14:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729089160; cv=none; b=qkpaksu/bszwHhf7rvs3bYllyiMeLxpfAOz/7ee1ZecaCXdR+MXhNZ14ir5UYFhe6rlHc6lz3YZVFxxlMYRdzh0Nx7rSmDjiSJAo9anWd0ymmt5YAmpLf3KEvKLORmvsz17j42YS1yQ8ie51gj+f2lbaPg+5JoM28RgpwhEB7ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729089160; c=relaxed/simple; bh=9tFyi9k7IgUfhj2xvBxUcAVTZ4B70J6eCdlm6rc23nA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: References; b=PiWoTKkvkR54UL+o6diIBxyt1MQtUGWU6UEd+0ieLU2N1O7kNnM9ZRYGMhXdo0rM91kBDew0lnmAGHMWNnpBlFRJ39QliJ7hgEcKBU2YpZ3DI/IywxQ7x6Bgg/JEi3RI8iu7gEeElgMtL0tLwTtEbnO8XvIFEfJi5YgiNe4Q/7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=AR3rHJk6; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="AR3rHJk6" Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241016143236epoutp0338e2d385bb1f053400bc9d0da49c9cad~_9W0zjrtD0808008080epoutp03R for ; Wed, 16 Oct 2024 14:32:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241016143236epoutp0338e2d385bb1f053400bc9d0da49c9cad~_9W0zjrtD0808008080epoutp03R 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 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-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgk+LIzCtJLcpLzFFi42LZdlhTT7f5HH+6wdPdUhZz1q9hs+jePJPR ovf9KyaLpn0z2S0u75rDZnFvzX9Wi2Vf37NbHP76hslidmMfowOnx85Zd9k9Fmwq9di0qpPN Y9OnSeweJ2b8ZvHo27KK0ePMgiPsHp83yQVwRGXbZKQmpqQWKaTmJeenZOal2yp5B8c7x5ua GRjqGlpamCsp5CXmpto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FjrKLMWRmVeSWpSXmKPExsWy7bCSvG7TOf50gzVbrC3mrF/DZtG9eSaj Re/7V0wWTftmsltc3jWHzeLemv+sFsu+vme3OPz1DZPF7MY+RgdOj52z7rJ7LNhU6rFpVSeb x6ZPk9g9Tsz4zeLRt2UVo8eZBUfYPT5vkgvgiOKySUnNySxLLdK3S+DK6L3/mqVgvXxFe+ta pgbGo1JdjJwcEgImEhdWfWXsYuTiEBLYzSixee8/NoiEjMSb809Zuhg5gGxhicOHiyFqPjJK rF3dzQRSwyagLfF+wSRWEFtEoEBi9atrYHFmgUqJf7dvgcWFBRwk7vTcZgaZwyKgKtG2qAwk zCtgJ/Hu/wQWiFXyEjMvfWeHiAtKnJz5hAVijLxE89bZzBMY+WYhSc1CklrAyLSKUTK1oDg3 PbfYsMAwL7Vcrzgxt7g0L10vOT93EyM4pLU0dzBuX/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 Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241016143235epcas1p216905027589e0a9c4ac44726510fbbd6 References: 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=3D0 nr_scanned=3D112 nr_reclaimed=3D112 nr_dir= ty=3D0 nr_writeback=3D0 nr_congested=3D0 nr_immediate=3D0 nr_activate_anon= =3D0 nr_activate_file=3D0 nr_ref_keep=3D0 nr_unmap_fail=3D0 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)) ); =20 +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 =3D nid; + __entry->nr_scanned =3D nr_scanned; + __entry->nr_reclaimed =3D nr_reclaimed; + __entry->nr_dirty =3D stat->nr_dirty; + __entry->nr_writeback =3D stat->nr_writeback; + __entry->nr_congested =3D stat->nr_congested; + __entry->nr_immediate =3D stat->nr_immediate; + __entry->nr_activate0 =3D stat->nr_activate[0]; + __entry->nr_activate1 =3D stat->nr_activate[1]; + __entry->nr_ref_keep =3D stat->nr_ref_keep; + __entry->nr_unmap_fail =3D stat->nr_unmap_fail; + ), + + TP_printk("nid=3D%d nr_scanned=3D%ld nr_reclaimed=3D%ld nr_dirty=3D%ld nr= _writeback=3D%ld nr_congested=3D%ld nr_immediate=3D%ld nr_activate_anon=3D%= d nr_activate_file=3D%d nr_ref_keep=3D%ld nr_unmap_fail=3D%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, =20 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_sc= an, 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 =3D { @@ -2139,12 +2139,13 @@ static unsigned int reclaim_folio_list(struct list_= head *folio_list, .no_demotion =3D 1, }; =20 - nr_reclaimed =3D shrink_folio_list(folio_list, pgdat, &sc, &dummy_stat, t= rue); + nr_reclaimed =3D shrink_folio_list(folio_list, pgdat, &sc, &stat, true); while (!list_empty(folio_list)) { folio =3D 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); =20 return nr_reclaimed; } --=20 2.25.1