Skip to content

Commit

Permalink
powerpc/mm: Enable compound page check for both THP and HugeTLB
Browse files Browse the repository at this point in the history
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 <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210203045812.234439-1-aneesh.kumar@linux.ibm.com
  • Loading branch information
Aneesh Kumar K.V authored and Michael Ellerman committed Feb 11, 2021
1 parent c9df3f8 commit c7ba2d6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ extern bool hugetlb_disabled;

void hugetlbpage_init_default(void);

void flush_dcache_icache_hugepage(struct page *page);

int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
unsigned long len);

Expand Down
18 changes: 0 additions & 18 deletions arch/powerpc/mm/hugetlbpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,24 +663,6 @@ static int __init hugetlbpage_init(void)

arch_initcall(hugetlbpage_init);

void flush_dcache_icache_hugepage(struct page *page)
{
int i;
void *start;

BUG_ON(!PageCompound(page));

for (i = 0; i < compound_nr(page); i++) {
if (!PageHighMem(page)) {
__flush_dcache_icache(page_address(page+i));
} else {
start = kmap_atomic(page+i);
__flush_dcache_icache(start);
kunmap_atomic(start);
}
}
}

void __init gigantic_hugetlb_cma_reserve(void)
{
unsigned long order = 0;
Expand Down
28 changes: 22 additions & 6 deletions arch/powerpc/mm/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,30 @@ void flush_dcache_page(struct page *page)
}
EXPORT_SYMBOL(flush_dcache_page);

void flush_dcache_icache_page(struct page *page)
static void flush_dcache_icache_hugepage(struct page *page)
{
#ifdef CONFIG_HUGETLB_PAGE
if (PageCompound(page)) {
flush_dcache_icache_hugepage(page);
return;
int i;
void *start;

BUG_ON(!PageCompound(page));

for (i = 0; i < compound_nr(page); i++) {
if (!PageHighMem(page)) {
__flush_dcache_icache(page_address(page+i));
} else {
start = kmap_atomic(page+i);
__flush_dcache_icache(start);
kunmap_atomic(start);
}
}
#endif
}

void flush_dcache_icache_page(struct page *page)
{

if (PageCompound(page))
return flush_dcache_icache_hugepage(page);

#if defined(CONFIG_PPC_8xx) || defined(CONFIG_PPC64)
/* On 8xx there is no need to kmap since highmem is not supported */
__flush_dcache_icache(page_address(page));
Expand Down

0 comments on commit c7ba2d6

Please sign in to comment.