public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Honggyu Kim <honggyu.kim@sk.com>
Cc: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org,
	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
Subject: Re: [RFC PATCH 1/4] mm/vmscan: refactor reclaim_pages with reclaim_or_migrate_folios
Date: Tue, 16 Jan 2024 12:32:10 -0800	[thread overview]
Message-ID: <20240116203210.52843-1-sj@kernel.org> (raw)
In-Reply-To: <20240115045253.1775-2-honggyu.kim@sk.com>

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

  reply	other threads:[~2024-01-16 20:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15  4:52 [RFC PATCH 0/4] DAMON based 2-tier memory management for CXL memory Honggyu Kim
2024-01-15  4:52 ` [RFC PATCH 1/4] mm/vmscan: refactor reclaim_pages with reclaim_or_migrate_folios Honggyu Kim
2024-01-16 20:32   ` SeongJae Park [this message]
2024-01-15  4:52 ` [RFC PATCH 2/4] mm/damon: introduce DAMOS_DEMOTE action for demotion Honggyu Kim
2024-01-16 20:32   ` SeongJae Park
2024-01-15  4:52 ` [RFC PATCH 3/4] mm/memory-tiers: add next_promotion_node to find promotion target Honggyu Kim
2024-01-16 20:32   ` SeongJae Park
2024-01-15  4:52 ` [RFC PATCH 4/4] mm/damon: introduce DAMOS_PROMOTE action for promotion Honggyu Kim
2024-01-16 20:32   ` SeongJae Park
2024-01-16 20:31 ` [RFC PATCH 0/4] DAMON based 2-tier memory management for CXL memory SeongJae Park
2024-01-17 11:49   ` Honggyu Kim
2024-01-17 21:11     ` SeongJae Park
2024-01-17 21:24       ` SeongJae Park
2024-01-18 10:40       ` Hyeongtak Ji
2024-01-18 17:17         ` SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116203210.52843-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=damon@lists.linux.dev \
    --cc=dave.jiang@intel.com \
    --cc=honggyu.kim@sk.com \
    --cc=kernel_team@skhynix.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=surenb@google.com \
    --cc=yangx.jy@fujitsu.com \
    --cc=ying.huang@intel.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox