Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp336178rdb; Sun, 14 Jan 2024 20:53:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRvhdzXAD/b/ryDeQ5zemXEwNT9t6fTFGwu3QUDangsgEdatRBplL3KAin+hdEWINiJv85 X-Received: by 2002:a17:906:22c6:b0:a2a:de51:7481 with SMTP id q6-20020a17090622c600b00a2ade517481mr1409826eja.106.1705294397918; Sun, 14 Jan 2024 20:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705294397; cv=none; d=google.com; s=arc-20160816; b=wo1eg1PBqaJzZ8xtytinC/IR4+kPIBnQUMVKSBDTNjvVyrJN0I6TPRm/tREJJHZ/Oj cq2xPKgjUbdh0vt9cDQ7yBGsd8m7nQdAtNtrnNURfyQJMh60Be+FAM3K77uztYME+wo2 UrkrUU9Hl53XZYUEa6Akf7EgXx7eH7gXhaQK63uqECH33Ktz4iN3IgyWNe/ET1KkALIE LTAX3LoVNkpunPZ82xSQAVHVrThC0OfWlaCA52lmVxCddmFDvAVFU9AqIoSlQd9okmGV NF5B4UzEY3UxbxLK8fL/GmqzSumMDTge42juT1dEBSnLDLhQ6FcKgJP5ua3K5Pgf/hLP cE5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=a1UhNMMmzfCTnIfkv81KfrDW9K6umykRAvD9WHzleqs=; fh=QpE/wnUeWoxuh0NjJxorah/5ccrR48k2q4LwbFu3G2k=; b=e4GCqctz2LeANye0Kgg4ITW5Mx0P7V/ctk44XOiGVY3zXyXufeyL8PztMQ8BHgfsV+ y1Ab6fs1ng2IlMGipc/Q8l+7jU1Lz9rIeYxGd469TGh+yupfU9dr3S+JQMJ9vj5iHihk KXL+LW0EcO8O+fiZacWbJdtF2dPVuPdDVWoUGHkQoT2b9RTefiSIa4Lt+/UnpWUtBwnY UEXoVP9pehITuGg5/jwbXZuPhiX84K6fAwETarirjJyecpYdUVIy5cgG2d8Hlvz2RY/+ oV6OpgruGpO1MaFV2GMT55lQzwKJiOcnqQiWKKYMSP9JGZOFnTPRJ3E6m5F/b9+Ykbyj Aizw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25622-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25622-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bl7-20020a170906c24700b00a2adc52f10fsi3482486ejb.876.2024.01.14.20.53.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 20:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25622-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25622-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25622-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 918DF1F21508 for ; Mon, 15 Jan 2024 04:53:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 620B52568; Mon, 15 Jan 2024 04:53:07 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED65417D2; Mon, 15 Jan 2024 04:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsXC9ZZnoa7uriWpButb9SzmrF/DZrHrRojF /73HGC2e/P/NanHiZiObRef3pSwWl3fNYbO4t+Y/q8WR9WdZLNbdArI2nz3DbLF4uZrFvo4H TBaHv75hsph8aQGbxYspZxgtTs6azGIx++g9dgchj/8HJzF7LD39hs1jQxOQaNl3i91jwaZS j5Yjb1k9Fu95yeSxaVUnm8emT5PYPU7M+M3isfOhpceLzTMZPXqb37F5fN4kF8AXxWWTkpqT WZZapG+XwJVx6+tKtoIL/BWzr/1lb2Bs4+1i5OSQEDCRONp2khX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46m3kCI88sJKlZSFILGJlWMYpk5pXlJmbmmOoVZ2dU5mVW6CXn525iBMbSsto/E3cwfrns fohRgINRiYf3x9/FqUKsiWXFlbmHGCU4mJVEeA8+X5AqxJuSWFmVWpQfX1Sak1p8iFGag0VJ nNcrPDVBSCA9sSQ1OzW1ILUIJsvEwSnVwNgk876pYYaCp/mLZFetpBSjSN5vz6wvOFhpWQuy /unMPeHE4ly7TeJLUTmjPV/A0wTnXZNmn9M23stY9cK5MmFlwETt8EA7+/xD0gXzEnT9BK89 7epl3bDQdP6t10p1DxnOvqs83RXN9m6qUfhy/Zev7QNcilnPxj0/32gQIp4geM/p7cfPSizF GYmGWsxFxYkAsorCzqECAAA= X-CFilter-Loop: Reflected 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, -- 2.34.1