This is a note to let you know that I've just added the patch titled mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-shmem-restore-shmem_huge_deny-precedence-over-madv_collapse.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3de0c269adc6c2fac0bb1fb11965f0de699dc32b Mon Sep 17 00:00:00 2001 From: Zach O'Keefe <zokeefe@xxxxxxxxxx> Date: Sat, 24 Dec 2022 00:20:35 -0800 Subject: mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE From: Zach O'Keefe <zokeefe@xxxxxxxxxx> 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@xxxxxxxxxx Fixes: 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()") Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx> Suggested-by: Hugh Dickins <hughd@xxxxxxxxxx> Acked-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/shmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -472,12 +472,10 @@ bool shmem_is_huge(struct vm_area_struct 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: Patches currently in stable-queue which might be from zokeefe@xxxxxxxxxx are queue-6.1/mm-khugepaged-fix-collapse_pte_mapped_thp-to-allow-anon_vma.patch queue-6.1/mm-shmem-restore-shmem_huge_deny-precedence-over-madv_collapse.patch