[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240115045253.1775-2-honggyu.kim@sk.com>
Date: Mon, 15 Jan 2024 13:52:49 +0900
From: Honggyu Kim <honggyu.kim@...com>
To: sj@...nel.org,
damon@...ts.linux.dev,
linux-mm@...ck.org
Cc: linux-trace-kernel@...r.kernel.org,
linux-kernel@...r.kernel.org,
kernel_team@...ynix.com,
akpm@...ux-foundation.org,
apopple@...dia.com,
baolin.wang@...ux.alibaba.com,
dave.jiang@...el.com,
linmiaohe@...wei.com,
lizhijian@...fujitsu.com,
mathieu.desnoyers@...icios.com,
mhiramat@...nel.org,
rostedt@...dmis.org,
surenb@...gle.com,
yangx.jy@...itsu.com,
ying.huang@...el.com,
ziy@...dia.com,
Honggyu Kim <honggyu.kim@...com>
Subject: [RFC PATCH 1/4] mm/vmscan: refactor reclaim_pages with reclaim_or_migrate_folios
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 <honggyu.kim@...com>
---
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
Powered by blists - more mailing lists