[PATCH v2 5/9] powerpc: Use preempt_model_str().

Sebastian Andrzej Siewior posted 9 patches 1 year ago
There is a newer version of this series
[PATCH v2 5/9] powerpc: Use preempt_model_str().
Posted by Sebastian Andrzej Siewior 1 year ago
Use preempt_model_str() instead of manually conducting the preemption
model. Use pr_emerg() instead of printk() to pass a loglevel.

Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/powerpc/kernel/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index edf5cabe5dfdb..9eb383189cfb2 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs *regs, long err)
 {
 	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
 
-	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
+	pr_emerg("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
 	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
 	       PAGE_SIZE / 1024, get_mmu_str(),
-	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
+	       preempt_model_str(),
 	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
 	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
 	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
-- 
2.47.2
Re: [PATCH v2 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 1 year ago

Le 03/02/2025 à 15:16, Sebastian Andrzej Siewior a écrit :
> Use preempt_model_str() instead of manually conducting the preemption
> model. Use pr_emerg() instead of printk() to pass a loglevel.

Why use pr_emerg() for that line and not all other ones ?

The purpose of using printk() is to get it at the level defined by 
CONFIG_MESSAGE_LOGLEVEL_DEFAULT and I think it is important to have the 
full Oops block at the same level.

> 
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   arch/powerpc/kernel/traps.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index edf5cabe5dfdb..9eb383189cfb2 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>   {
>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>   
> -	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
> +	pr_emerg("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>   	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>   	       PAGE_SIZE / 1024, get_mmu_str(),
> -	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
> +	       preempt_model_str(),
>   	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>   	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
>   	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",

Re: [PATCH v2 5/9] powerpc: Use preempt_model_str().
Posted by Sebastian Andrzej Siewior 1 year ago
On 2025-02-03 16:19:06 [+0100], Christophe Leroy wrote:
> 
> 
> Le 03/02/2025 à 15:16, Sebastian Andrzej Siewior a écrit :
> > Use preempt_model_str() instead of manually conducting the preemption
> > model. Use pr_emerg() instead of printk() to pass a loglevel.
> 
> Why use pr_emerg() for that line and not all other ones ?

checkpatch complained for the current printk() line and this looks like
an emergency coming from die().

> The purpose of using printk() is to get it at the level defined by
> CONFIG_MESSAGE_LOGLEVEL_DEFAULT and I think it is important to have the full
> Oops block at the same level.

Okay. So "printk(KERN_DEFAULT " then.

Sebastian
Re: [PATCH v2 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 1 year ago

Le 03/02/2025 à 17:01, Sebastian Andrzej Siewior a écrit :
> On 2025-02-03 16:19:06 [+0100], Christophe Leroy wrote:
>>
>>
>> Le 03/02/2025 à 15:16, Sebastian Andrzej Siewior a écrit :
>>> Use preempt_model_str() instead of manually conducting the preemption
>>> model. Use pr_emerg() instead of printk() to pass a loglevel.
>>
>> Why use pr_emerg() for that line and not all other ones ?
> 
> checkpatch complained for the current printk() line and this looks like
> an emergency coming from die().

Right but checkpatch only looks at the line you modify with your patch, 
it doesn't consider the global picture.

> 
>> The purpose of using printk() is to get it at the level defined by
>> CONFIG_MESSAGE_LOGLEVEL_DEFAULT and I think it is important to have the full
>> Oops block at the same level.
> 
> Okay. So "printk(KERN_DEFAULT " then.

Up to you, I'm fine with that but you should consistently update all 
printk's in the function, not only that one, so is it really worth it ?

Christophe

[PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Sebastian Andrzej Siewior 1 year ago
Use preempt_model_str() instead of manually conducting the preemption
model. Use pr_emerg() instead of printk() to pass a loglevel.

Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v2…v3:
  - Use printk() instead of pr_emerg() to remain consistent with the
    other invocations in terms of printing context.

 arch/powerpc/kernel/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index edf5cabe5dfdb..d6d77d92b3358 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs *regs, long err)
 {
 	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
 
-	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
+	printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
 	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
 	       PAGE_SIZE / 1024, get_mmu_str(),
-	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
+	       preempt_model_str(),
 	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
 	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
 	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
-- 
2.47.2
Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Shrikanth Hegde 1 year ago

On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
> Use preempt_model_str() instead of manually conducting the preemption
> model. Use pr_emerg() instead of printk() to pass a loglevel.

even on powerpc, i see __die ends up calling show_regs_print_info().
Why print it twice?

> 
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> v2…v3:
>    - Use printk() instead of pr_emerg() to remain consistent with the
>      other invocations in terms of printing context.
> 
>   arch/powerpc/kernel/traps.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index edf5cabe5dfdb..d6d77d92b3358 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>   {
>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>   
> -	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
> +	printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>   	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>   	       PAGE_SIZE / 1024, get_mmu_str(),
> -	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
> +	       preempt_model_str(),
>   	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>   	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
>   	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",

Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Sebastian Andrzej Siewior 12 months ago
On 2025-02-08 13:05:57 [+0530], Shrikanth Hegde wrote:
> 
> 
> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
> > Use preempt_model_str() instead of manually conducting the preemption
> > model. Use pr_emerg() instead of printk() to pass a loglevel.
> 
> even on powerpc, i see __die ends up calling show_regs_print_info().
> Why print it twice?

Thank you for noticing. I did remove it on other architectures, I
somehow missed it here. Will remove it from from the arch code.

Sebastian
Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Sebastian Andrzej Siewior 12 months ago
On 2025-02-10 11:59:50 [+0100], To Shrikanth Hegde wrote:
> Thank you for noticing. I did remove it on other architectures, I
> somehow missed it here. Will remove it from from the arch code.

This is what I have for powerpc now. I'm going to repost the series,
currently waiting for arm/x86.

-------->8-----------

Subject: [PATCH] powerpc: Rely on generic printing of preemption model.

After the first printk in __die() there is show_regs() ->
show_regs_print_info() which prints the current
preemption model.

Remove the preempion model from the arch code.

Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/powerpc/kernel/traps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index edf5cabe5dfdb..cb8e9357383e9 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -263,10 +263,9 @@ static int __die(const char *str, struct pt_regs *regs, long err)
 {
 	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
 
-	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
+	printk("%s PAGE_SIZE=%luK%s %s%s%s%s %s\n",
 	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
 	       PAGE_SIZE / 1024, get_mmu_str(),
-	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
 	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
 	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
 	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
-- 
2.47.2
Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Shrikanth Hegde 12 months ago

On 2/10/25 19:53, Sebastian Andrzej Siewior wrote:
> On 2025-02-10 11:59:50 [+0100], To Shrikanth Hegde wrote:
>> Thank you for noticing. I did remove it on other architectures, I
>> somehow missed it here. Will remove it from from the arch code.
> 
> This is what I have for powerpc now. I'm going to repost the series,
> currently waiting for arm/x86.
> 
> -------->8-----------
> 
> Subject: [PATCH] powerpc: Rely on generic printing of preemption model.
> 
> After the first printk in __die() there is show_regs() ->
> show_regs_print_info() which prints the current
> preemption model.
> 
> Remove the preempion model from the arch code.
> 
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   arch/powerpc/kernel/traps.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index edf5cabe5dfdb..cb8e9357383e9 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -263,10 +263,9 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>   {
>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>   
> -	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
> +	printk("%s PAGE_SIZE=%luK%s %s%s%s%s %s\n",
>   	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>   	       PAGE_SIZE / 1024, get_mmu_str(),
> -	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
>   	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>   	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
>   	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",

Looks good to me.

Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 1 year ago

Le 08/02/2025 à 08:35, Shrikanth Hegde a écrit :
> 
> 
> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
>> Use preempt_model_str() instead of manually conducting the preemption
>> model. Use pr_emerg() instead of printk() to pass a loglevel.
> 
> even on powerpc, i see __die ends up calling show_regs_print_info().
> Why print it twice?

I don't understand what you mean, what is printed twice ?

I can't see show_regs_print_info() printing the preemption model, am I 
missing something ?

Christophe

> 
>>
>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Nicholas Piggin <npiggin@gmail.com>
>> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
>> Cc: Naveen N Rao <naveen@kernel.org>
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> ---
>> v2…v3:
>>    - Use printk() instead of pr_emerg() to remain consistent with the
>>      other invocations in terms of printing context.
>>
>>   arch/powerpc/kernel/traps.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
>> index edf5cabe5dfdb..d6d77d92b3358 100644
>> --- a/arch/powerpc/kernel/traps.c
>> +++ b/arch/powerpc/kernel/traps.c
>> @@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs 
>> *regs, long err)
>>   {
>>       printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>> -    printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
>> +    printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>>              IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>>              PAGE_SIZE / 1024, get_mmu_str(),
>> -           IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
>> +           preempt_model_str(),
>>              IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>>              IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" 
>> __stringify(NR_CPUS)) : "",
>>              debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
> 

Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Shrikanth Hegde 1 year ago

On 2/8/25 18:25, Christophe Leroy wrote:
> 
> 
> Le 08/02/2025 à 08:35, Shrikanth Hegde a écrit :
>>
>>
>> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
>>> Use preempt_model_str() instead of manually conducting the preemption
>>> model. Use pr_emerg() instead of printk() to pass a loglevel.
>>
>> even on powerpc, i see __die ends up calling show_regs_print_info().
>> Why print it twice?
> 
> I don't understand what you mean, what is printed twice ?
> 
> I can't see show_regs_print_info() printing the preemption model, am I 
> missing something ?
> 

Patch 2/9 add preemption string in dump_stack_print_info.

__die -> show_regs() _> show_regs_print_info() -> 
dump_stack_print_info() -> init_utsname()->version, preempt_model_str(), 
BUILD_ID_VAL);

Wont we end up in this path?

> Christophe
> 
>>
>>>
>>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>>> Cc: Nicholas Piggin <npiggin@gmail.com>
>>> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> Cc: Naveen N Rao <naveen@kernel.org>
>>> Cc: linuxppc-dev@lists.ozlabs.org
>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>>> ---
>>> v2…v3:
>>>    - Use printk() instead of pr_emerg() to remain consistent with the
>>>      other invocations in terms of printing context.
>>>
>>>   arch/powerpc/kernel/traps.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
>>> index edf5cabe5dfdb..d6d77d92b3358 100644
>>> --- a/arch/powerpc/kernel/traps.c
>>> +++ b/arch/powerpc/kernel/traps.c
>>> @@ -263,10 +263,10 @@ static int __die(const char *str, struct 
>>> pt_regs *regs, long err)
>>>   {
>>>       printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>>> -    printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
>>> +    printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>>>              IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>>>              PAGE_SIZE / 1024, get_mmu_str(),
>>> -           IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
>>> +           preempt_model_str(),
>>>              IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>>>              IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" 
>>> __stringify(NR_CPUS)) : "",
>>>              debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
>>
> 

Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 1 year ago

Le 08/02/2025 à 14:42, Shrikanth Hegde a écrit :
> 
> 
> On 2/8/25 18:25, Christophe Leroy wrote:
>>
>>
>> Le 08/02/2025 à 08:35, Shrikanth Hegde a écrit :
>>>
>>>
>>> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
>>>> Use preempt_model_str() instead of manually conducting the preemption
>>>> model. Use pr_emerg() instead of printk() to pass a loglevel.
>>>
>>> even on powerpc, i see __die ends up calling show_regs_print_info().
>>> Why print it twice?
>>
>> I don't understand what you mean, what is printed twice ?
>>
>> I can't see show_regs_print_info() printing the preemption model, am I 
>> missing something ?
>>
> 
> Patch 2/9 add preemption string in dump_stack_print_info.
> 
> __die -> show_regs() _> show_regs_print_info() -> 
> dump_stack_print_info() -> init_utsname()->version, preempt_model_str(), 
> BUILD_ID_VAL);
> 
> Wont we end up in this path?

Indeed I missed that. You are right, we now get the information twice:

[  440.068216] BUG: Unable to handle kernel data access on write at 
0xc09036fc
[  440.075051] Faulting instruction address: 0xc045ddf8
[  440.080032] Oops: Kernel access of bad area, sig: 11 [#1]
[  440.085438] BE PAGE_SIZE=16K PREEMPT  CMPC885
[  440.089872] SAF3000 DIE NOTIFICATION
[  440.093391] CPU: 0 UID: 0 PID: 472 Comm: sh Not tainted 
6.13.0-s3k-dev-01384-g54680e2fbfb0 #1379 PREEMPT
[  440.102977] Hardware name: MIAE 8xx 0x500000 CMPC885
[  440.107951] NIP:  c045ddf8 LR: c045dde8 CTR: 00000000
[  440.113015] REGS: c9bf3d60 TRAP: 0300   Not tainted 
(6.13.0-s3k-dev-01384-g54680e2fbfb0)
[  440.121215] MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 35009393  XER: 80003100
[  440.128198] DAR: c09036fc DSISR: 82000000
[  440.128198] GPR00: c045c59c c9bf3e20 c27e7700 0000002e c108575c 
00000001 c1085850 00009032
[  440.128198] GPR08: 00000027 0198b861 00000001 3ffff000 55009393 
100d815e 7fcf5e20 100d0000
[  440.128198] GPR16: 100d0000 00000000 113e447c 113e4480 00000000 
00000001 00000000 00000000
[  440.128198] GPR24: 113e4464 00000000 c1828000 c9bf3ef8 c1136eac 
c9bf3ef8 c2888000 c0900000
[  440.168081] NIP [c045ddf8] lkdtm_WRITE_RO+0x34/0x50
[  440.172969] LR [c045dde8] lkdtm_WRITE_RO+0x24/0x50
[  440.177771] Call Trace:

Christophe

> 
>> Christophe
>>
>>>
>>>>
>>>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>>>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>>>> Cc: Nicholas Piggin <npiggin@gmail.com>
>>>> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
>>>> Cc: Naveen N Rao <naveen@kernel.org>
>>>> Cc: linuxppc-dev@lists.ozlabs.org
>>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>>>> ---
>>>> v2…v3:
>>>>    - Use printk() instead of pr_emerg() to remain consistent with the
>>>>      other invocations in terms of printing context.
>>>>
>>>>   arch/powerpc/kernel/traps.c | 4 ++--
>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
>>>> index edf5cabe5dfdb..d6d77d92b3358 100644
>>>> --- a/arch/powerpc/kernel/traps.c
>>>> +++ b/arch/powerpc/kernel/traps.c
>>>> @@ -263,10 +263,10 @@ static int __die(const char *str, struct 
>>>> pt_regs *regs, long err)
>>>>   {
>>>>       printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>>>> -    printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
>>>> +    printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>>>>              IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>>>>              PAGE_SIZE / 1024, get_mmu_str(),
>>>> -           IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
>>>> +           preempt_model_str(),
>>>>              IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>>>>              IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" 
>>>> __stringify(NR_CPUS)) : "",
>>>>              debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
>>>
>>
> 

Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Shrikanth Hegde 1 year ago

On 2/8/25 23:25, Christophe Leroy wrote:
> 
> 
> Le 08/02/2025 à 14:42, Shrikanth Hegde a écrit :
>>
>>
>> On 2/8/25 18:25, Christophe Leroy wrote:
>>>
>>>
>>> Le 08/02/2025 à 08:35, Shrikanth Hegde a écrit :
>>>>
>>>>
>>>> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
>>>>> Use preempt_model_str() instead of manually conducting the preemption
>>>>> model. Use pr_emerg() instead of printk() to pass a loglevel.
>>>>
>>>> even on powerpc, i see __die ends up calling show_regs_print_info().
>>>> Why print it twice?
>>>
>>> I don't understand what you mean, what is printed twice ?
>>>
>>> I can't see show_regs_print_info() printing the preemption model, am 
>>> I missing something ?
>>>
>>
>> Patch 2/9 add preemption string in dump_stack_print_info.
>>
>> __die -> show_regs() _> show_regs_print_info() -> 
>> dump_stack_print_info() -> init_utsname()->version, 
>> preempt_model_str(), BUILD_ID_VAL);
>>
>> Wont we end up in this path?
> 
> Indeed I missed that. You are right, we now get the information twice:

I think we can remove it from arch specific code and rely on lib/dump_stack?

And similar concern of printk vs pr_warn/pr_emerg would apply to that as 
well i guess.

> 
> [  440.068216] BUG: Unable to handle kernel data access on write at 
> 0xc09036fc
Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 12 months ago

Le 09/02/2025 à 15:38, Shrikanth Hegde a écrit :
> 
> 
> On 2/8/25 23:25, Christophe Leroy wrote:
>>
>>
>> Le 08/02/2025 à 14:42, Shrikanth Hegde a écrit :
>>>
>>>
>>> On 2/8/25 18:25, Christophe Leroy wrote:
>>>>
>>>>
>>>> Le 08/02/2025 à 08:35, Shrikanth Hegde a écrit :
>>>>>
>>>>>
>>>>> On 2/4/25 13:52, Sebastian Andrzej Siewior wrote:
>>>>>> Use preempt_model_str() instead of manually conducting the preemption
>>>>>> model. Use pr_emerg() instead of printk() to pass a loglevel.
>>>>>
>>>>> even on powerpc, i see __die ends up calling show_regs_print_info().
>>>>> Why print it twice?
>>>>
>>>> I don't understand what you mean, what is printed twice ?
>>>>
>>>> I can't see show_regs_print_info() printing the preemption model, am 
>>>> I missing something ?
>>>>
>>>
>>> Patch 2/9 add preemption string in dump_stack_print_info.
>>>
>>> __die -> show_regs() _> show_regs_print_info() -> 
>>> dump_stack_print_info() -> init_utsname()->version, 
>>> preempt_model_str(), BUILD_ID_VAL);
>>>
>>> Wont we end up in this path?
>>
>> Indeed I missed that. You are right, we now get the information twice:
> 
> I think we can remove it from arch specific code and rely on lib/ 
> dump_stack?

Yes I guess so.

> 
> And similar concern of printk vs pr_warn/pr_emerg would apply to that as 
> well i guess.

Well, powerpc's show_regs() calls it with 
show_regs_print_info(KERN_DEFAULT);

And dump_stack_print_info() uses printk with log_lvl so there should be 
no concern here.

> 
>>
>> [  440.068216] BUG: Unable to handle kernel data access on write at 
>> 0xc09036fc

Re: [PATCH v3 5/9] powerpc: Use preempt_model_str().
Posted by Christophe Leroy 1 year ago

Le 04/02/2025 à 09:22, Sebastian Andrzej Siewior a écrit :
> Use preempt_model_str() instead of manually conducting the preemption
> model. Use pr_emerg() instead of printk() to pass a loglevel.
> 
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
> v2…v3:
>    - Use printk() instead of pr_emerg() to remain consistent with the
>      other invocations in terms of printing context.
> 
>   arch/powerpc/kernel/traps.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index edf5cabe5dfdb..d6d77d92b3358 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -263,10 +263,10 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>   {
>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>   
> -	printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s %s\n",
> +	printk("%s PAGE_SIZE=%luK%s %s %s%s%s%s %s\n",
>   	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
>   	       PAGE_SIZE / 1024, get_mmu_str(),
> -	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
> +	       preempt_model_str(),
>   	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
>   	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
>   	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",