Skip to content

Commit

Permalink
riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Tong Tiangen authored and palmer-dabbelt committed Dec 2, 2022
1 parent 6925ba3 commit d33deda
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/riscv/include/asm/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ static inline void local_flush_icache_all(void)

static inline void flush_dcache_page(struct page *page)
{
/*
* HugeTLB pages are always fully mapped and only head page will be
* set PG_dcache_clean (see comments in flush_icache_pte()).
*/
if (PageHuge(page))
page = compound_head(page);

if (test_bit(PG_dcache_clean, &page->flags))
clear_bit(PG_dcache_clean, &page->flags);
}
Expand Down
7 changes: 7 additions & 0 deletions arch/riscv/mm/cacheflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ void flush_icache_pte(pte_t pte)
{
struct page *page = pte_page(pte);

/*
* HugeTLB pages are always fully mapped, so only setting head page's
* PG_dcache_clean flag is enough.
*/
if (PageHuge(page))
page = compound_head(page);

if (!test_and_set_bit(PG_dcache_clean, &page->flags))
flush_icache_all();
}
Expand Down

0 comments on commit d33deda

Please sign in to comment.