Skip to content

Commit c7ba2d6

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm: Enable compound page check for both THP and HugeTLB
THP config results in compound pages. Make sure the kernel enables the PageCompound() check with CONFIG_HUGETLB_PAGE disabled and CONFIG_TRANSPARENT_HUGEPAGE enabled. This makes sure we correctly flush the icache with THP pages. flush_dcache_icache_page only matter for platforms that don't support COHERENT_ICACHE. Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c9df3f8 commit c7ba2d6

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

arch/powerpc/include/asm/hugetlb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ extern bool hugetlb_disabled;
1717

1818
void hugetlbpage_init_default(void);
1919

20-
void flush_dcache_icache_hugepage(struct page *page);
21-
2220
int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
2321
unsigned long len);
2422

arch/powerpc/mm/hugetlbpage.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -663,24 +663,6 @@ static int __init hugetlbpage_init(void)
663663

664664
arch_initcall(hugetlbpage_init);
665665

666-
void flush_dcache_icache_hugepage(struct page *page)
667-
{
668-
int i;
669-
void *start;
670-
671-
BUG_ON(!PageCompound(page));
672-
673-
for (i = 0; i < compound_nr(page); i++) {
674-
if (!PageHighMem(page)) {
675-
__flush_dcache_icache(page_address(page+i));
676-
} else {
677-
start = kmap_atomic(page+i);
678-
__flush_dcache_icache(start);
679-
kunmap_atomic(start);
680-
}
681-
}
682-
}
683-
684666
void __init gigantic_hugetlb_cma_reserve(void)
685667
{
686668
unsigned long order = 0;

arch/powerpc/mm/mem.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,30 @@ void flush_dcache_page(struct page *page)
494494
}
495495
EXPORT_SYMBOL(flush_dcache_page);
496496

497-
void flush_dcache_icache_page(struct page *page)
497+
static void flush_dcache_icache_hugepage(struct page *page)
498498
{
499-
#ifdef CONFIG_HUGETLB_PAGE
500-
if (PageCompound(page)) {
501-
flush_dcache_icache_hugepage(page);
502-
return;
499+
int i;
500+
void *start;
501+
502+
BUG_ON(!PageCompound(page));
503+
504+
for (i = 0; i < compound_nr(page); i++) {
505+
if (!PageHighMem(page)) {
506+
__flush_dcache_icache(page_address(page+i));
507+
} else {
508+
start = kmap_atomic(page+i);
509+
__flush_dcache_icache(start);
510+
kunmap_atomic(start);
511+
}
503512
}
504-
#endif
513+
}
514+
515+
void flush_dcache_icache_page(struct page *page)
516+
{
517+
518+
if (PageCompound(page))
519+
return flush_dcache_icache_hugepage(page);
520+
505521
#if defined(CONFIG_PPC_8xx) || defined(CONFIG_PPC64)
506522
/* On 8xx there is no need to kmap since highmem is not supported */
507523
__flush_dcache_icache(page_address(page));

0 commit comments

Comments
 (0)