aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mm.h
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2023-08-21 14:26:20 -0700
committerAndrew Morton <akpm@linux-foundation.org>2023-08-21 14:26:20 -0700
commit5994eabf3bbbea550166ae90de0c854fc984c95d (patch)
tree6b242a70d3254c408c68157a5f5b2fa7eb9f6a4b /include/linux/mm.h
parente45a2e947dfa6da2d73e2cf91ed6399c12522d4f (diff)
parent6867c7a3320669cbe44b905a3eb35db725c6d470 (diff)
downloadlinux-5994eabf3bbbea550166ae90de0c854fc984c95d.tar.gz
merge mm-hotfixes-stable into mm-stable to pick up depended-upon changes
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r--include/linux/mm.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 88ac4cf9d3eca..55eb2789794e7 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3496,15 +3496,24 @@ static inline int vm_fault_to_errno(vm_fault_t vm_fault, int foll_flags)
* Indicates whether GUP can follow a PROT_NONE mapped page, or whether
* a (NUMA hinting) fault is required.
*/
-static inline bool gup_can_follow_protnone(unsigned int flags)
+static inline bool gup_can_follow_protnone(struct vm_area_struct *vma,
+ unsigned int flags)
{
/*
- * FOLL_FORCE has to be able to make progress even if the VMA is
- * inaccessible. Further, FOLL_FORCE access usually does not represent
- * application behaviour and we should avoid triggering NUMA hinting
- * faults.
+ * If callers don't want to honor NUMA hinting faults, no need to
+ * determine if we would actually have to trigger a NUMA hinting fault.
*/
- return flags & FOLL_FORCE;
+ if (!(flags & FOLL_HONOR_NUMA_FAULT))
+ return true;
+
+ /*
+ * NUMA hinting faults don't apply in inaccessible (PROT_NONE) VMAs.
+ *
+ * Requiring a fault here even for inaccessible VMAs would mean that
+ * FOLL_FORCE cannot make any progress, because handle_mm_fault()
+ * refuses to process NUMA hinting faults in inaccessible VMAs.
+ */
+ return !vma_is_accessible(vma);
}
typedef int (*pte_fn_t)(pte_t *pte, unsigned long addr, void *data);