Message ID | 20240115045253.1775-2-honggyu.kim@sk.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | DAMON based 2-tier memory management for CXL memory | expand |
On Mon, 15 Jan 2024 13:52:49 +0900 Honggyu Kim <honggyu.kim@sk.com> wrote: > 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@sk.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 *)) I'm not very sure if extending this function for general migration is the right approach, since we have dedicated functions for the migration. I'd like to hear others' opinions. > { > 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
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,
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@sk.com> --- mm/vmscan.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)