Skip to content

Commit 3de0c26

Browse files
zokeefeakpm00
authored andcommitted
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. Restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE. Link: https://lkml.kernel.org/r/[email protected] Fixes: 7c6c6cc ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()") Signed-off-by: Zach O'Keefe <[email protected]> Suggested-by: Hugh Dickins <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Yang Shi <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 52dc031 commit 3de0c26

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mm/shmem.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,10 @@ bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,
478478
if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) ||
479479
test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags)))
480480
return false;
481-
if (shmem_huge_force)
482-
return true;
483-
if (shmem_huge == SHMEM_HUGE_FORCE)
484-
return true;
485481
if (shmem_huge == SHMEM_HUGE_DENY)
486482
return false;
483+
if (shmem_huge_force || shmem_huge == SHMEM_HUGE_FORCE)
484+
return true;
487485

488486
switch (SHMEM_SB(inode->i_sb)->huge) {
489487
case SHMEM_HUGE_ALWAYS:

0 commit comments

Comments
 (0)