hugetlbfs: Get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs
Quoted 48 lines · Hushijie
Quoted 47 lines
Quoted 15 lines · Shijie Hu
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (mm->get_unmapped_area == arch_get_unmapped_area) + return hugetlb_get_unmapped_area_bottomup(file, addr, len, + pgoff, flags); + return hugetlb_get_unmapped_area_topdown(file, addr, len, + pgoff, flags);I like this code using the value of
mm->get_unmapped_areato determine
which routine to call. It is used by a few architectures. However, I
noticed that on at least one architecture (powerpc)mm->get_unmapped_areamay be assigned to routines other thanarch_get_unmapped_areaorarch_get_unmapped_area_topdown. In such a case, we would call the 'new' topdown routine. I would prefer that we call the bottomup routine in this default case.Quoted 3 lines
In reality, this does not impact powerpc as that architecture has it's own
hugetlb_get_unmapped_arearoutine.Yes, I also noticed this before, powerpc uses radix__arch_get_unmapped_area*() when
CONFIG_PPC_RADIX_MMUopened as 'y' andradix_enabled()returns true. However, powerpc implemented its ownhugetlb_get_unmapped_area(). This patch actually has no effect on powerpc.Quoted 14 lines
Because of this, I suggest we add a comment above this code and switch the if/else order. For example,
(quoted diff) +10
-0+ /* + * Use mm->get_unmapped_area value as a hint to use topdown routine. + * If architectures have special needs, they should define their own + * version of hugetlb_get_unmapped_area. + */ + if (mm->get_unmapped_area == arch_get_unmapped_area_topdown) + return hugetlb_get_unmapped_area_topdown(file, addr, len, + pgoff, flags); + return hugetlb_get_unmapped_area_bottomup(file, addr, len, + pgoff, flags);Quoted 4 lines
Thoughts?
Signature · 1 line
Mike KravetzI agree with you. It's clever to switch the if/else order. If there is such a case,
mm->get_unmapped_area()is neihterarch_get_unmapped_area()norarch_get_unmapped_area_topdown(), it is indeed more appropriate to make the bottomup routine as the default behavior.
Quoted 9 lines
Quoted 2 lines
May I put this code and comment you show above into patch v6 and add "Signed-off-by: Mike Kravetz <[email protected]>" to it?
Feel free to add this code and my Signed-off-by.
I assume this still works for your use case. Correct?
Signature · 1 line
Mike Kravetz
Yes, It still works for our use case.
Thanks for your replies and suggestions, I will submit patch v6 later. --
Shijie Hu