2024-03-29 07:38:27

by Barry Song

[permalink] [raw]
Subject: [PATCH] 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]>
Signed-off-by: Barry Song <[email protected]>
---
mm/memory.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index c9c1031c2ecb..010e7bb20d2b 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -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) {
--
2.34.1



2024-04-01 14:32:14

by Yu Zhao

[permalink] [raw]
Subject: Re: [PATCH] mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases

On Fri, Mar 29, 2024 at 3:38 AM Barry Song <[email protected]> wrote:
>
> 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.

Acked-by: Yu Zhao <[email protected]>

2024-04-01 15:20:55

by Zi Yan

[permalink] [raw]
Subject: Re: [PATCH] mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases

On 29 Mar 2024, at 3:37, Barry Song wrote:

> 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]>
> Signed-off-by: Barry Song <[email protected]>
> ---
> mm/memory.c | 3 +++
> 1 file changed, 3 insertions(+)

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

--
Best Regards,
Yan, Zi


Attachments:
signature.asc (871.00 B)
OpenPGP digital signature

2024-04-02 07:58:35

by Ryan Roberts

[permalink] [raw]
Subject: Re: [PATCH] mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases

On 29/03/2024 07:37, Barry Song wrote:
> 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]>
> Signed-off-by: Barry Song <[email protected]>

Reviewed-by: Ryan Roberts <[email protected]>

> ---
> mm/memory.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index c9c1031c2ecb..010e7bb20d2b 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -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) {