Skip to content

Commit cf5a501

Browse files
Muchun Songwilldeacon
authored andcommitted
arm64: avoid flushing icache multiple times on contiguous HugeTLB
When a contiguous HugeTLB page is mapped, set_pte_at() will be called CONT_PTES/CONT_PMDS times. Therefore, __sync_icache_dcache() will flush cache multiple times if the page is executable (to ensure the I-D cache coherency). However, the first flushing cache already covers subsequent cache flush operations. So only flusing cache for the head page if it is a HugeTLB page to avoid redundant cache flushing. In the next patch, it is also depends on this change since the tail vmemmap pages of HugeTLB is mapped with read-only meanning only head page struct can be modified. Signed-off-by: Muchun Song <songmuchun@bytedance.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20220302084624.33340-1-songmuchun@bytedance.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 2369f17 commit cf5a501

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/arm64/mm/flush.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ void __sync_icache_dcache(pte_t pte)
5252
{
5353
struct page *page = pte_page(pte);
5454

55+
/*
56+
* HugeTLB pages are always fully mapped, so only setting head page's
57+
* PG_dcache_clean flag is enough.
58+
*/
59+
if (PageHuge(page))
60+
page = compound_head(page);
61+
5562
if (!test_bit(PG_dcache_clean, &page->flags)) {
5663
sync_icache_aliases((unsigned long)page_address(page),
5764
(unsigned long)page_address(page) +

0 commit comments

Comments
 (0)