From: David Hildenbrand <david@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Suren Baghdasaryan <surenb@google.com>,
Peter Xu <peterx@redhat.com>, Jann Horn <jannh@google.com>
Subject: Re: [PATCH 4/4] mm: Optimise vmf_anon_prepare() for VMAs without an anon_vma
Date: Fri, 26 Apr 2024 19:36:31 +0200 [thread overview]
Message-ID: <31813228-4d2e-45f5-98d3-10cae826130a@redhat.com> (raw)
In-Reply-To: <20240426144506.1290619-5-willy@infradead.org>
On 26.04.24 16:45, Matthew Wilcox (Oracle) wrote:
> If the mmap_lock can be taken for read, we can call __anon_vma_prepare()
> while holding it, saving ourselves a trip back through the fault handler.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Jann Horn <jannh@google.com>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> ---
> mm/memory.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 7dc112d3a7e4..b5453b86ec4b 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3232,16 +3232,21 @@ static inline vm_fault_t vmf_can_call_fault(const struct vm_fault *vmf)
> vm_fault_t vmf_anon_prepare(struct vm_fault *vmf)
> {
> struct vm_area_struct *vma = vmf->vma;
> + vm_fault_t ret = 0;
>
> if (likely(vma->anon_vma))
> return 0;
> if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
> - vma_end_read(vma);
> - return VM_FAULT_RETRY;
> + if (!mmap_read_trylock(vma->vm_mm)) {
> + vma_end_read(vma);
> + return VM_FAULT_RETRY;
> + }
> }
> if (__anon_vma_prepare(vma))
> - return VM_FAULT_OOM;
> - return 0;
> + ret = VM_FAULT_OOM;
> + if (vmf->flags & FAULT_FLAG_VMA_LOCK)
> + mmap_read_unlock(vma->vm_mm);
> + return ret;
> }
>
> /*
Fancy
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2024-04-26 17:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 14:44 [PATCH 0/4] Improve anon_vma scalability for anon VMAs Matthew Wilcox (Oracle)
2024-04-26 14:45 ` [PATCH 1/4] mm: Assert the mmap_lock is held in __anon_vma_prepare() Matthew Wilcox (Oracle)
2024-04-26 15:23 ` Suren Baghdasaryan
2024-04-26 17:34 ` David Hildenbrand
2024-04-26 14:45 ` [PATCH 2/4] mm: Delay the check for a NULL anon_vma Matthew Wilcox (Oracle)
2024-04-26 14:45 ` [PATCH 3/4] mm: Fix some minor per-VMA lock issues in userfaultfd Matthew Wilcox (Oracle)
2024-04-26 15:23 ` Suren Baghdasaryan
2024-04-26 14:45 ` [PATCH 4/4] mm: Optimise vmf_anon_prepare() for VMAs without an anon_vma Matthew Wilcox (Oracle)
2024-04-26 17:36 ` David Hildenbrand [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=31813228-4d2e-45f5-98d3-10cae826130a@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).