arm64/mm: Enable HugeTLB migration
Subsystems (3)
v2 cover arm64/mm: Enable HugeTLB migration
This patch series enables HugeTLB migration support for all supported huge page sizes at all levels including contiguous bit implementation. Following HugeTLB migration support matrix has been enabled with this patch series. All permutations have been tested except for the 16GB.
CONT PTE PMD CONT PMD PUD
-------- --- -------- ---4K: 64K 2M 32M 1G
16K: 2M 32M 1G
64K: 2M 512M 16G
First the series adds migration support for PUD based huge pages. It then adds a platform specific hook to query an architecture if a given huge page size is supported for migration while also providing a default fallback option preserving the existing semantics which just checks for (PMD|PUD|PGDIR)_SHIFT macros. The last two patches enables HugeTLB migration on arm64 and subscribe to this new platform specific hook by defining an override.
The second patch differentiates between movability and migratability aspects of huge pages and implements hugepage_movable_supported() which can then be used during allocation to decide whether to place the huge page in movable zone or not.
Changes in V2:
- Added a new patch which differentiates migratability and movability of huge pages and implements hugepage_movable_supported() function as suggested by Michal Hocko.
Anshuman Khandual (5):
mm/hugetlb: Enable PUD level huge page migration mm/hugetlb: Distinguish between migratability and movability mm/hugetlb: Enable arch specific huge page size support for migration arm64/mm: Enable HugeTLB migration
arm64/mm: Enable HugeTLB migration for contiguous bit HugeTLB pages
arch/arm64/Kconfig | 4 ++++ arch/arm64/include/asm/hugetlb.h | 5 +++++ arch/arm64/mm/hugetlbpage.c | 20 +++++++++++++++++ include/linux/hugetlb.h | 48 +++++++++++++++++++++++++++++++++++++--- mm/hugetlb.c | 2 +- 5 files changed, 75 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/5 mm/hugetlb: Enable PUD level huge page migration
Architectures like arm64 have PUD level HugeTLB pages for certain configs (1GB huge page is PUD based on ARM64_4K_PAGES base page size) that can be enabled for migration. It can be achieved through checking for PUD_SHIFT order based HugeTLB pages during migration.
--- include/linux/hugetlb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/hugetlb.h +2 -1
@@ -483,7 +483,8 @@ static inline bool hugepage_migration_supported(struct hstate *h) {#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION if ((huge_page_shift (h) ==PMD_SHIFT ) || - (huge_page_shift (h) ==PGDIR_SHIFT )) + (huge_page_shift (h) ==PUD_SHIFT ) || + (huge_page_shift (h) ==PGDIR_SHIFT ))return true;else return false;
Signature · 1 line
2.7.4
Re: [PATCH V2 1/5] mm/hugetlb: Enable PUD level huge page migration
I planed to get to review this earlier but been busy. Anyway, this patch should be applied only after movability one to prevent from (theoretical) bisectability issues.
I would probably fold it into the one which defines arch specific hook.
Quoted 26 lines · Anshuman Khandual
Architectures like arm64 have PUD level HugeTLB pages for certain configs (1GB huge page is PUD based on
ARM64_4K_PAGESbase page size) that can be enabled for migration. It can be achieved through checking forPUD_SHIFTorder based HugeTLB pages during migration.Signed-off-by Anshuman Khandual <[email protected]>--- include/linux/hugetlb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/linux/hugetlb.h +2
-1@@ -483,7 +483,8 @@ static inline bool hugepage_migration_supported(struct hstate *h) {#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION if ((huge_page_shift (h) ==PMD_SHIFT ) || - (huge_page_shift (h) ==PGDIR_SHIFT )) + (huge_page_shift (h) ==PUD_SHIFT ) || + (huge_page_shift (h) ==PGDIR_SHIFT ))return true;else return false;Signature · 1 line
2.7.4
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH V2 1/5] mm/hugetlb: Enable PUD level huge page migration
Quoted 3 lines · Michal Hocko
I planed to get to review this earlier but been busy. Anyway, this patch should be applied only after movability one to prevent from (theoretical) bisectability issues.
Sure, I can change the order there.
Quoted 2 lines
I would probably fold it into the one which defines arch specific hook.
Hmm but that may be like doing two functionality changes together. Adding one more conditional check and at the same time wrapping it over with a new name which is part of a new scheme. I would suggest keeping the patches separate.
Re: [PATCH V2 1/5] mm/hugetlb: Enable PUD level huge page migration
Quoted 6 lines · Anshuman Khandual
Quoted 1 line · Michal Hocko
I would probably fold it into the one which defines arch specific hook.
Hmm but that may be like doing two functionality changes together. Adding one more conditional check and at the same time wrapping it over with a new name which is part of a new scheme. I would suggest keeping the patches separate.
I will surely not insist. If you think it is better this way then no objections from me of course.
Signature · 2 lines
Michal Hocko SUSE Labs
PATCH v2 2/5 mm/hugetlb: Distinguish between migratability and movability
In reply to Anshuman KhandualDuring huge page allocation it's migratability is checked to determine if it should be placed under movable zones with GFP_HIGHUSER_MOVABLE. But the movability aspect of the huge page could depend on other factors than just migratability. Movability in itself is a distinct property which should not be tied with migratability alone.
This differentiates these two and implements an enhanced movability check which also considers huge page size to determine if it is feasible to be placed under a movable zone. At present it just checks for gigantic pages but going forward it can incorporate other enhanced checks.
--- include/linux/hugetlb.h | 30 ++++++++++++++++++++++++++++++ mm/hugetlb.c | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-)
include/linux/hugetlb.h +30 -0
@@ -493,6 +493,31 @@ static inline bool hugepage_migration_supported(struct hstate *h)#endif } +/* +* Movability check is different as compared to migration check. +* It determines whether or not a huge page should be placed on +* movable zone or not. Movability of any huge page should be +* required only if huge page size is supported for migration. +* There wont be any reason for the huge page to be movable if +* it is not migratable to start with. Also the size of the huge +* page should be large enough to be placed under a movable zone +* and still feasible enough to be migratable. Just the presence +* in movable zone does not make the migration feasible. +* +* So even though large huge page sizes like the gigantic ones +* are migratable they should not be movable because its not +* feasible to migrate them from movable zone. +*/ +static inline bool hugepage_movable_supported (struct hstate *h) +{ +if (!hugepage_migration_supported (h)) +return false; + +if (hstate_is_gigantic (h)) +return false; +return true; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {
@@ -589,6 +614,11 @@ static inline bool hugepage_migration_supported(struct hstate *h)return false; } +static inline bool hugepage_movable_supported (struct hstate *h) +{ +return false; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {
mm/hugetlb.c +1 -1
@@ -919,7 +919,7 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask,/* Movability of hugepages depends on migration support. */ static inline gfp_t htlb_alloc_mask (struct hstate *h) { -if (hugepage_migration_supported (h)) +if (hugepage_movable_supported (h))return GFP_HIGHUSER_MOVABLE ;else return GFP_HIGHUSER ;
Signature · 1 line
2.7.4
Re: [PATCH V2 2/5] mm/hugetlb: Distinguish between migratability and movability
Quoted 10 lines · Anshuman Khandual
During huge page allocation it's migratability is checked to determine if it should be placed under movable zones with
GFP_HIGHUSER_MOVABLE. But the movability aspect of the huge page could depend on other factors than just migratability. Movability in itself is a distinct property which should not be tied with migratability alone.This differentiates these two and implements an enhanced movability check which also considers huge page size to determine if it is feasible to be placed under a movable zone. At present it just checks for gigantic pages but going forward it can incorporate other enhanced checks.
(nitpicking...)
The following code just checks hugepage_migration_supported(), so maybe s/Movability/Migratability/ is expected in the comment?
static int unmap_and_move_huge_page(...)
{
...
/*
* Movability of hugepages depends on architectures and hugepage size.
* This check is necessary because some callers of hugepage migration
* like soft offline and memory hotremove don't walk through page
* tables or check whether the hugepage is pmd-based or not before
* kicking migration.
*/
if (!hugepage_migration_supported(page_hstate(hpage))) {
Thanks,
Naoya Horiguchi
Quoted 73 lines
Suggested-by Michal Hocko <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- include/linux/hugetlb.h | 30 ++++++++++++++++++++++++++++++ mm/hugetlb.c | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-)include/linux/hugetlb.h +30
-0@@ -493,6 +493,31 @@ static inline bool hugepage_migration_supported(struct hstate *h)#endif } +/* +* Movability check is different as compared to migration check. +* It determines whether or not a huge page should be placed on +* movable zone or not. Movability of any huge page should be +* required only if huge page size is supported for migration. +* There wont be any reason for the huge page to be movable if +* it is not migratable to start with. Also the size of the huge +* page should be large enough to be placed under a movable zone +* and still feasible enough to be migratable. Just the presence +* in movable zone does not make the migration feasible. +* +* So even though large huge page sizes like the gigantic ones +* are migratable they should not be movable because its not +* feasible to migrate them from movable zone. +*/ +static inline bool hugepage_movable_supported (struct hstate *h) +{ +if (!hugepage_migration_supported (h)) +return false; + +if (hstate_is_gigantic (h)) +return false; +return true; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {@@ -589,6 +614,11 @@ static inline bool hugepage_migration_supported(struct hstate *h)return false; } +static inline bool hugepage_movable_supported (struct hstate *h) +{ +return false; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {mm/hugetlb.c +1
-1@@ -919,7 +919,7 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask,/* Movability of hugepages depends on migration support. */ static inline gfp_t htlb_alloc_mask (struct hstate *h) { -if (hugepage_migration_supported (h)) +if (hugepage_movable_supported (h))return GFP_HIGHUSER_MOVABLE ;else return GFP_HIGHUSER ;Signature · 1 line
2.7.4
Re: [PATCH V2 2/5] mm/hugetlb: Distinguish between migratability and movability
Quoted 16 lines · Naoya Horiguchi
Quoted 10 lines · Anshuman Khandual
During huge page allocation it's migratability is checked to determine if it should be placed under movable zones with
GFP_HIGHUSER_MOVABLE. But the movability aspect of the huge page could depend on other factors than just migratability. Movability in itself is a distinct property which should not be tied with migratability alone.This differentiates these two and implements an enhanced movability check which also considers huge page size to determine if it is feasible to be placed under a movable zone. At present it just checks for gigantic pages but going forward it can incorporate other enhanced checks.
(nitpicking...)
The following code just checkshugepage_migration_supported(), so maybe s/Movability/Migratability/ is expected in the comment?
Quoted 12 lines
static int
unmap_and_move_huge_page(...)
{
...
/*
* Movability of hugepages depends on architectures and hugepage size.
* This check is necessary because some callers of hugepage migration
* like soft offline and memory hotremove don't walk through page
* tables or check whether the hugepage is pmd-based or not before
* kicking migration.
*/
if (!hugepage_migration_supported(page_hstate(hpage))) {
Sure, will update this patch only unless other changes are suggested.
PATCH v2 3/5 mm/hugetlb: Enable arch specific huge page size support for migration
In reply to Anshuman KhandualArchitectures like arm64 have HugeTLB page sizes which are different than generic sizes at PMD, PUD, PGD level and implemented via contiguous bits. At present these special size HugeTLB pages cannot be identified through macros like (PMD|PUD|PGDIR)_SHIFT and hence chosen not be migrated.
Enabling migration support for these special HugeTLB page sizes along with the generic ones (PMD|PUD|PGD) would require identifying all of them on a given platform. A platform specific hook can precisely enumerate all huge page sizes supported for migration. Instead of comparing against standard huge page orders let hugetlb_migration_support() function call a platform hook arch_hugetlb_migration_support(). Default definition for the platform hook maintains existing semantics which checks standard huge page order. But an architecture can choose to override the default and provide support for a comprehensive set of huge page sizes.
--- include/linux/hugetlb.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
include/linux/hugetlb.h +13 -2
@@ -479,18 +479,29 @@ static inline pgoff_t basepage_index(struct page *page)extern int dissolve_free_huge_page (struct page *page);extern int dissolve_free_huge_pages (unsigned long start_pfn,unsigned long end_pfn); -static inline bool hugepage_migration_supported (struct hstate *h) -{ +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +#ifndef arch_hugetlb_migration_supported +static inline bool arch_hugetlb_migration_supported (struct hstate *h) +{if ((huge_page_shift (h) ==PMD_SHIFT ) || (huge_page_shift (h) ==PUD_SHIFT ) || (huge_page_shift (h) ==PGDIR_SHIFT ))return true;else return false; +} +#endif #else +static inline bool arch_hugetlb_migration_supported (struct hstate *h) +{return false; +}#endif + +static inline bool hugepage_migration_supported (struct hstate *h) +{ +return arch_hugetlb_migration_supported (h); }/*
Signature · 1 line
2.7.4
PATCH v2 4/5 arm64/mm: Enable HugeTLB migration
In reply to Anshuman KhandualLet arm64 subscribe to generic HugeTLB page migration framework. Right now this only works on the following PMD and PUD level HugeTLB page sizes with various kernel base page size combinations.
CONT PTE PMD CONT PMD PUD
-------- --- -------- ---
4K: NA 2M NA 1G
16K: NA 32M NA
64K: NA 512M NA--- arch/arm64/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/Kconfig +4 -0
@@ -1305,6 +1305,10 @@ config SYSVIPC_COMPAT def_bool y depends on COMPAT && SYSVIPC +config ARCH_ENABLE_HUGEPAGE_MIGRATION + def_bool y + depends on HUGETLB_PAGE && MIGRATION + menu "Power management options" source "kernel/power/Kconfig"
Signature · 1 line
2.7.4
PATCH v2 5/5 arm64/mm: Enable HugeTLB migration for contiguous bit HugeTLB pages
In reply to Anshuman KhandualLet arm64 subscribe to the previously added framework in which architecture can inform whether a given huge page size is supported for migration. This just overrides the default function arch_hugetlb_migration_supported() and enables migration for all possible HugeTLB page sizes on arm64. With this, HugeTLB migration support on arm64 now covers all possible HugeTLB options.
CONT PTE PMD CONT PMD PUD
-------- --- -------- ---
4K: 64K 2M 32M 1G16K: 2M 32M 1G
64K: 2M 512M 16G
--- arch/arm64/include/asm/hugetlb.h | 5 +++++ arch/arm64/mm/hugetlbpage.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+)
arch/arm64/include/asm/hugetlb.h +5 -0
@@ -20,6 +20,11 @@#include <asm/page.h> +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +#define arch_hugetlb_migration_supported arch_hugetlb_migration_supported +extern bool arch_hugetlb_migration_supported (struct hstate *h); +#endif +static inline pte_t huge_ptep_get (pte_t *ptep) {return READ_ONCE (*ptep);
arch/arm64/mm/hugetlbpage.c +20 -0
@@ -27,6 +27,26 @@#include <asm/tlbflush.h> #include <asm/pgalloc.h> +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +bool arch_hugetlb_migration_supported (struct hstate *h) +{ +size_t pagesize =huge_page_size (h); + +switch (pagesize) { +#ifdef CONFIG_ARM64_4K_PAGES +case PUD_SIZE : +#endif +case PMD_SIZE : +case CONT_PMD_SIZE : +case CONT_PTE_SIZE : +return true; + } +pr_warn ("%s: unrecognized huge page size 0x%lx\n" , + __func__, pagesize); +return false; +} +#endif +int pmd_huge (pmd_t pmd) {return pmd_val (pmd) && !(pmd_val (pmd) &PMD_TABLE_BIT );
Signature · 1 line
2.7.4
Quoted 24 lines · Anshuman Khandual
This patch series enables HugeTLB migration support for all supported huge page sizes at all levels including contiguous bit implementation. Following HugeTLB migration support matrix has been enabled with this patch series. All permutations have been tested except for the 16GB.
CONT PTE PMD CONT PMD PUD -------- --- -------- ---4K: 64K 2M 32M 1G
16K: 2M 32M 1G
64K: 2M 512M 16GFirst the series adds migration support for PUD based huge pages. It then adds a platform specific hook to query an architecture if a given huge page size is supported for migration while also providing a default fallback option preserving the existing semantics which just checks for (PMD|PUD|PGDIR)_SHIFT macros. The last two patches enables HugeTLB migration on arm64 and subscribe to this new platform specific hook by defining an override.
The second patch differentiates between movability and migratability aspects of huge pages and implements
hugepage_movable_supported()which can then be used during allocation to decide whether to place the huge page in movable zone or not.
Quoted 5 lines
Changes in V2:
- Added a new patch which differentiates migratability and movability of huge pages and implements
hugepage_movable_supported()function as suggested by Michal Hocko.
Hello Andrew/Michal/Mike/Naoya/Catalin,
Just checking for an update. Does this series looks okay ?
- Anshuman
Naoya Horiguchi
Reviewed-byQuoted 29 lines · Anshuman Khandual
Quoted 26 lines · Anshuman Khandual
This patch series enables HugeTLB migration support for all supported huge page sizes at all levels including contiguous bit implementation. Following HugeTLB migration support matrix has been enabled with this patch series. All permutations have been tested except for the 16GB.
CONT PTE PMD CONT PMD PUD -------- --- -------- ---4K: 64K 2M 32M 1G
16K: 2M 32M 1G
64K: 2M 512M 16GFirst the series adds migration support for PUD based huge pages. It then adds a platform specific hook to query an architecture if a given huge page size is supported for migration while also providing a default fallback option preserving the existing semantics which just checks for (PMD|PUD|PGDIR)_SHIFT macros. The last two patches enables HugeTLB migration on arm64 and subscribe to this new platform specific hook by defining an override.
The second patch differentiates between movability and migratability aspects of huge pages and implements
hugepage_movable_supported()which can then be used during allocation to decide whether to place the huge page in movable zone or not.Changes in V2:
Quoted 7 lines
Quoted 3 lines
- Added a new patch which differentiates migratability and movability of huge pages and implements
hugepage_movable_supported()function as suggested by Michal Hocko.Hello Andrew/Michal/Mike/Naoya/Catalin,
Just checking for an update. Does this series looks okay ?
Looks good to me. So for the series