Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()

2019-03-21 Thread Christophe Leroy




Le 21/03/2019 à 11:07, Michael Ellerman a écrit :

Christophe Leroy  writes:


Le 21/03/2019 à 06:29, Michael Ellerman a écrit :

Christophe Leroy  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 
---
   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



Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()

2019-03-21 Thread Michael Ellerman
Christophe Leroy  writes:

> Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
>> Christophe Leroy  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 
>>> ---
>>>   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


Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()

2019-03-21 Thread Christophe Leroy




Le 21/03/2019 à 06:29, Michael Ellerman a écrit :

Christophe Leroy  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 
---
  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



Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()

2019-03-20 Thread Michael Ellerman
Christophe Leroy  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 
> ---
>  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