* [PATCH] mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE
@ 2022-12-23 0:38 Zach O'Keefe
2023-01-02 13:24 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: Zach O'Keefe @ 2022-12-23 0:38 UTC (permalink / raw)
To: linux-mm; +Cc: Andrew Morton, Hugh Dickins, Yang Shi, Zach O'Keefe
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.
Fixes: 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()")
Suggested-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Zach O'Keefe <zokeefe@google.com>
Cc: Yang Shi <shy828301@gmail.com>
---
mm/shmem.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index c301487be5fb..0005ab2c29af 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -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:
--
2.39.0.314.g84b9a713c41-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE
2022-12-23 0:38 [PATCH] mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE Zach O'Keefe
@ 2023-01-02 13:24 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2023-01-02 13:24 UTC (permalink / raw)
To: Zach O'Keefe, linux-mm; +Cc: Andrew Morton, Hugh Dickins, Yang Shi
On 23.12.22 01:38, Zach O'Keefe wrote:
> 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.
>
> Fixes: 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()")
> Suggested-by: Hugh Dickins <hughd@google.com>
> Signed-off-by: Zach O'Keefe <zokeefe@google.com>
> Cc: Yang Shi <shy828301@gmail.com>
> ---
> mm/shmem.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index c301487be5fb..0005ab2c29af 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -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:
Looks sane to me
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-02 13:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 0:38 [PATCH] mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE Zach O'Keefe
2023-01-02 13:24 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox