From: David Hildenbrand <david@redhat.com>
To: Lokesh Gidra <lokeshgidra@google.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, kaleshsingh@google.com, ngeoffray@google.com,
jannh@google.com, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Harry Yoo <harry.yoo@oracle.com>, Peter Xu <peterx@redhat.com>,
Suren Baghdasaryan <surenb@google.com>,
Barry Song <baohua@kernel.org>, SeongJae Park <sj@kernel.org>
Subject: Re: [PATCH 1/2] mm: always call rmap_walk() on locked folios
Date: Thu, 18 Sep 2025 14:15:55 +0200 [thread overview]
Message-ID: <2c9df5ee-6109-4fa5-b895-ad8e47d34bee@redhat.com> (raw)
In-Reply-To: <20250918055135.2881413-2-lokeshgidra@google.com>
On 18.09.25 07:51, Lokesh Gidra wrote:
> Guarantee that rmap_walk() is called on locked folios so that threads
> changing folio->mapping and folio->index for non-KSM anon folios can
> serialize on fine-grained folio lock rather than anon_vma lock. Other
> folio types are already always locked before rmap_walk().
>
> This is in preparation for removing anon_vma write-lock from
> UFFDIO_MOVE.
I think quite a big bunch of the cover letter belongs into this patch
here. In essence, why is it okay, what could be problematic, history
etc, etc.
>
> CC: David Hildenbrand <david@redhat.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> CC: Harry Yoo <harry.yoo@oracle.com>
> CC: Peter Xu <peterx@redhat.com>
> CC: Suren Baghdasaryan <surenb@google.com>
> CC: Barry Song <baohua@kernel.org>
> CC: SeongJae Park <sj@kernel.org>
> Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
> ---
> mm/damon/ops-common.c | 16 ++++------------
> mm/memory-failure.c | 3 +++
> mm/page_idle.c | 8 ++------
> mm/rmap.c | 42 ++++++++++++------------------------------
> 4 files changed, 21 insertions(+), 48 deletions(-)
>
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index 998c5180a603..f61d6dde13dc 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -162,21 +162,17 @@ void damon_folio_mkold(struct folio *folio)
> .rmap_one = damon_folio_mkold_one,
> .anon_lock = folio_lock_anon_vma_read,
> };
> - bool need_lock;
>
> if (!folio_mapped(folio) || !folio_raw_mapping(folio)) {
> folio_set_idle(folio);
> return;
> }
>
> - need_lock = !folio_test_anon(folio) || folio_test_ksm(folio);
> - if (need_lock && !folio_trylock(folio))
> + if (!folio_trylock(folio))
> return;
>
> rmap_walk(folio, &rwc);
> -
> - if (need_lock)
> - folio_unlock(folio);
> + folio_unlock(folio);
>
> }
>
> @@ -228,7 +224,6 @@ bool damon_folio_young(struct folio *folio)
> .rmap_one = damon_folio_young_one,
> .anon_lock = folio_lock_anon_vma_read,
> };
> - bool need_lock;
>
> if (!folio_mapped(folio) || !folio_raw_mapping(folio)) {
> if (folio_test_idle(folio))
> @@ -237,14 +232,11 @@ bool damon_folio_young(struct folio *folio)
> return true;
> }
>
> - need_lock = !folio_test_anon(folio) || folio_test_ksm(folio);
> - if (need_lock && !folio_trylock(folio))
> + if (!folio_trylock(folio))
> return false;
>
> rmap_walk(folio, &rwc);
> -
> - if (need_lock)
> - folio_unlock(folio);
> + folio_unlock(folio);
>
> return accessed;
> }
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index a24806bb8e82..f698df156bf8 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2143,7 +2143,10 @@ static void kill_procs_now(struct page *p, unsigned long pfn, int flags,
> {
> LIST_HEAD(tokill);
>
> + folio_lock(folio);
> collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED);
> + folio_unlock(folio);
> +
> kill_procs(&tokill, true, pfn, flags);
> }
Is mf_generic_kill_procs()->collect_procs() problematic?
The dax_lock_folio/dax_unlock_folio part confuses me: I think it only
locks an entry in the page cache but not the actual folio ("Lock the DAX
entry corresponding to a folio")?
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-09-18 12:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 5:51 [PATCH 0/2] Improve UFFDIO_MOVE scalability by removing anon_vma lock Lokesh Gidra
2025-09-18 5:51 ` [PATCH 1/2] mm: always call rmap_walk() on locked folios Lokesh Gidra
2025-09-18 11:57 ` Lorenzo Stoakes
2025-09-19 5:45 ` Lokesh Gidra
2025-09-19 9:59 ` Lorenzo Stoakes
2025-11-03 14:58 ` Lorenzo Stoakes
2025-11-03 15:46 ` Lokesh Gidra
2025-11-03 16:38 ` Lorenzo Stoakes
2025-09-18 12:15 ` David Hildenbrand [this message]
2025-09-19 6:09 ` Lokesh Gidra
2025-09-24 10:00 ` David Hildenbrand
2025-09-24 19:17 ` Lokesh Gidra
2025-09-25 11:06 ` David Hildenbrand
2025-10-02 6:46 ` Lokesh Gidra
2025-10-02 7:22 ` David Hildenbrand
2025-10-02 7:48 ` Lokesh Gidra
2025-10-03 23:02 ` Peter Xu
2025-10-06 6:43 ` David Hildenbrand
2025-10-06 19:49 ` Peter Xu
2025-10-06 20:02 ` David Hildenbrand
2025-10-06 20:50 ` Peter Xu
2025-09-18 5:51 ` [PATCH 2/2] mm/userfaultfd: don't lock anon_vma when performing UFFDIO_MOVE Lokesh Gidra
2025-09-18 12:38 ` Lorenzo Stoakes
2025-09-19 6:30 ` Lokesh Gidra
2025-09-19 9:57 ` Lorenzo Stoakes
2025-09-19 18:34 ` Lokesh Gidra
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=2c9df5ee-6109-4fa5-b895-ad8e47d34bee@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=harry.yoo@oracle.com \
--cc=jannh@google.com \
--cc=kaleshsingh@google.com \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=ngeoffray@google.com \
--cc=peterx@redhat.com \
--cc=sj@kernel.org \
--cc=surenb@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