76
76
#include <linux/ptrace.h>
77
77
#include <linux/vmalloc.h>
78
78
#include <linux/sched/sysctl.h>
79
+ #include <linux/fsnotify.h>
79
80
80
81
#include <trace/events/kmem.h>
81
82
@@ -5662,8 +5663,17 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
5662
5663
static inline vm_fault_t create_huge_pmd (struct vm_fault * vmf )
5663
5664
{
5664
5665
struct vm_area_struct * vma = vmf -> vma ;
5666
+
5665
5667
if (vma_is_anonymous (vma ))
5666
5668
return do_huge_pmd_anonymous_page (vmf );
5669
+ /*
5670
+ * Currently we just emit PAGE_SIZE for our fault events, so don't allow
5671
+ * a huge fault if we have a pre content watch on this file. This would
5672
+ * be trivial to support, but there would need to be tests to ensure
5673
+ * this works properly and those don't exist currently.
5674
+ */
5675
+ if (unlikely (FMODE_FSNOTIFY_HSM (vma -> vm_file -> f_mode )))
5676
+ return VM_FAULT_FALLBACK ;
5667
5677
if (vma -> vm_ops -> huge_fault )
5668
5678
return vma -> vm_ops -> huge_fault (vmf , PMD_ORDER );
5669
5679
return VM_FAULT_FALLBACK ;
@@ -5687,6 +5697,9 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf)
5687
5697
}
5688
5698
5689
5699
if (vma -> vm_flags & (VM_SHARED | VM_MAYSHARE )) {
5700
+ /* See comment in create_huge_pmd. */
5701
+ if (unlikely (FMODE_FSNOTIFY_HSM (vma -> vm_file -> f_mode )))
5702
+ goto split ;
5690
5703
if (vma -> vm_ops -> huge_fault ) {
5691
5704
ret = vma -> vm_ops -> huge_fault (vmf , PMD_ORDER );
5692
5705
if (!(ret & VM_FAULT_FALLBACK ))
@@ -5709,6 +5722,9 @@ static vm_fault_t create_huge_pud(struct vm_fault *vmf)
5709
5722
/* No support for anonymous transparent PUD pages yet */
5710
5723
if (vma_is_anonymous (vma ))
5711
5724
return VM_FAULT_FALLBACK ;
5725
+ /* See comment in create_huge_pmd. */
5726
+ if (unlikely (FMODE_FSNOTIFY_HSM (vma -> vm_file -> f_mode )))
5727
+ return VM_FAULT_FALLBACK ;
5712
5728
if (vma -> vm_ops -> huge_fault )
5713
5729
return vma -> vm_ops -> huge_fault (vmf , PUD_ORDER );
5714
5730
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
@@ -5726,6 +5742,9 @@ static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud)
5726
5742
if (vma_is_anonymous (vma ))
5727
5743
goto split ;
5728
5744
if (vma -> vm_flags & (VM_SHARED | VM_MAYSHARE )) {
5745
+ /* See comment in create_huge_pmd. */
5746
+ if (unlikely (FMODE_FSNOTIFY_HSM (vma -> vm_file -> f_mode )))
5747
+ goto split ;
5729
5748
if (vma -> vm_ops -> huge_fault ) {
5730
5749
ret = vma -> vm_ops -> huge_fault (vmf , PUD_ORDER );
5731
5750
if (!(ret & VM_FAULT_FALLBACK ))
0 commit comments