linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
@ 2019-03-07  9:47 Christophe Leroy
  2019-03-21  5:29 ` Michael Ellerman
  2019-04-21 14:18 ` Michael Ellerman
  0 siblings, 2 replies; 6+ messages in thread
From: Christophe Leroy @ 2019-03-07  9:47 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
not vital and can be replaced by a a WARN_ON

At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/mm/highmem.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
index 82a0e37557a5..b68c9f20fbdf 100644
--- a/arch/powerpc/mm/highmem.c
+++ b/arch/powerpc/mm/highmem.c
@@ -43,9 +43,7 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
 	type = kmap_atomic_idx_push();
 	idx = type + KM_TYPE_NR*smp_processor_id();
 	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-#ifdef CONFIG_DEBUG_HIGHMEM
-	BUG_ON(!pte_none(*(kmap_pte-idx)));
-#endif
+	WARN_ON(IS_ENABLED(CONFIG_DEBUG_HIGHMEM) && !pte_none(*(kmap_pte - idx)));
 	__set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot), 1);
 	local_flush_tlb_page(NULL, vaddr);
 
@@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
 void __kunmap_atomic(void *kvaddr)
 {
 	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
-	int type __maybe_unused;
+	int type;
 
 	if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
 		pagefault_enable();
@@ -66,12 +64,11 @@ void __kunmap_atomic(void *kvaddr)
 
 	type = kmap_atomic_idx();
 
-#ifdef CONFIG_DEBUG_HIGHMEM
-	{
+	if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
 		unsigned int idx;
 
 		idx = type + KM_TYPE_NR * smp_processor_id();
-		BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
+		WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
 
 		/*
 		 * force other mappings to Oops if they'll try to access
@@ -80,7 +77,6 @@ void __kunmap_atomic(void *kvaddr)
 		pte_clear(&init_mm, vaddr, kmap_pte-idx);
 		local_flush_tlb_page(NULL, vaddr);
 	}
-#endif
 
 	kmap_atomic_idx_pop();
 	pagefault_enable();
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
  2019-03-07  9:47 [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON() Christophe Leroy
@ 2019-03-21  5:29 ` Michael Ellerman
  2019-03-21  6:00   ` Christophe Leroy
  2019-04-21 14:18 ` Michael Ellerman
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2019-03-21  5:29 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linux-kernel, linuxppc-dev

Christophe Leroy <christophe.leroy@c-s.fr> writes:
> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
> not vital and can be replaced by a a WARN_ON
>
> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/mm/highmem.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
> index 82a0e37557a5..b68c9f20fbdf 100644
> --- a/arch/powerpc/mm/highmem.c
> +++ b/arch/powerpc/mm/highmem.c
> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>  void __kunmap_atomic(void *kvaddr)
>  {
>  	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
> -	int type __maybe_unused;
> +	int type;

Why don't we move type into the block below.

eg:

> @@ -66,12 +64,11 @@ void __kunmap_atomic(void *kvaddr)
>  
-  	type = kmap_atomic_idx();
>  
> -#ifdef CONFIG_DEBUG_HIGHMEM
> -	{
> +	if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
  		int type = kmap_atomic_idx();
>  		unsigned int idx;
>  
>  		idx = type + KM_TYPE_NR * smp_processor_id();
> -		BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
> +		WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));


cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
  2019-03-21  5:29 ` Michael Ellerman
@ 2019-03-21  6:00   ` Christophe Leroy
  2019-03-21 10:07     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Leroy @ 2019-03-21  6:00 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linux-kernel, linuxppc-dev



Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>> not vital and can be replaced by a a WARN_ON
>>
>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>>   arch/powerpc/mm/highmem.c | 12 ++++--------
>>   1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>> index 82a0e37557a5..b68c9f20fbdf 100644
>> --- a/arch/powerpc/mm/highmem.c
>> +++ b/arch/powerpc/mm/highmem.c
>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>>   void __kunmap_atomic(void *kvaddr)
>>   {
>>   	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>> -	int type __maybe_unused;
>> +	int type;
> 
> Why don't we move type into the block below.

Yes you're right, when Mathieu introduced the __maybe_unused, I was 
wrongly thinging that kmap_atomic_idx() was doing something important 
that had to be done also when DEBUG was not selected, but indeed it does 
nothing else than returning the type.

I'll send a new patch.

Christophe

> 
> eg:
> 
>> @@ -66,12 +64,11 @@ void __kunmap_atomic(void *kvaddr)
>>   
> -  	type = kmap_atomic_idx();
>>   
>> -#ifdef CONFIG_DEBUG_HIGHMEM
>> -	{
>> +	if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
>    		int type = kmap_atomic_idx();
>>   		unsigned int idx;
>>   
>>   		idx = type + KM_TYPE_NR * smp_processor_id();
>> -		BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
>> +		WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
> 
> 
> cheers
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
  2019-03-21  6:00   ` Christophe Leroy
@ 2019-03-21 10:07     ` Michael Ellerman
  2019-03-21 10:14       ` Christophe Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2019-03-21 10:07 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linux-kernel, linuxppc-dev

Christophe Leroy <christophe.leroy@c-s.fr> writes:

> Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>>> not vital and can be replaced by a a WARN_ON
>>>
>>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> ---
>>>   arch/powerpc/mm/highmem.c | 12 ++++--------
>>>   1 file changed, 4 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>>> index 82a0e37557a5..b68c9f20fbdf 100644
>>> --- a/arch/powerpc/mm/highmem.c
>>> +++ b/arch/powerpc/mm/highmem.c
>>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>>>   void __kunmap_atomic(void *kvaddr)
>>>   {
>>>   	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>>> -	int type __maybe_unused;
>>> +	int type;
>> 
>> Why don't we move type into the block below.
>
> Yes you're right, when Mathieu introduced the __maybe_unused, I was 
> wrongly thinging that kmap_atomic_idx() was doing something important 
> that had to be done also when DEBUG was not selected, but indeed it does 
> nothing else than returning the type.
>
> I'll send a new patch.

I can just fix it up when applying.

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
  2019-03-21 10:07     ` Michael Ellerman
@ 2019-03-21 10:14       ` Christophe Leroy
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2019-03-21 10:14 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linux-kernel, linuxppc-dev



Le 21/03/2019 à 11:07, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
> 
>> Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
>>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>>>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>>>> not vital and can be replaced by a a WARN_ON
>>>>
>>>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>>> ---
>>>>    arch/powerpc/mm/highmem.c | 12 ++++--------
>>>>    1 file changed, 4 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>>>> index 82a0e37557a5..b68c9f20fbdf 100644
>>>> --- a/arch/powerpc/mm/highmem.c
>>>> +++ b/arch/powerpc/mm/highmem.c
>>>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>>>>    void __kunmap_atomic(void *kvaddr)
>>>>    {
>>>>    	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>>>> -	int type __maybe_unused;
>>>> +	int type;
>>>
>>> Why don't we move type into the block below.
>>
>> Yes you're right, when Mathieu introduced the __maybe_unused, I was
>> wrongly thinging that kmap_atomic_idx() was doing something important
>> that had to be done also when DEBUG was not selected, but indeed it does
>> nothing else than returning the type.
>>
>> I'll send a new patch.
> 
> I can just fix it up when applying.
> 

Ok, thanks

Christophe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: powerpc/highmem: change BUG_ON() to WARN_ON()
  2019-03-07  9:47 [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON() Christophe Leroy
  2019-03-21  5:29 ` Michael Ellerman
@ 2019-04-21 14:18 ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2019-04-21 14:18 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, linux-kernel

On Thu, 2019-03-07 at 09:47:50 UTC, Christophe Leroy wrote:
> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
> not vital and can be replaced by a a WARN_ON
> 
> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/6c84f8c5cbfb4bf728f88296bc035c4a

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-21 14:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07  9:47 [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON() Christophe Leroy
2019-03-21  5:29 ` Michael Ellerman
2019-03-21  6:00   ` Christophe Leroy
2019-03-21 10:07     ` Michael Ellerman
2019-03-21 10:14       ` Christophe Leroy
2019-04-21 14:18 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).