From patchwork Mon Jan 15 04:52:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggyu Kim X-Patchwork-Id: 13519307 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 02DD2C4707B for ; Mon, 15 Jan 2024 04:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EAEE6B0081; Sun, 14 Jan 2024 23:53:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89AEC6B0082; Sun, 14 Jan 2024 23:53:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7133C6B0083; Sun, 14 Jan 2024 23:53:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5D5A36B0081 for ; Sun, 14 Jan 2024 23:53:09 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2F4071C1078 for ; Mon, 15 Jan 2024 04:53:09 +0000 (UTC) X-FDA: 81680326098.08.DB52D22 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf30.hostedemail.com (Postfix) with ESMTP id 3DBA280008 for ; Mon, 15 Jan 2024 04:53:06 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of honggyu.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=honggyu.kim@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705294387; 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:in-reply-to:references:references; bh=a1UhNMMmzfCTnIfkv81KfrDW9K6umykRAvD9WHzleqs=; b=r/gOjRcxNSRflkR6pu9o1nbP+5c1PhUby2FJUA7zQNPx3XFLfC7aI4L3xkLFQoJCL7ZvE/ c0Yll1+j9DuLL+8ouYQML1+vnGKA3adTDRn29g6tL0yXB2Ce+tB8YfZcCOu/JHH9hQLMYo grximCvQGAle1v3r2n6ljyj7SiRcJfU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705294387; a=rsa-sha256; cv=none; b=AXczm4D2xSvJD5ken8auhoiU4HZ6K7wdJKTaQzPw1fhWL8DJwBURCf6E8+egn2KijFe2YY niSiZtRFt+bFgHsuF7CxRkXCUwccXZ5EG4c37o29HCFg1EgIy4pi9RW2iBZjtPLfPphuOZ qqkJ3TNKrhT335I6qwrp5aWn4UtDkv8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of honggyu.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=honggyu.kim@sk.com; dmarc=none X-AuditID: a67dfc5b-d6dff70000001748-4a-65a4ba2da7c0 From: Honggyu Kim To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel_team@skhynix.com, akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, dave.jiang@intel.com, linmiaohe@huawei.com, lizhijian@cn.fujitsu.com, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rostedt@goodmis.org, surenb@google.com, yangx.jy@fujitsu.com, ying.huang@intel.com, ziy@nvidia.com, Honggyu Kim Subject: [RFC PATCH 1/4] mm/vmscan: refactor reclaim_pages with reclaim_or_migrate_folios Date: Mon, 15 Jan 2024 13:52:49 +0900 Message-ID: <20240115045253.1775-2-honggyu.kim@sk.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240115045253.1775-1-honggyu.kim@sk.com> References: <20240115045253.1775-1-honggyu.kim@sk.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsXC9ZZnoa7uriWpButb9SzmrF/DZrHrRojF /73HGC2e/P/NanHiZiObRef3pSwWl3fNYbO4t+Y/q8WR9WdZLNbdArI2nz3DbLF4uZrFvo4H TBaHv75hsph8aQGbxYspZxgtTs6azGIx++g9dgchj/8HJzF7LD39hs1jQxOQaNl3i91jwaZS j5Yjb1k9Fu95yeSxaVUnm8emT5PYPU7M+M3isfOhpceLzTMZPXqb37F5fN4kF8AXxWWTkpqT WZZapG+XwJVx6+tKtoIL/BWzr/1lb2Bs4+1i5OSQEDCRONp2khXG3rFhHzuIzSagJnHl5SSm LkYODhEBB4lVXxW6GLk4mAXOMEs0915mAakRFoiUWPruESNIDYuAqsSMnYYgJq+AmcSnx7oQ EzUlHm//CTaRU8Bc4nX7G2YQWwiopHHtN7A4r4CgxMmZT8AmMgvISzRvnc0MskpCYBO7xJX+ NYwQgyQlDq64wTKBkX8Wkp5ZSHoWMDKtYhTKzCvLTczMMdHLqMzLrNBLzs/dxAiMtWW1f6J3 MH66EHyIUYCDUYmH98ffxalCrIllxZW5hxglOJiVRHgPPl+QKsSbklhZlVqUH19UmpNafIhR moNFSZzX6Ft5ipBAemJJanZqakFqEUyWiYNTqoFxzjm2ozr/XHrjZwcu8P6dq1wfXP3/19HK g+UyPt/j61L9p9oL1vP9jr+b7b30tlO4zuympQEmWmtFp/J9fCdXmJhd43T8zIx5J+/2TmBZ cOX5F4uG1KLDZoXssXNLhDY8nZ286VLQ22UeRlxLo/Zreu4pD09qfTz7Yzsz77XkOSIfzA/3 pnYrsRRnJBpqMRcVJwIAPKj9drECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42LhmqGlp6u7a0mqwct2WYs569ewWey6EWLx f+8xRosn/3+zWpy42chm8fnZa2aLw3NPslp0fl/KYnF51xw2i3tr/rNaHFl/lsVi3S0ga/PZ M8wWi5erWezreMBkcfjrGyaLyZcWsFm8mHKG0eLkrMksFrOP3mN3EPH4f3ASs8fS02/YPDY0 AYmWfbfYPRZsKvVoOfKW1WPxnpdMHptWdbJ5bPo0id3jxIzfLB47H1p6vNg8k9Gjt/kdm8e3 2x4ei198YPL4vEkuQCCKyyYlNSezLLVI3y6BK+PW15VsBRf4K2Zf+8vewNjG28XIySEhYCKx Y8M+dhCbTUBN4srLSUxdjBwcIgIOEqu+KnQxcnEwC5xhlmjuvcwCUiMsECmx9N0jRpAaFgFV iRk7DUFMXgEziU+PdSEmako83v4TbCKngLnE6/Y3zCC2EFBJ49pvYHFeAUGJkzOfgE1kFpCX aN46m3kCI88sJKlZSFILGJlWMYpk5pXlJmbmmOoVZ2dU5mVW6CXn525iBMbSsto/E3cwfrns fohRgINRiYf3x9/FqUKsiWXFlbmHGCU4mJVEeA8+X5AqxJuSWFmVWpQfX1Sak1p8iFGag0VJ nNcrPDVBSCA9sSQ1OzW1ILUIJsvEwSnVwNgk876pYYaCp/mLZFetpBSjSN5vz6wvOFhpWQuy /unMPeHE4ly7TeJLUTmjPV/A0wTnXZNmn9M23stY9cK5MmFlwETt8EA7+/xD0gXzEnT9BK89 7epl3bDQdP6t10p1DxnOvqs83RXN9m6qUfhy/Zev7QNcilnPxj0/32gQIp4geM/p7cfPSizF GYmGWsxFxYkAsorCzqECAAA= X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3DBA280008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: acyzfyfq5mkzfjgxrrinwhn647pfr641 X-HE-Tag: 1705294386-303243 X-HE-Meta: U2FsdGVkX18YmjVPut5jtJNf8j4rdZRA11D4qaHnXd1SvT3n+HqbhuE4WGUwkoAbNLStKkWBQks3RpofRzUDRd/YiASNv+o0hYfXDXVRXFecrjwAQMGnyerLqV5liRq09eHfb1Jwxd9+IShI6ZuKGT7SC5H0rHl5QRjeKc0muT0nUJv12mipJSnZWJLufFVUtvxz1Uv+h8C/J6PdIX6+YICTY0qpt9anPMLcweRy5PVjbjG1k75H+MCdmRmwLhwJIFla2FpgaFaNev+LJY2yqO41VcSYH8ExkGsscE4GTQNC5zUBIiIBN21jZaQyXIlLg3UTkVTlgS41BZNr3bpyQ9uLvQzCsTzm9XoyVggTtHlwPqUluHpttDgrab0JsfCfrt1aeIKH3sIW4QCnQb9xBf1jK44GRUD8CflbBZtqkVtey300MDWRJnuasc0bnguZfYYXQKtiOOUn5kJGfz0IcLocznijwehUViLYaDRJiK88SuFBGnxX5wkeyTU2usvD18Rsw6tMei6p11q5hjbNMSwnwxvLQk+YXV+0Fz2fIfXakvfLN0QMqKi3MKwJniPq1sv3OEeC21lnhWwNL06lZVyfX2H86CDVQIPNl6Il7zlD8bDcb77LGTUfYWZunZo76nOPNlqCXZbOn5f6t7l+u85JNGFfQDnrB43+6Z88eTeTciTGSUN6tUlsZ9USCTWKTCOJEf+Afzf7mZhY/c28/zxfc7Y8sUqZazKAA2uCSERdYj6X+Yocilxgabhzdvq7FfKFTWhBeQuiKoC+jQnIQnR1we63csd1z96nD0qbA36kflnYsqzw5KyEX7WCMEWR/wc+DhKXXeReY0h2alte5gPFEre3A2ck4B7LBBj6GxKb4mKa060NisibfzPXeQIEJO9Jfc9qGgBYhVvb2id5Gw6/d+vqujLzgUxyidIw9fn95nf7u+FAoOl3jhrz71BSiZ6ZBhOI80HPw2f2X8f MjidQTch M+8GtJhtVe4rjgqMT237opbah7vct20kKUhX6MXeoIGc6kT3O25hmHEI9O8alCod+E178MQZhYzQgpPo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since we will introduce reclaim_pages like functions such as demote_pages and promote_pages, the most of the code can be shared. This is a preparation patch that introduces reclaim_or_migrate_folios() to cover all the logics, but it provides a handler for the different actions. No functional changes applied. Signed-off-by: Honggyu Kim --- mm/vmscan.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index bba207f41b14..7ca2396ccc3b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2107,15 +2107,16 @@ static unsigned int reclaim_folio_list(struct list_head *folio_list, return nr_reclaimed; } -unsigned long reclaim_pages(struct list_head *folio_list) +static unsigned long reclaim_or_migrate_folios(struct list_head *folio_list, + unsigned int (*handler)(struct list_head *, struct pglist_data *)) { int nid; - unsigned int nr_reclaimed = 0; + unsigned int nr_folios = 0; LIST_HEAD(node_folio_list); unsigned int noreclaim_flag; if (list_empty(folio_list)) - return nr_reclaimed; + return nr_folios; noreclaim_flag = memalloc_noreclaim_save(); @@ -2129,15 +2130,20 @@ unsigned long reclaim_pages(struct list_head *folio_list) continue; } - nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid)); + nr_folios += handler(&node_folio_list, NODE_DATA(nid)); nid = folio_nid(lru_to_folio(folio_list)); } while (!list_empty(folio_list)); - nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid)); + nr_folios += handler(&node_folio_list, NODE_DATA(nid)); memalloc_noreclaim_restore(noreclaim_flag); - return nr_reclaimed; + return nr_folios; +} + +unsigned long reclaim_pages(struct list_head *folio_list) +{ + return reclaim_or_migrate_folios(folio_list, reclaim_folio_list); } static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,