Skip to content

Commit cf54f31

Browse files
yuzhaogoogleakpm00
authored andcommitted
mm/hugetlb: use __GFP_COMP for gigantic folios
Use __GFP_COMP for gigantic folios to greatly reduce not only the amount of code but also the allocation and free time. LOC (approximately): +60, -240 Allocate and free 500 1GB hugeTLB memory without HVO by: time echo 500 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages time echo 0 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages Before After Alloc ~13s ~10s Free ~15s <1s The above magnitude generally holds for multiple x86 and arm64 CPU models. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yu Zhao <[email protected]> Reported-by: Frank van der Linden <[email protected]> Acked-by: Zi Yan <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Muchun Song <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 463586e commit cf54f31

File tree

2 files changed

+61
-238
lines changed

2 files changed

+61
-238
lines changed

include/linux/hugetlb.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,11 @@ static inline bool hugepage_movable_supported(struct hstate *h)
896896
/* Movability of hugepages depends on migration support. */
897897
static inline gfp_t htlb_alloc_mask(struct hstate *h)
898898
{
899-
if (hugepage_movable_supported(h))
900-
return GFP_HIGHUSER_MOVABLE;
901-
else
902-
return GFP_HIGHUSER;
899+
gfp_t gfp = __GFP_COMP | __GFP_NOWARN;
900+
901+
gfp |= hugepage_movable_supported(h) ? GFP_HIGHUSER_MOVABLE : GFP_HIGHUSER;
902+
903+
return gfp;
903904
}
904905

905906
static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)

0 commit comments

Comments
 (0)