[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210430195232.30491-26-michel@lespinasse.org>
Date: Fri, 30 Apr 2021 12:52:26 -0700
From: Michel Lespinasse <michel@...pinasse.org>
To: Linux-MM <linux-mm@...ck.org>,
Linux-Kernel <linux-kernel@...r.kernel.org>
Cc: Laurent Dufour <ldufour@...ux.ibm.com>,
Peter Zijlstra <peterz@...radead.org>,
Michal Hocko <mhocko@...e.com>,
Matthew Wilcox <willy@...radead.org>,
Rik van Riel <riel@...riel.com>,
Paul McKenney <paulmck@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Suren Baghdasaryan <surenb@...gle.com>,
Joel Fernandes <joelaf@...gle.com>,
Andy Lutomirski <luto@...nel.org>,
Michel Lespinasse <michel@...pinasse.org>
Subject: [PATCH 25/29] mm: disable speculative faults for single threaded user space
Performance tuning: single threaded userspace does not benefit from
speculative page faults, so we turn them off to avoid any related
(small) extra overheads.
Signed-off-by: Michel Lespinasse <michel@...pinasse.org>
---
arch/x86/mm/fault.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 463061186827..b5c21585e35f 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1321,6 +1321,14 @@ void do_user_addr_fault(struct pt_regs *regs,
#endif
#ifdef CONFIG_SPECULATIVE_PAGE_FAULT
+
+ /*
+ * No need to try speculative faults for kernel or
+ * single threaded user space.
+ */
+ if (!(flags & FAULT_FLAG_USER) || atomic_read(&mm->mm_users) == 1)
+ goto no_spf;
+
count_vm_event(SPF_ATTEMPT);
seq = mmap_seq_read_start(mm);
if (seq & 1)
@@ -1353,7 +1361,9 @@ void do_user_addr_fault(struct pt_regs *regs,
spf_abort:
count_vm_event(SPF_ABORT);
-#endif
+no_spf:
+
+#endif /* CONFIG_SPECULATIVE_PAGE_FAULT */
/*
* Kernel-mode access to the user address space should only occur
--
2.20.1
Powered by blists - more mailing lists