From: Miaohe Lin Date: Wed, 2 Jun 2021 03:52:45 +0000 (+1000) Subject: mm-huge_memoryc-add-missing-read-only-thp-checking-in-transparent_hugepage_enabled-v4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=52c285581b1ca0d667a411f37610622f42e21514;p=users%2Fjedix%2Flinux-maple.git mm-huge_memoryc-add-missing-read-only-thp-checking-in-transparent_hugepage_enabled-v4 define transhuge_vma_enabled next to transhuge_vma_suitable Link: https://lkml.kernel.org/r/20210514093007.4117906-1-linmiaohe@huawei.com Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS") Signed-off-by: Miaohe Lin Reviewed-by: Yang Shi Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index a35c13d1f4873..7b7f7b52ccb80 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -115,6 +115,21 @@ extern struct kobj_attribute shmem_enabled_attr; extern unsigned long transparent_hugepage_flags; +static inline bool transhuge_vma_suitable(struct vm_area_struct *vma, + unsigned long haddr) +{ + /* Don't have to check pgoff for anonymous vma */ + if (!vma_is_anonymous(vma)) { + if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, + HPAGE_PMD_NR)) + return false; + } + + if (haddr < vma->vm_start || haddr + HPAGE_PMD_SIZE > vma->vm_end) + return false; + return true; +} + static inline bool transhuge_vma_enabled(struct vm_area_struct *vma, unsigned long vm_flags) { @@ -159,21 +174,6 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) bool transparent_hugepage_active(struct vm_area_struct *vma); -static inline bool transhuge_vma_suitable(struct vm_area_struct *vma, - unsigned long haddr) -{ - /* Don't have to check pgoff for anonymous vma */ - if (!vma_is_anonymous(vma)) { - if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, - HPAGE_PMD_NR)) - return false; - } - - if (haddr < vma->vm_start || haddr + HPAGE_PMD_SIZE > vma->vm_end) - return false; - return true; -} - #define transparent_hugepage_use_zero_page() \ (transparent_hugepage_flags & \ (1<