From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Punit Agrawal <punit.agrawal@bytedance.com>,
Suren Baghdasaryan <surenb@google.com>
Subject: [PATCH v3 07/10] mm: Move FAULT_FLAG_VMA_LOCK check down from do_fault()
Date: Mon, 24 Jul 2023 19:54:07 +0100 [thread overview]
Message-ID: <20230724185410.1124082-8-willy@infradead.org> (raw)
In-Reply-To: <20230724185410.1124082-1-willy@infradead.org>
Perform the check at the start of do_read_fault(), do_cow_fault()
and do_shared_fault() instead. Should be no performance change from
the last commit.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
---
mm/memory.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 11b337876477..627a2abb969b 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4661,6 +4661,11 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf)
vm_fault_t ret = 0;
struct folio *folio;
+ if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
+ vma_end_read(vmf->vma);
+ return VM_FAULT_RETRY;
+ }
+
/*
* Let's call ->map_pages() first and use ->fault() as fallback
* if page by the offset is not ready to be mapped (cold cache or
@@ -4689,6 +4694,11 @@ static vm_fault_t do_cow_fault(struct vm_fault *vmf)
struct vm_area_struct *vma = vmf->vma;
vm_fault_t ret;
+ if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
+ vma_end_read(vma);
+ return VM_FAULT_RETRY;
+ }
+
if (unlikely(anon_vma_prepare(vma)))
return VM_FAULT_OOM;
@@ -4729,6 +4739,11 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
vm_fault_t ret, tmp;
struct folio *folio;
+ if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
+ vma_end_read(vma);
+ return VM_FAULT_RETRY;
+ }
+
ret = __do_fault(vmf);
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
return ret;
@@ -4775,11 +4790,6 @@ static vm_fault_t do_fault(struct vm_fault *vmf)
struct mm_struct *vm_mm = vma->vm_mm;
vm_fault_t ret;
- if (vmf->flags & FAULT_FLAG_VMA_LOCK){
- vma_end_read(vma);
- return VM_FAULT_RETRY;
- }
-
/*
* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND
*/
--
2.39.2
next prev parent reply other threads:[~2023-07-24 18:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 18:54 [PATCH v3 00/10] Handle most file-backed faults under the VMA lock Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 01/10] mm: Remove CONFIG_PER_VMA_LOCK ifdefs Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 02/10] mm: Allow per-VMA locks on file-backed VMAs Matthew Wilcox (Oracle)
2023-07-25 12:57 ` Conor Dooley
2023-07-25 14:15 ` Suren Baghdasaryan
2023-07-25 14:31 ` Matthew Wilcox
2023-07-24 18:54 ` [PATCH v3 03/10] mm: Move FAULT_FLAG_VMA_LOCK check from handle_mm_fault() Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 04/10] mm: Handle PUD faults under the VMA lock Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 05/10] mm: Handle some PMD " Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 06/10] mm: Move FAULT_FLAG_VMA_LOCK check down in handle_pte_fault() Matthew Wilcox (Oracle)
2023-07-24 18:54 ` Matthew Wilcox (Oracle) [this message]
2023-07-24 18:54 ` [PATCH v3 08/10] mm: Run the fault-around code under the VMA lock Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 09/10] mm: Handle swap and NUMA PTE faults " Matthew Wilcox (Oracle)
2023-07-24 18:54 ` [PATCH v3 10/10] mm: Handle faults that merely update the accessed bit " Matthew Wilcox (Oracle)
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=20230724185410.1124082-8-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=punit.agrawal@bytedance.com \
--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;
as well as URLs for NNTP newsgroup(s).