mm, hugetlb: unclutter hugetlb allocation layers
Subsystems (2)
[email protected]
maintainerPATCH 39/115 mm, hugetlb: unclutter hugetlb allocation layers
From: Michal Hocko <[email protected]>
Subject: mm, hugetlb: unclutter hugetlb allocation layers
Patch series "mm, hugetlb: allow proper node fallback dequeue".
While working on a hugetlb migration issue addressed in a separate patchset
(http://lkml.kernel.org/r/[email protected]) I have noticed that the hugetlb allocations from the preallocated pool are quite subotimal. There is no fallback mechanism implemented and no notion of preferred node. I have tried to work around it but Vlastimil was right to push back for a more robust solution. It seems that such a solution is to reuse zonelist approach we use for the page alloctor.
This series has 3 patches. The first one tries to make hugetlb allocation layers more clear. The second one implements the zonelist hugetlb pool allocation and introduces a preferred node semantic which is used by the migration callbacks. The last patch is a clean up.
This patch (of 3):
Hugetlb allocation path for fresh huge pages is unnecessarily complex and it mixes different interfaces between layers. __alloc_buddy_huge_page is the central place to perform a new allocation. It checks for the hugetlb overcommit and then relies on __hugetlb_alloc_buddy_huge_page to invoke the page allocator. This is all good except that __alloc_buddy_huge_page pushes vma and address down the callchain and so __hugetlb_alloc_buddy_huge_page has to deal with two different allocation modes - one for memory policy and other node specific (or to make it more obscure node non-specific) requests. This just screams for a reorganization.
This patch pulls out all the vma specific handling up to __alloc_buddy_huge_page_with_mpol where it belongs. __alloc_buddy_huge_page will get nodemask argument and __hugetlb_alloc_buddy_huge_page will become a trivial wrapper over the page allocator.
In short:__alloc_buddy_huge_page_with_mpol - memory policy handling
__alloc_buddy_huge_page - overcommit handling and accounting
__hugetlb_alloc_buddy_huge_page - page allocator layer
Also note that __hugetlb_alloc_buddy_huge_page and its cpuset retry loop is not really needed because the page allocator already handles the cpusets update.
Finally __hugetlb_alloc_buddy_huge_page had a special case for node specific allocations (when no policy is applied and there is a node given). This has relied on __GFP_THISNODE to not fallback to a different node. alloc_huge_page_node is the only caller which relies on this behavior so move the __GFP_THISNODE there.
Not only this removes quite some code it also should make those layers easier to follow and clear wrt responsibilities.
---
include/linux/hugetlb.h | 2 mm/hugetlb.c | 133 ++++++++------------------------------ 2 files changed, 30 insertions(+), 105 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-hugetlb-unclutter-hugetlb-allocation-layers +1 -1
@@ -349,7 +349,7 @@ struct page *alloc_huge_page(struct vm_astruct page *alloc_huge_page_node (struct hstate *h,int nid);struct page *alloc_huge_page_noerr (struct vm_area_struct *vma,unsigned long addr,int avoid_reserve); -struct page *alloc_huge_page_nodemask (struct hstate *h,const nodemask_t *nmask); +struct page *alloc_huge_page_nodemask (struct hstate *h,nodemask_t *nmask);int huge_add_to_page_cache (struct page *page,struct address_space *mapping,pgoff_t idx);
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-unclutter-hugetlb-allocation-layers +26 -101
185 lines not on this page · raw message