[V2, 66/68] powerpc/mm/radix: Add THP support for 4k linux page size

Aneesh Kumar K.V aneesh.kumar at linux.vnet.ibm.com
Thu Apr 28 16:28:47 AEST 2016


Michael Ellerman <mpe at ellerman.id.au> writes:

> On Sat, 2016-09-04 at 06:14:02 UTC, "Aneesh Kumar K.V" wrote:
>
> Missing change log.

This add THP support for 4K linux page size config with Radix. We still
don't do THP with 4K linux page size and hash page table. Hash page
table needs a 16MB hugepage and we can't do THP with 16MM hugepage and
4K linux page size.

We add missing functions to 4k hash config to get it build and
hl_has_transparent_hugepage() make sure we don't enable THP for 4K hash
config. To catch wrong usage of THP related with 4K config, we add BUG()
in those dummpy functions we added to get it compile.


>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
>> 
>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
>> index bb3d8539bb1b..d915788d5074 100644
>> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
>> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
>> @@ -50,6 +50,65 @@ static inline int hl_hugepd_ok(hugepd_t hpd)
>>  }
>>  #endif
>>  
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> +
>> +static inline char *get_hpte_slot_array(pmd_t *pmdp)
>> +{
>> +	BUG();
>> +	return NULL;
>> +}
>
> ...
>
>> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
>> index 53299182dba9..ad9c77399aab 100644
>> --- a/arch/powerpc/platforms/Kconfig.cputype
>> +++ b/arch/powerpc/platforms/Kconfig.cputype
>> @@ -72,7 +72,7 @@ config PPC_BOOK3S_64
>>  	select PPC_FPU
>>  	select PPC_HAVE_PMU_SUPPORT
>>  	select SYS_SUPPORTS_HUGETLBFS
>> -	select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES
>> +	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
>
>
> How is this meant to work?
>
> It appears to allow me to build a 4K kernel with THP which will then BUG() as
> soon as I run it on hash?
>
> I assume you'll tell me there's some mechanism somewhere that prevents that from
> happening, but what is it?
>

This one.

int hl_has_transparent_hugepage(void)
{

	if (!mmu_has_feature(MMU_FTR_16M_PAGE))
		return 0;
	/*
	 * We support THP only if PMD_SIZE is 16MB.
	 */
	if (mmu_psize_defs[MMU_PAGE_16M].shift != PMD_SHIFT)
		return 0;
	/*
	 * We need to make sure that we support 16MB hugepage in a segement
	 * with base page size 64K or 4K. We only enable THP with a PAGE_SIZE
	 * of 64K.
	 */
	/*
	 * If we have 64K HPTE, we will be using that by default
	 */
	if (mmu_psize_defs[MMU_PAGE_64K].shift &&
	    (mmu_psize_defs[MMU_PAGE_64K].penc[MMU_PAGE_16M] == -1))
		return 0;
	/*
	 * Ok we only have 4K HPTE
	 */
	if (mmu_psize_defs[MMU_PAGE_4K].penc[MMU_PAGE_16M] == -1)
		return 0;

	return 1;
}

So we will enable THP on a platform only if has_transparent_hugepage()
return 1.

-aneesh



More information about the Linuxppc-dev mailing list