From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Aditya Sharma <adi.sharma@zohomail.in>, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, ljs@kernel.org,
Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/memory: update stale locking comments for fault handlers
Date: Thu, 23 Apr 2026 16:27:21 +0200 [thread overview]
Message-ID: <19f5f950-d0f9-49c2-acf6-7b0ab277ab23@kernel.org> (raw)
In-Reply-To: <20260405171834.15971-1-adi.sharma@zohomail.in>
On 4/5/26 19:18, Aditya Sharma wrote:
> Update the comments for wp_page_copy(), do_wp_page(), do_swap_page(),
> do_anonymous_page(), __do_fault(), do_fault(), handle_pte_fault(),
> __handle_mm_fault(), and handle_mm_fault() to concisely clarify that
> they can be entered holding either the mmap_lock or the VMA lock,
> and that the lock may be released upon returning VM_FAULT_RETRY.
>
> Additionally, make the following corrections:
> - In do_anonymous_page(), correct the outdated claim that the function
> is entered with the PTE "mapped but not yet locked". Since
> handle_pte_fault() unmaps the empty PTE before routing to
> do_pte_missing(), the comment now correctly states it is entered
> with the PTE unmapped and unlocked.
> - In __do_fault(), update the stale reference from __lock_page_retry()
> to __folio_lock_or_retry().
>
> Signed-off-by: Aditya Sharma <adi.sharma@zohomail.in>
Next time, please don't send as reply to your previous version
> ---
> v2:
> - Simplified the comment to concisely state "either the VMA lock or
> the mmap_lock" instead of a verbose explanation (per David Hildenbrand).
> - Expanded the scope to cover 8 other fault handlers in mm/memory.c
> that suffered from the same stale mmap_lock comments.
> - Fixed an additional historical inaccuracy in do_anonymous_page()
> regarding the PTE mapping state on entry.
> - Updated a stale reference in __do_fault() from __lock_page_retry()
> to __folio_lock_or_retry().
>
>
> mm/memory.c | 49 ++++++++++++++++++++++++++-----------------------
> 1 file changed, 26 insertions(+), 23 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index c65e82c86..2b407e3f9 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3742,8 +3742,8 @@ vm_fault_t __vmf_anon_prepare(struct vm_fault *vmf)
> * Handle the case of a page which we actually need to copy to a new page,
> * either due to COW or unsharing.
> *
> - * Called with mmap_lock locked and the old page referenced, but
> - * without the ptl held.
> + * Called with either the VMA lock or the mmap_lock (FAULT_FLAG_VMA_LOCK
> + * tells you which)
"Called with either the VMA lock or the mmap_lock *held*"
Same for other cases.
Can we shorten "FAULT_FLAG_VMA_LOCK tells you which" to "see FAULT_FLAG_VMA_LOCK"
?
--
Cheers,
David
next prev parent reply other threads:[~2026-04-23 14:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 14:29 [PATCH] mm: update stale locking comment in do_anonymous_page() Aditya Sharma
2026-04-01 10:52 ` David Hildenbrand (Arm)
2026-04-01 16:42 ` Aditya Sharma
2026-04-01 18:47 ` David Hildenbrand (Arm)
2026-04-05 17:18 ` [PATCH v2] mm/memory: update stale locking comments for fault handlers Aditya Sharma
2026-04-23 14:27 ` David Hildenbrand (Arm) [this message]
2026-04-23 15:00 ` Aditya Sharma
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=19f5f950-d0f9-49c2-acf6-7b0ab277ab23@kernel.org \
--to=david@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=adi.sharma@zohomail.in \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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