linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Suren Baghdasaryan <surenb@google.com>
Subject: Re: [PATCH] mm: Tweak __vma_enter_locked()
Date: Wed, 19 Nov 2025 07:02:31 +0000	[thread overview]
Message-ID: <8d4744ee-3f5a-460f-824f-11c632732da1@lucifer.local> (raw)
In-Reply-To: <20251119042639.3937024-1-willy@infradead.org>

On Wed, Nov 19, 2025 at 04:26:35AM +0000, Matthew Wilcox (Oracle) wrote:
> Move the commentary on how __vma_enter_locked() behaves from the
> body of __vma_start_write() to the head of __vma_enter_locked() and
> merge it with the existing documentation.  Also add a call to
> mmap_assert_write_locked().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

LGTM, so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Suren Baghdasaryan <surenb@google.com>
> ---
>  mm/mmap_lock.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
> index f2532af6208c..e6e5570d1ec7 100644
> --- a/mm/mmap_lock.c
> +++ b/mm/mmap_lock.c
> @@ -46,9 +46,9 @@ EXPORT_SYMBOL(__mmap_lock_do_trace_released);
>  #ifdef CONFIG_MMU
>  #ifdef CONFIG_PER_VMA_LOCK
>  /*
> - * Return value: 0 if vma detached,
> - * 1 if vma attached with no readers,
> - * -EINTR if signal received,
> + * __vma_enter_locked() returns 0 immediately if the vma is not
> + * attached, otherwise it waits for any current readers to finish and
> + * returns 1.  Returns -EINTR if a signal is received while waiting.
>   */
>  static inline int __vma_enter_locked(struct vm_area_struct *vma,
>  		bool detaching, int state)
> @@ -56,6 +56,8 @@ static inline int __vma_enter_locked(struct vm_area_struct *vma,
>  	int err;
>  	unsigned int tgt_refcnt = VMA_LOCK_OFFSET;
>
> +	mmap_assert_write_locked(vma->vm_mm);

This is nice, actually was thinking the other day we need more asserts like this
in these lock functions.

> +
>  	/* Additional refcnt if the vma is attached. */
>  	if (!detaching)
>  		tgt_refcnt++;
> @@ -91,11 +93,6 @@ int __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_seq,
>  {
>  	int locked;
>
> -	/*
> -	 * __vma_enter_locked() returns false immediately if the vma is not
> -	 * attached, otherwise it waits until refcnt is indicating that vma
> -	 * is attached with no readers.
> -	 */
>  	locked = __vma_enter_locked(vma, false, state);
>  	if (locked < 0)
>  		return locked;
> --
> 2.47.2
>
>


      reply	other threads:[~2025-11-19  7:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19  4:26 Matthew Wilcox (Oracle)
2025-11-19  7:02 ` Lorenzo Stoakes [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=8d4744ee-3f5a-460f-824f-11c632732da1@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    --cc=willy@infradead.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