mm/THP: Don't use HPAGE_SHIFT in transparent hugepage code
Subsystems (2)
PATCH 1/1 mm/THP: Don't use HPAGE_SHIFT in transparent hugepage code
From: "Aneesh Kumar K.V" <[email protected]>
For architectures like powerpc that support multiple explicit hugepage sizes, HPAGE_SHIFT indicate the default explicit hugepage shift. For THP to work the hugepage size should be same as PMD_SIZE. So use PMD_SHIFT directly. So move the define outside CONFIG_TRANSPARENT_HUGEPAGE #ifdef because we want to use these defines in generic code with if (pmd_trans_huge()) conditional.
--- include/linux/huge_mm.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/huge_mm.h +3 -7
@@ -58,12 +58,11 @@ extern pmd_t *page_check_address_pmd(struct page *page,#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) +#define HPAGE_PMD_SHIFT PMD_SHIFT +#define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) +#define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1))#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define HPAGE_PMD_SHIFT HPAGE_SHIFT -#define HPAGE_PMD_MASK HPAGE_MASK -#define HPAGE_PMD_SIZE HPAGE_SIZE -extern bool is_vma_temporary_stack (struct vm_area_struct *vma);#define transparent_hugepage_enabled (__vma) \
@@ -181,9 +180,6 @@ extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vm unsigned long addr, pmd_t pmd, pmd_t *pmdp);#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })#define hpage_nr_pages (x) 1
Signature · 7 lines
1.8.1.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
For architectures like powerpc that support multiple explicit hugepage sizes,
HPAGE_SHIFTindicate the default explicit hugepage shift. For THP to work the hugepage size should be same asPMD_SIZE. So usePMD_SHIFTdirectly. So move the define outsideCONFIG_TRANSPARENT_HUGEPAGE#ifdef because we want to use these defines in generic code with if (pmd_trans_huge()) conditional.
Sorry, I haven't got why you move it outside #ifdef.
If CONFIG_TRANSPARENT_HUGEPAGE disabled pmd_trans_huge() will be 0 in compile time, so BUILD_BUG() will be optimize out by GCC.
The BUILD_BUGs are useful. It's bug if you *really* use the defines with THP disabled.
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 19 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
For architectures like powerpc that support multiple explicit hugepage sizes,
HPAGE_SHIFTindicate the default explicit hugepage shift. For THP to work the hugepage size should be same asPMD_SIZE. So usePMD_SHIFTdirectly. So move the define outsideCONFIG_TRANSPARENT_HUGEPAGE#ifdef because we want to use these defines in generic code with if (pmd_trans_huge()) conditional.Signed-off-by Aneesh Kumar K.V <[email protected]>--- include/linux/huge_mm.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)include/linux/huge_mm.h +0
-0
include/linux/huge_mm.h extern pmd_t *page_check_address_pmd(struct page *page, · line 61
Quoted 4 lines
include/linux/huge_mm.h +1
-0@@ -58,12 +58,11 @@ extern pmd_t *page_check_address_pmd(struct page *page,#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) +#define HPAGE_PMD_SHIFT PMD_SHIFT
What about:
#ifndef HPAGE_PMD_SHIFT
#define HPAGE_PMD_SHIFT HPAGE_SHIFT
#endif
And define HPAGE_PMD_SHIFT in arch code if HPAGE_SHIFT is not suitable?
Quoted 29 lines
include/linux/huge_mm.h +2
-7+#define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) +#define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1))#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define HPAGE_PMD_SHIFT HPAGE_SHIFT -#define HPAGE_PMD_MASK HPAGE_MASK -#define HPAGE_PMD_SIZE HPAGE_SIZE -extern bool is_vma_temporary_stack (struct vm_area_struct *vma);#define transparent_hugepage_enabled (__vma) \@@ -181,9 +180,6 @@ extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vm unsigned long addr, pmd_t pmd, pmd_t *pmdp);#else /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) -#define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })#define hpage_nr_pages (x) 1Signature · 7 lines
1.8.1.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 27 lines · Kirill A. Shutemov
Quoted 19 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
For architectures like powerpc that support multiple explicit hugepage sizes,
HPAGE_SHIFTindicate the default explicit hugepage shift. For THP to work the hugepage size should be same asPMD_SIZE. So usePMD_SHIFTdirectly. So move the define outsideCONFIG_TRANSPARENT_HUGEPAGE#ifdef because we want to use these defines in generic code with if (pmd_trans_huge()) conditional.Signed-off-by Aneesh Kumar K.V <[email protected]>--- include/linux/huge_mm.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)include/linux/huge_mm.h +0
-0include/linux/huge_mm.h extern pmd_t *page_check_address_pmd(struct page *page, · line 61
Quoted 4 lines
include/linux/huge_mm.h +1
-0@@ -58,12 +58,11 @@ extern pmd_t *page_check_address_pmd(struct page *page,#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) +#define HPAGE_PMD_SHIFT PMD_SHIFTWhat about:
Quoted 6 lines
#ifndef
HPAGE_PMD_SHIFT
#defineHPAGE_PMD_SHIFTHPAGE_SHIFT
#endifAnd define
HPAGE_PMD_SHIFTin arch code ifHPAGE_SHIFTis not suitable?
That would work for me provided the BUILD_BUG_ON is also taken care. But is there a reason why we want to do that ? Will any value other than PMD_SHIFT work ?
The below patch shows how we want to use these. To avoid those BUILD_BUG_ON I ended up doing HUGE_PAGE_SIZE and HUGE_PAGE_MASK
https://lists.ozlabs.org/pipermail/linuxppc-dev/2013-April/105631.html
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>