LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
	Joel Stanley <joel@jms.id.au>, Jordan Niethe <jniethe5@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2] powerpc/s64: Clarify that radix lacks DEBUG_PAGEALLOC
Date: Fri, 15 Oct 2021 21:41:17 +1100	[thread overview]
Message-ID: <875ytyy3hu.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <6fb9e0ec-8ac8-1cc3-38de-78749ffee623@csgroup.eu>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 13/10/2021 à 23:34, Joel Stanley a écrit :
>> The page_alloc.c code will call into __kernel_map_pages when
>> DEBUG_PAGEALLOC is configured and enabled.
>> 
>> As the implementation assumes hash, this should crash spectacularly if
>> not for a bit of luck in __kernel_map_pages. In this function
>> linear_map_hash_count is always zero, the for loop exits without doing
>> any damage.
>> 
>> There are no other platforms that determine if they support
>> debug_pagealloc at runtime. Instead of adding code to mm/page_alloc.c to
>> do that, this change turns the map/unmap into a noop when in radix
>> mode and prints a warning once.
>> 
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> ---
>> v2: Put __kernel_map_pages in pgtable.h
>> 
>>   arch/powerpc/include/asm/book3s/64/hash.h    |  2 ++
>>   arch/powerpc/include/asm/book3s/64/pgtable.h | 11 +++++++++++
>>   arch/powerpc/include/asm/book3s/64/radix.h   |  3 +++
>>   arch/powerpc/mm/book3s64/hash_utils.c        |  2 +-
>>   arch/powerpc/mm/book3s64/radix_pgtable.c     |  7 +++++++
>>   5 files changed, 24 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
>> index d959b0195ad9..674fe0e890dc 100644
>> --- a/arch/powerpc/include/asm/book3s/64/hash.h
>> +++ b/arch/powerpc/include/asm/book3s/64/hash.h
>> @@ -255,6 +255,8 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
>>   				 int nid, pgprot_t prot);
>>   int hash__remove_section_mapping(unsigned long start, unsigned long end);
>>   
>> +void hash__kernel_map_pages(struct page *page, int numpages, int enable);
>> +
>>   #endif /* !__ASSEMBLY__ */
>>   #endif /* __KERNEL__ */
>>   #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
>> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
>> index 5d34a8646f08..265661ded238 100644
>> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
>> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
>> @@ -1101,6 +1101,17 @@ static inline void vmemmap_remove_mapping(unsigned long start,
>>   }
>>   #endif
>>   
>> +#ifdef CONFIG_DEBUG_PAGEALLOC
>> +static inline void __kernel_map_pages(struct page *page, int numpages, int enable)
>> +{
>> +	if (radix_enabled()) {
>> +		radix__kernel_map_pages(page, numpages, enable);
>> +		return;
>> +	}
>> +	hash__kernel_map_pages(page, numpages, enable);
>
> I'd have prefered something like below
>
> 	if (radix_enabled())
> 		radix__kernel_map_pages(page, numpages, enable);
> 	else
> 		hash__kernel_map_pages(page, numpages, enable);

I did that when applying.

cheers

  reply	other threads:[~2021-10-15 10:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 21:34 [PATCH v2] powerpc/s64: Clarify that radix lacks DEBUG_PAGEALLOC Joel Stanley
2021-10-14  8:45 ` Christophe Leroy
2021-10-15 10:41   ` Michael Ellerman [this message]
2021-11-02 10:11 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875ytyy3hu.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=christophe.leroy@csgroup.eu \
    --cc=jniethe5@gmail.com \
    --cc=joel@jms.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox