mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
mm: don't allow huge faults for files with pre content watches
There's nothing stopping us from supporting this, we could simply pass the order into the helper and emit the proper length. However currently there's no tests to validate this works properly, so disable it until there's a desire to support this along with the appropriate tests. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/9035b82cff08a3801cef3d06bbf2778b2e5a4dba.1731684329.git.josef@toxicpanda.com
This commit is contained in:
parent
fac84846a2
commit
20bf82a898
19
mm/memory.c
19
mm/memory.c
@ -76,6 +76,7 @@
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/sched/sysctl.h>
|
||||
#include <linux/fsnotify.h>
|
||||
|
||||
#include <trace/events/kmem.h>
|
||||
|
||||
@ -5662,8 +5663,17 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
|
||||
static inline vm_fault_t create_huge_pmd(struct vm_fault *vmf)
|
||||
{
|
||||
struct vm_area_struct *vma = vmf->vma;
|
||||
|
||||
if (vma_is_anonymous(vma))
|
||||
return do_huge_pmd_anonymous_page(vmf);
|
||||
/*
|
||||
* Currently we just emit PAGE_SIZE for our fault events, so don't allow
|
||||
* a huge fault if we have a pre content watch on this file. This would
|
||||
* be trivial to support, but there would need to be tests to ensure
|
||||
* this works properly and those don't exist currently.
|
||||
*/
|
||||
if (unlikely(FMODE_FSNOTIFY_HSM(vma->vm_file->f_mode)))
|
||||
return VM_FAULT_FALLBACK;
|
||||
if (vma->vm_ops->huge_fault)
|
||||
return vma->vm_ops->huge_fault(vmf, PMD_ORDER);
|
||||
return VM_FAULT_FALLBACK;
|
||||
@ -5687,6 +5697,9 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf)
|
||||
}
|
||||
|
||||
if (vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) {
|
||||
/* See comment in create_huge_pmd. */
|
||||
if (unlikely(FMODE_FSNOTIFY_HSM(vma->vm_file->f_mode)))
|
||||
goto split;
|
||||
if (vma->vm_ops->huge_fault) {
|
||||
ret = vma->vm_ops->huge_fault(vmf, PMD_ORDER);
|
||||
if (!(ret & VM_FAULT_FALLBACK))
|
||||
@ -5709,6 +5722,9 @@ static vm_fault_t create_huge_pud(struct vm_fault *vmf)
|
||||
/* No support for anonymous transparent PUD pages yet */
|
||||
if (vma_is_anonymous(vma))
|
||||
return VM_FAULT_FALLBACK;
|
||||
/* See comment in create_huge_pmd. */
|
||||
if (unlikely(FMODE_FSNOTIFY_HSM(vma->vm_file->f_mode)))
|
||||
return VM_FAULT_FALLBACK;
|
||||
if (vma->vm_ops->huge_fault)
|
||||
return vma->vm_ops->huge_fault(vmf, PUD_ORDER);
|
||||
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
|
||||
@ -5726,6 +5742,9 @@ static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud)
|
||||
if (vma_is_anonymous(vma))
|
||||
goto split;
|
||||
if (vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) {
|
||||
/* See comment in create_huge_pmd. */
|
||||
if (unlikely(FMODE_FSNOTIFY_HSM(vma->vm_file->f_mode)))
|
||||
goto split;
|
||||
if (vma->vm_ops->huge_fault) {
|
||||
ret = vma->vm_ops->huge_fault(vmf, PUD_ORDER);
|
||||
if (!(ret & VM_FAULT_FALLBACK))
|
||||
|
Loading…
Reference in New Issue
Block a user