Skip to contentSkip to conversation

mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases

PATCH Applied Barry Song 4 participants 4 messages Mar 29, 2024 – Apr 2, 2024

Subsystems (2)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases

From: Barry Song <[email protected]>

Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability.

Cc Ryan Roberts <[email protected]>
Cc Kefeng Wang <[email protected]>
Cc John Hubbard <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Alistair Popple <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Itaru Kitayama <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>
Cc Yin Fengwei <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Zi Yan <[email protected]>
---
 mm/memory.c | 3 +++
 1 file changed, 3 insertions(+)
mm/memory.c +3 -0
index c9c1031c2ecb..010e7bb20d2b 100644
@@ -4353,6 +4353,9 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf)
 
 	pte_unmap(pte);
 
+	if (!orders)
+		goto fallback;
+
 	/* Try allocating the highest of the remaining orders. */
 	gfp = vma_thp_gfp_mask(vma);
 	while (orders) {
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Barry Song

From: Barry Song <[email protected]>

Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability.

#2 lore raw
In reply to Barry Song
Quoted 28 lines · Barry Song

From: Barry Song <[email protected]>

Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability.

Cc Ryan Roberts <[email protected]>
Cc Kefeng Wang <[email protected]>
Cc John Hubbard <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Alistair Popple <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Itaru Kitayama <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>
Cc Yin Fengwei <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Zi Yan <[email protected]>
Quoted 3 lines
---
 mm/memory.c | 3 +++
 1 file changed, 3 insertions(+)

LGTM. Reviewed-by: Zi Yan <[email protected]>

--
Best Regards,
Yan, Zi

Reviewed-by on v1 1/1
#3 lore raw
In reply to Barry Song
Quoted 20 lines · Barry Song

From: Barry Song <[email protected]>

Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability.

Cc Ryan Roberts <[email protected]>
Cc Kefeng Wang <[email protected]>
Cc John Hubbard <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Alistair Popple <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Itaru Kitayama <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Quoted 8 lines
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>
Cc Yin Fengwei <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Zi Yan <[email protected]>
Quoted 18 lines
---
 mm/memory.c | 3 +++
 1 file changed, 3 insertions(+)
mm/memory.c +3 -0
index c9c1031c2ecb..010e7bb20d2b 100644
@@ -4353,6 +4353,9 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf)
 
 	pte_unmap(pte);
 
+	if (!orders)
+		goto fallback;
+
 	/* Try allocating the highest of the remaining orders. */
 	gfp = vma_thp_gfp_mask(vma);
 	while (orders) {