FROMLIST: 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@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-29-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I52720f24949d69b3ccaa7dbc1173e47b030fcaaf
This commit is contained in:
Michel Lespinasse
2022-01-24 17:43:56 -08:00
committed by Todd Kjos
parent aa9ae5c915
commit 959fc0f0f1

View File

@@ -1328,6 +1328,13 @@ 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)
@@ -1362,7 +1369,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