Re: [PATCH] mm: huge_memory: batch tlb flush when splitting a pte-mapped THP

From: Baolin Wang
Date: Thu Nov 02 2023 - 03:10:44 EST




On 11/1/2023 2:13 PM, Alistair Popple wrote:

Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> writes:

I can observe an obvious tlb flush hotpot when splitting a pte-mapped THP on

A tlb flush hotpot does sound delicious, but I think you meant hotspot :-)

Ah, yes. Hope Andrew can help to fix it :)

my ARM64 server, and the distribution of this hotspot is as follows:

- 16.85% split_huge_page_to_list
+ 7.80% down_write
- 7.49% try_to_migrate
- 7.48% rmap_walk_anon
7.23% ptep_clear_flush
+ 1.52% __split_huge_page

The reason is that the split_huge_page_to_list() will build migration entries
for each subpage of a pte-mapped Anon THP by try_to_migrate(), or unmap for
file THP, and it will clear and tlb flush for each subpage's pte. Moreover,
the split_huge_page_to_list() will set TTU_SPLIT_HUGE_PMD flag to ensure
the THP is already a pte-mapped THP before splitting it to some normal pages.

The only other user of TTU_SPLIT_HUGE_PMD is vmscan which also sets
TTU_BATCH_FLUSH so we could make the former imply the latter but that
seem dangerous given the requirement to call try_to_unmap_flush() so
best not to.

Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>

Thanks for reviewing, and also thanks to Ying and Yang.