summaryrefslogtreecommitdiff
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorZach O'Keefe <zokeefe@google.com>2022-12-24 00:20:35 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-24 07:24:33 +0100
commit1cb76f56694965541d07c78b988f3edc837bf561 (patch)
treeef1861053403bdd2d601ef6e404594bf876ac080 /mm/shmem.c
parent0bf463939c09e5b2c35c71ed74a5fd60a74d6a04 (diff)
downloadlinux-starfive-1cb76f56694965541d07c78b988f3edc837bf561.tar.gz
linux-starfive-1cb76f56694965541d07c78b988f3edc837bf561.tar.bz2
linux-starfive-1cb76f56694965541d07c78b988f3edc837bf561.zip
mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE
commit 3de0c269adc6c2fac0bb1fb11965f0de699dc32b upstream. 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/20221224082035.3197140-2-zokeefe@google.com Fixes: 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()") Signed-off-by: Zach O'Keefe <zokeefe@google.com> Suggested-by: Hugh Dickins <hughd@google.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Yang Shi <shy828301@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 82911fefc2d5..a8d9fd039d0a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -472,12 +472,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: