From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Joanne Koong <joannelkoong@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Barry Song <baohua@kernel.org>, Usama Arif <usama.arif@linux.dev>,
Lance Yang <lance.yang@linux.dev>,
Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH v1] mm: unqueue deferred split folios outside the lruvec lock
Date: Wed, 14 Oct 2026 11:31:49 +0200 [thread overview]
Message-ID: <b90ec4b6-e0a4-4f46-aa3b-b1a3a08570c9@kernel.org> (raw)
In-Reply-To: <20261013221307.850803-1-joannelkoong@gmail.com>
On 10/14/26 00:13, Joanne Koong wrote:
> move_folios_to_lru(), folio_batch_move_lru() and folios_put_refs() call
> folio_unqueue_deferred_split() on folios where the refcount has dropped
> to zero. In these paths, folio_unqueue_deferred_split() is called with
> the lruvec lock often held (move_folios_to_lru() always holds it and
> folio_batch_move_lru()/folios_put_refs() usually hold it for every folio
> in the batch except the first). However, it's not needed to hold the
> lruvec lock.
>
> The lruvec lock protects folio->lru and the reclaim LRU lists whereas
> the deferred split queue lives on folio->_deferred_list in
> deferred_split_lru. The deferred_split_lru is a list_lru with its own
> per-memcg per-node lock.
>
> There are already other existing callers that call
> folio_unqueue_deferred_split() without holding the lruvec lock (eg
> __folio_put(), shrink_folio_list(), __folio_migrate_mapping(), ...).
>
> Add folio_batch_unqueue_deferred_split() and use it in
> move_folios_to_lru(), folio_batch_move_lru(), and folios_put_refs() to
> unqueue each batch of zero-refcount folios from the deferred split list
> after the lruvec lock is released and before
> mem_cgroup_uncharge_folios(). This helps shorten the lruvec lock's
> critical sections, which run with IRQs disabled and are highly
> contended.
>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> mm/folio.c | 24 +++++++++++++++++++-----
> mm/internal.h | 1 +
> mm/vmscan.c | 3 ++-
> 3 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/mm/folio.c b/mm/folio.c
> index 35e242b48870..85144078e635 100644
> --- a/mm/folio.c
> +++ b/mm/folio.c
> @@ -109,6 +109,19 @@ EXPORT_SYMBOL(__folio_put);
>
> typedef void (*move_fn_t)(struct lruvec *lruvec, struct folio *folio);
>
> +/*
> + * Unqueue a batch of folios from the deferred split queue. This must be
> + * called after the folios' refcounts have dropped to zero and before they
> + * are uncharged (see comment above __folio_unqueue_deferred_split() for why).
> + */
> +void folio_batch_unqueue_deferred_split(struct folio_batch *fbatch)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < folio_batch_count(fbatch); i++)
> + folio_unqueue_deferred_split(fbatch->folios[i]);
> +}
> +
> static void lru_add(struct lruvec *lruvec, struct folio *folio)
> {
> int was_unevictable = folio_test_clear_unevictable(folio);
> @@ -177,14 +190,10 @@ static void folio_batch_move_lru(struct folio_batch *fbatch, move_fn_t move_fn)
> *
> * We're bypassing normal cleanup. Clear flags that are not
> * applicable to dead folios.
> - *
> - * Since the folio may be part of a huge page, unqueue from
> - * deferred split list to avoid a dangling list entry.
> */
> if (is_lru_add && folio_ref_freeze(folio, 1)) {
> __folio_clear_active(folio);
> __folio_clear_unevictable(folio);
> - folio_unqueue_deferred_split(folio);
> fbatch->folios[i] = NULL;
> folio_batch_add(&free_fbatch, folio);
> continue;
> @@ -201,6 +210,11 @@ static void folio_batch_move_lru(struct folio_batch *fbatch, move_fn_t move_fn)
>
> /* Cleanup filtered dead folios. */
> if (is_lru_add) {
> + /*
> + * Since the folios may be part of a huge page, unqueue them
> + * from the deferred split list to avoid a dangling list entry.
> + */
In general, this lgtm, thanks. I am confused about this existing comment you are
moving.
folios being *part of* a huge page? Huh? A folio might represent a huge page,
but what does the "part of" thing mean here.
Is it simply "Dequeue any large folios" ?
--
Cheers,
David
prev parent reply other threads:[~2026-10-14 9:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 22:13 [PATCH v1] mm: unqueue deferred split folios outside the lruvec lock Joanne Koong
2026-10-14 3:07 ` Lance Yang
2026-10-14 3:13 ` Barry Song
2026-10-14 4:24 ` Lance Yang
2026-10-14 9:31 ` David Hildenbrand (Arm) [this message]
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=b90ec4b6-e0a4-4f46-aa3b-b1a3a08570c9@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=joannelkoong@gmail.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--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