mm: Promote huge_pmd_share from x86 to mm.
Subsystems (5)
cover mm: Promote huge_pmd_share from x86 to mm.
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full PUD_SIZE of shared huge memory that is aligned to a PUD_SIZE boundary.
The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This RFC promotes the huge_pmd_share code (and dependencies) from x86 to mm to make it accessible to other architectures.
I am working on ARM64 support for huge pages and rather than duplicate the x86 huge_pmd_share code, I thought it would be better to promote it to mm.
Comments would be very welcome.
Cheers,
Signature · 20 lines
Steve Steve Capper (2): mm: hugetlb: Copy huge_pmd_share from x86 to mm. x86: mm: Remove x86 version of huge_pmd_share. arch/x86/Kconfig | 3 ++ arch/x86/mm/hugetlbpage.c | 120 --------------------------------------------- include/linux/hugetlb.h | 4 ++ mm/hugetlb.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 120 deletions(-) -- 1.8.1.4 -- 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>
RFC PATCH 1/2 mm: hugetlb: Copy huge_pmd_share from x86 to mm.
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full PUD_SIZE of shared huge memory that is aligned to a PUD_SIZE boundary.
The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This patch copies the huge pmd sharing (and unsharing) logic from x86/ to mm/ and introduces a new config option to activate it:CONFIG_ARCH_WANTS_HUGE_PMD_SHARE.
--- include/linux/hugetlb.h | 4 ++ mm/hugetlb.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+)
include/linux/hugetlb.h +4 -0
@@ -68,6 +68,10 @@ void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);int dequeue_hwpoisoned_huge_page (struct page *page);void copy_huge_page (struct page *dst,struct page *src); +#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +pte_t *huge_pmd_share (struct mm_struct *mm,unsigned long addr,pud_t *pud); +#endif +extern unsigned long hugepages_treat_as_movable;extern const unsigned long hugetlb_zero, hugetlb_infinity;extern int sysctl_hugetlb_shm_group;
mm/hugetlb.c +122 -0
128 lines not on this page · raw message
Signature · 1 line
1.8.1.4
RFC PATCH 2/2 x86: mm: Remove x86 version of huge_pmd_share.
In reply to Steve CapperThe huge_pmd_share code has been copied over to mm/hugetlb.c to make it accessible to other architectures.
Remove the x86 copy of the huge_pmd_share code and enable the ARCH_WANT_HUGE_PMD_SHARE config flag. That way we reference the general one.
--- arch/x86/Kconfig | 3 ++ arch/x86/mm/hugetlbpage.c | 120 ---------------------------------------------- 2 files changed, 3 insertions(+), 120 deletions(-)
arch/x86/Kconfig +3 -0
@@ -212,6 +212,9 @@ config ARCH_HIBERNATION_POSSIBLE config ARCH_SUSPEND_POSSIBLE def_bool y +config ARCH_WANT_HUGE_PMD_SHARE + def_bool y + config ZONE_DMA32 bool default X86_64
arch/x86/mm/hugetlbpage.c +0 -120
126 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [RFC PATCH 1/2] mm: hugetlb: Copy huge_pmd_share from x86 to mm.
In reply to Steve CapperSteve,
Quoted 11 lines · Steve Capper
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full
PUD_SIZEof shared huge memory that is aligned to aPUD_SIZEboundary.The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This patch copies the huge pmd sharing (and unsharing) logic from x86/ to
mm/and introduces a new config option to activate it:CONFIG_ARCH_WANTS_HUGE_PMD_SHARE.
Just wondering whether more of it could be shared. The following look pretty close to what you'd write for arm64:
- huge_pte_alloc()
- huge_pte_offset() (there is a pud_large macro on x86 which checks for present & huge, we can replace it with just pud_huge in this function as it already checks for present)
- follow_huge_pud()
- follow_huge_pmd()
Of course, arch-specific macros like pud_huge, pmd_huge would have to go in a header file.
Signature · 7 lines
Catalin -- 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>
Re: [RFC PATCH 1/2] mm: hugetlb: Copy huge_pmd_share from x86 to mm.
Quoted 1 line · Catalin Marinas
Steve,
Hi Catalin,
Quoted 17 lines · Steve Capper
Quoted 11 lines
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full
PUD_SIZEof shared huge memory that is aligned to aPUD_SIZEboundary.The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This patch copies the huge pmd sharing (and unsharing) logic from x86/ to
mm/and introduces a new config option to activate it:CONFIG_ARCH_WANTS_HUGE_PMD_SHARE.Just wondering whether more of it could be shared. The following look pretty close to what you'd write for arm64:
Quoted 6 lines
-
huge_pte_alloc()
-huge_pte_offset()(there is apud_largemacro on x86 which checks for present & huge, we can replace it with justpud_hugein this function as it already checks for present)
-follow_huge_pud()
-follow_huge_pmd()
I did do something like this initially, then reined it back a bit as it placed implicit restrictions on x86 and arm64.
If we enable 64K pages on arm64 for instance, we obviate the need to share pmds (pmd_index doesn't exist for 64K pages). So I have a slightly different huge_pte_alloc function to account for this.
I would be happy to move more code from x86 to mm though, as my huge_pte_offset and follow_huge_p[mu]d functions are pretty much identical to the x86 ones. This patch, I thought, was the most I could get away with :-).
Cheers,
Signature · 1 line
Steve
Quoted 6 lines
Of course, arch-specific macros like
pud_huge,pmd_hugewould have to go in a header file.Signature · 1 line
Catalin
Re: [RFC PATCH 1/2] mm: hugetlb: Copy huge_pmd_share from x86 to mm.
Quoted 24 lines · Steve Capper
Quoted 16 lines · Catalin Marinas
Quoted 11 lines · Steve Capper
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full
PUD_SIZEof shared huge memory that is aligned to aPUD_SIZEboundary.The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This patch copies the huge pmd sharing (and unsharing) logic from x86/ to
mm/and introduces a new config option to activate it:CONFIG_ARCH_WANTS_HUGE_PMD_SHARE.Just wondering whether more of it could be shared. The following look pretty close to what you'd write for arm64:
Quoted 6 lines
-
huge_pte_alloc()
-huge_pte_offset()(there is apud_largemacro on x86 which checks for present & huge, we can replace it with justpud_hugein this function as it already checks for present)
-follow_huge_pud()
-follow_huge_pmd()
Quoted 6 lines
I did do something like this initially, then reined it back a bit as it placed implicit restrictions on x86 and arm64.
If we enable 64K pages on arm64 for instance, we obviate the need to share pmds (
pmd_indexdoesn't exist for 64K pages). So I have a slightly differenthuge_pte_allocfunction to account for this.
I guess with 64K pages on arm64 (two levels of page tables), you can't share the pmds anyway. pud_none() is defined as 0 in pgtable-nopmd.h. huge_pte_alloc() can probably be the same with 64K pages since pud_alloc always succeeds (pmd/pud/pgd are all the same).
So with some #ifdef __PAGETABLE_PMD_FOLDED (not nice but it allows for some more code sharing) you can add empty (NULL-returning) huge_pmd_share/huge_pmd_unshare functions and avoid the compiler error for pmd_index.
Signature · 7 lines
Catalin -- 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 · Steve Capper
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full
PUD_SIZEof shared huge memory that is aligned to aPUD_SIZEboundary.The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
Quoted 7 lines
This RFC promotes the
huge_pmd_sharecode (and dependencies) from x86 to mm to make it accessible to other architectures.I am working on ARM64 support for huge pages and rather than duplicate the x86
huge_pmd_sharecode, I thought it would be better to promote it to mm.
No objections to this, but I think you should do it as the first patch in a series that adds the arm support. There's no need for this to be moved until that support is tested, proposed, reviewed, and merged.
--
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 13 lines · David Rientjes
Quoted 11 lines · Steve Capper
Under x86, multiple puds can be made to reference the same bank of huge pmds provided that they represent a full
PUD_SIZEof shared huge memory that is aligned to aPUD_SIZEboundary.The code to share pmds does not require any architecture specific knowledge other than the fact that pmds can be indexed, thus can be beneficial to some other architectures.
This RFC promotes the
huge_pmd_sharecode (and dependencies) from x86 to mm to make it accessible to other architectures.
Quoted 7 lines
Quoted 3 lines
I am working on ARM64 support for huge pages and rather than duplicate the x86
huge_pmd_sharecode, I thought it would be better to promote it to mm.No objections to this, but I think you should do it as the first patch in a series that adds the arm support. There's no need for this to be moved until that support is tested, proposed, reviewed, and merged.
I agree, it would be good to see the arm64 support in this series as well (though eventual upstreaming may go via separate paths).
Signature · 7 lines
Catalin -- 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>