Skip to contentSkip to conversation

hugetlbfs: Get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs

PATCH Hushijie 1 participant 1 message May 18, 2020 Memory management

lore
Share & tools
lore

Hushijie

author
#0 lore raw
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_area to 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_area may be assigned to routines other than arch_get_unmapped_area or arch_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_area routine.

Yes, I also noticed this before, powerpc uses radix__arch_get_unmapped_area*() when CONFIG_PPC_RADIX_MMU opened as 'y' and radix_enabled() returns true. However, powerpc implemented its own hugetlb_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 Kravetz

I agree with you. It's clever to switch the if/else order. If there is such a case, mm->get_unmapped_area() is neihter arch_get_unmapped_area() nor arch_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