Re: [PATCH 08/29] mm: add FAULT_FLAG_SPECULATIVE flag

From: Suren Baghdasaryan
Date: Wed Jun 09 2021 - 20:58:56 EST


On Fri, Apr 30, 2021 at 12:52 PM Michel Lespinasse
<michel@xxxxxxxxxxxxxx> wrote:
>
> Define the new FAULT_FLAG_SPECULATIVE flag, which indicates when we are
> attempting speculative fault handling (without holding the mmap lock).
>
> Signed-off-by: Michel Lespinasse <michel@xxxxxxxxxxxxxx>
> ---
> include/linux/mm.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 8ba434287387..021fdab5b721 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -434,6 +434,7 @@ extern pgprot_t protection_map[16];
> * @FAULT_FLAG_REMOTE: The fault is not for current task/mm.
> * @FAULT_FLAG_INSTRUCTION: The fault was during an instruction fetch.
> * @FAULT_FLAG_INTERRUPTIBLE: The fault can be interrupted by non-fatal signals.
> + * @FAULT_FLAG_SPECULATIVE: The fault is handled without holding the mmap_sem.

nit: s/mmap_sem/mmap_lock

> *
> * About @FAULT_FLAG_ALLOW_RETRY and @FAULT_FLAG_TRIED: we can specify
> * whether we would allow page faults to retry by specifying these two
> @@ -464,6 +465,7 @@ extern pgprot_t protection_map[16];
> #define FAULT_FLAG_REMOTE 0x80
> #define FAULT_FLAG_INSTRUCTION 0x100
> #define FAULT_FLAG_INTERRUPTIBLE 0x200
> +#define FAULT_FLAG_SPECULATIVE 0x400
>
> /*
> * The default fault flags that should be used by most of the
> @@ -501,7 +503,8 @@ static inline bool fault_flag_allow_retry_first(unsigned int flags)
> { FAULT_FLAG_USER, "USER" }, \
> { FAULT_FLAG_REMOTE, "REMOTE" }, \
> { FAULT_FLAG_INSTRUCTION, "INSTRUCTION" }, \
> - { FAULT_FLAG_INTERRUPTIBLE, "INTERRUPTIBLE" }
> + { FAULT_FLAG_INTERRUPTIBLE, "INTERRUPTIBLE" }, \
> + { FAULT_FLAG_SPECULATIVE, "SPECULATIVE" }
>
> /*
> * vm_fault is filled by the pagefault handler and passed to the vma's
> --
> 2.20.1
>