From: Barry Song <21cnbao@gmail.com>
To: Chen Ridong <chenridong@huaweicloud.com>
Cc: akpm@linux-foundation.org, mhocko@suse.com, hannes@cmpxchg.org,
yosryahmed@google.com, yuzhao@google.com, david@redhat.com,
willy@infradead.org, ryan.roberts@arm.com,
wangkefeng.wang@huawei.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, chenridong@huawei.com,
wangweiyang2@huawei.com, xieym_ict@hotmail.com
Subject: Re: [RFC PATCH v3 1/2] mm: vmascan: add find_folios_written_back() helper
Date: Wed, 4 Dec 2024 23:37:15 +1300 [thread overview]
Message-ID: <CAGsJ_4yBJBLucTP6945VTf9UQ_y6wcPyooevHT+mUu_junkjWQ@mail.gmail.com> (raw)
In-Reply-To: <20241204040158.2768519-2-chenridong@huaweicloud.com>
On Wed, Dec 4, 2024 at 5:11 PM Chen Ridong <chenridong@huaweicloud.com> wrote:
>
> From: Chen Ridong <chenridong@huawei.com>
>
> Add find_folios_written_back() helper, which will be called in the
> shrink_inactive_list function in subsequent patch.
This is not about adding a helper but rather extracting a function
that can be used
by both lru_gen and the traditional active/inactive LRU. Making it a
separate patch
may not be ideal, as it isn’t an external function that warrants
special attention.
Combining patch 1 and patch 2 into a single patch creates a more cohesive and
logical flow, making it easier to review.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> mm/vmscan.c | 73 +++++++++++++++++++++++++++++++----------------------
> 1 file changed, 43 insertions(+), 30 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 76378bc257e3..af1ff76f83e7 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -283,6 +283,48 @@ static void set_task_reclaim_state(struct task_struct *task,
> task->reclaim_state = rs;
> }
>
> +/**
> + * find_folios_written_back - Find and move the written back folios to a new list.
> + * @list: filios list
> + * @clean: the written back folios list
> + * @skip: whether skip to move the written back folios to clean list.
> + */
> +static inline void find_folios_written_back(struct list_head *list,
> + struct list_head *clean, bool skip)
> +{
> + struct folio *folio;
> + struct folio *next;
> +
> + list_for_each_entry_safe_reverse(folio, next, list, lru) {
> + if (!folio_evictable(folio)) {
> + list_del(&folio->lru);
> + folio_putback_lru(folio);
> + continue;
> + }
> +
> + if (folio_test_reclaim(folio) &&
> + (folio_test_dirty(folio) || folio_test_writeback(folio))) {
> + /* restore LRU_REFS_FLAGS cleared by isolate_folio() */
> + if (lru_gen_enabled() && folio_test_workingset(folio))
> + folio_set_referenced(folio);
> + continue;
> + }
> +
> + if (skip || folio_test_active(folio) || folio_test_referenced(folio) ||
> + folio_mapped(folio) || folio_test_locked(folio) ||
> + folio_test_dirty(folio) || folio_test_writeback(folio)) {
> + /* don't add rejected folios to the oldest generation */
> + if (lru_gen_enabled())
> + set_mask_bits(&folio->flags, LRU_REFS_MASK | LRU_REFS_FLAGS,
> + BIT(PG_active));
> + continue;
> + }
> +
> + /* retry folios that may have missed folio_rotate_reclaimable() */
> + list_move(&folio->lru, clean);
> + }
> +}
> +
> /*
> * flush_reclaim_state(): add pages reclaimed outside of LRU-based reclaim to
> * scan_control->nr_reclaimed.
> @@ -4567,8 +4609,6 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
> int reclaimed;
> LIST_HEAD(list);
> LIST_HEAD(clean);
> - struct folio *folio;
> - struct folio *next;
> enum vm_event_item item;
> struct reclaim_stat stat;
> struct lru_gen_mm_walk *walk;
> @@ -4597,34 +4637,7 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
> scanned, reclaimed, &stat, sc->priority,
> type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON);
>
> - list_for_each_entry_safe_reverse(folio, next, &list, lru) {
> - if (!folio_evictable(folio)) {
> - list_del(&folio->lru);
> - folio_putback_lru(folio);
> - continue;
> - }
> -
> - if (folio_test_reclaim(folio) &&
> - (folio_test_dirty(folio) || folio_test_writeback(folio))) {
> - /* restore LRU_REFS_FLAGS cleared by isolate_folio() */
> - if (folio_test_workingset(folio))
> - folio_set_referenced(folio);
> - continue;
> - }
> -
> - if (skip_retry || folio_test_active(folio) || folio_test_referenced(folio) ||
> - folio_mapped(folio) || folio_test_locked(folio) ||
> - folio_test_dirty(folio) || folio_test_writeback(folio)) {
> - /* don't add rejected folios to the oldest generation */
> - set_mask_bits(&folio->flags, LRU_REFS_MASK | LRU_REFS_FLAGS,
> - BIT(PG_active));
> - continue;
> - }
> -
> - /* retry folios that may have missed folio_rotate_reclaimable() */
> - list_move(&folio->lru, &clean);
> - }
> -
> + find_folios_written_back(&list, &clean, skip_retry);
> spin_lock_irq(&lruvec->lru_lock);
>
> move_folios_to_lru(lruvec, &list);
> --
> 2.34.1
>
Thanks
Barry
next prev parent reply other threads:[~2024-12-04 10:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 4:01 [RFC PATCH v3 0/2] mm: vmscan: retry folios written back while isolated Chen Ridong
2024-12-04 4:01 ` [RFC PATCH v3 1/2] mm: vmascan: add find_folios_written_back() helper Chen Ridong
2024-12-04 10:37 ` Barry Song [this message]
2024-12-04 4:01 ` [RFC PATCH v3 2/2] mm: vmscan: retry folios written back while isolated Chen Ridong
2024-12-04 10:45 ` Barry Song
2024-12-05 2:06 ` chenridong
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=CAGsJ_4yBJBLucTP6945VTf9UQ_y6wcPyooevHT+mUu_junkjWQ@mail.gmail.com \
--to=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chenridong@huawei.com \
--cc=chenridong@huaweicloud.com \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=ryan.roberts@arm.com \
--cc=wangkefeng.wang@huawei.com \
--cc=wangweiyang2@huawei.com \
--cc=willy@infradead.org \
--cc=xieym_ict@hotmail.com \
--cc=yosryahmed@google.com \
--cc=yuzhao@google.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;
as well as URLs for NNTP newsgroup(s).