Skip to content

Commit d33deda

Browse files
tongtiangenpalmer-dabbelt
authored andcommitted
riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
HugeTLB pages are always fully mapped, so only setting head page's PG_dcache_clean flag is enough. Signed-off-by: Tong Tiangen <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6925ba3 commit d33deda

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

arch/riscv/include/asm/cacheflush.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ static inline void local_flush_icache_all(void)
1717

1818
static inline void flush_dcache_page(struct page *page)
1919
{
20+
/*
21+
* HugeTLB pages are always fully mapped and only head page will be
22+
* set PG_dcache_clean (see comments in flush_icache_pte()).
23+
*/
24+
if (PageHuge(page))
25+
page = compound_head(page);
26+
2027
if (test_bit(PG_dcache_clean, &page->flags))
2128
clear_bit(PG_dcache_clean, &page->flags);
2229
}

arch/riscv/mm/cacheflush.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ void flush_icache_pte(pte_t pte)
8282
{
8383
struct page *page = pte_page(pte);
8484

85+
/*
86+
* HugeTLB pages are always fully mapped, so only setting head page's
87+
* PG_dcache_clean flag is enough.
88+
*/
89+
if (PageHuge(page))
90+
page = compound_head(page);
91+
8592
if (!test_and_set_bit(PG_dcache_clean, &page->flags))
8693
flush_icache_all();
8794
}

0 commit comments

Comments
 (0)