Re: [RFC PATCH 33/37] mm: enable speculative fault handling only for multithreaded user space

From: Matthew Wilcox
Date: Tue Apr 06 2021 - 22:49:04 EST


On Tue, Apr 06, 2021 at 06:44:58PM -0700, Michel Lespinasse wrote:
> + /* Only try spf for multithreaded user space faults. */

This comment is misleading ... mm_users will also be incremented for
ptraced programs as well as programs that are having their /proc/$pid/maps
examined, etc. Maybe:

/* No need to try spf for single-threaded programs */

Also, please, can we not use an acronym for this feature? It's not a
speculative page fault. The page fault is really happening. We're
trying to handle it under RCU protection (if anything the faultaround
code is the speculative page fault code ...) This is unlocked page
fault handling, perhaps?

> + 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)
> @@ -1351,6 +1355,7 @@ void do_user_addr_fault(struct pt_regs *regs,
>
> spf_abort:
> count_vm_event(SPF_ABORT);
> +no_spf:
>
> /*
> * Kernel-mode access to the user address space should only occur
> --
> 2.20.1
>
>