mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE
Subsystems (2)
PATCH 1/1 mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE
SHMEM_HUGE_DENY is for emergency use by the admin, to disable allocation of shmem huge pages if, for example, a dangerous bug is found in their
usage: see "deny" in Documentation/mm/transhuge.rst. An app using madvise(,,MADV_COLLAPSE) should not be allowed to override it: restore its precedence over shmem_huge_force.
--- mm/shmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/shmem.c +2 -4
@@ -478,12 +478,10 @@ bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,if (vma && ((vma->vm_flags &VM_NOHUGEPAGE ) ||test_bit (MMF_DISABLE_THP , &vma->vm_mm->flags)))return false; -if (shmem_huge_force) -return true; -if (shmem_huge ==SHMEM_HUGE_FORCE ) -return true;if (shmem_huge ==SHMEM_HUGE_DENY )return false; +if (shmem_huge_force || shmem_huge ==SHMEM_HUGE_FORCE ) +return true;switch (SHMEM_SB (inode->i_sb)->huge) {case SHMEM_HUGE_ALWAYS :
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Quoted 23 lines · Zach O'Keefe
SHMEM_HUGE_DENYis for emergency use by the admin, to disable allocation of shmem huge pages if, for example, a dangerous bug is found in their
usage: see "deny" inDocumentation/mm/transhuge.rst. An app usingmadvise(,,MADV_COLLAPSE)should not be allowed to override it: restore its precedence overshmem_huge_force.Fixes 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()")Suggested-by Hugh Dickins <[email protected]>Signed-off-by Zach O'Keefe <[email protected]>Cc Yang Shi <[email protected]>--- mm/shmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)mm/shmem.c +0
-1@@ -478,12 +478,10 @@ bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,if (vma && ((vma->vm_flags &VM_NOHUGEPAGE ) ||test_bit (MMF_DISABLE_THP , &vma->vm_mm->flags)))return false; -if (shmem_huge_force)
mm/shmem.c bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode, · line 487
Quoted 10 lines
mm/shmem.c +2
-3-return true; -if (shmem_huge ==SHMEM_HUGE_FORCE ) -return true;if (shmem_huge ==SHMEM_HUGE_DENY )return false; +if (shmem_huge_force || shmem_huge ==SHMEM_HUGE_FORCE ) +return true;switch (SHMEM_SB (inode->i_sb)->huge) {case SHMEM_HUGE_ALWAYS :
Looks sane to me
Signature · 3 lines
Thanks, David / dhildenb