[v2,1/3] powerpc: Stop using pr_cont() in __die()

Message ID 20190110115737.30931-1-mpe@ellerman.id.au
State Accepted
Commit 782274434d6f2e8aa8c573cb24fef94a164f2ce0
Headers show
Series
  • [v2,1/3] powerpc: Stop using pr_cont() in __die()
Related show

Checks

Context Check Description
snowpatch_ozlabs/checkpatch warning total: 0 errors, 2 warnings, 0 checks, 32 lines checked
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied

Commit Message

Michael Ellerman Jan. 10, 2019, 11:57 a.m.
Using pr_cont() risks having our output interleaved with other output
from other CPUs. Instead print everything in a single printk() call.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/traps.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

v2: Use a single printk with (mostly) compile time checks rather than
constructing the string with seq_buf.

Comments

Christophe Leroy Jan. 10, 2019, 1:40 p.m. | #1
Le 10/01/2019 à 12:57, Michael Ellerman a écrit :
> Using pr_cont() risks having our output interleaved with other output
> from other CPUs. Instead print everything in a single printk() call.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

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

> ---
>   arch/powerpc/kernel/traps.c | 26 ++++++++------------------
>   1 file changed, 8 insertions(+), 18 deletions(-)
> 
> v2: Use a single printk with (mostly) compile time checks rather than
> constructing the string with seq_buf.
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index 64936b60d521..164fc92895be 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -257,24 +257,14 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>   {
>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);

Maybe this printk() should also be merge with the following to further 
limit risks of interleaving ?

Christophe

>   
> -	if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
> -		printk("LE ");
> -	else
> -		printk("BE ");
> -
> -	if (IS_ENABLED(CONFIG_PREEMPT))
> -		pr_cont("PREEMPT ");
> -
> -	if (IS_ENABLED(CONFIG_SMP))
> -		pr_cont("SMP NR_CPUS=%d ", NR_CPUS);
> -
> -	if (debug_pagealloc_enabled())
> -		pr_cont("DEBUG_PAGEALLOC ");
> -
> -	if (IS_ENABLED(CONFIG_NUMA))
> -		pr_cont("NUMA ");
> -
> -	pr_cont("%s\n", ppc_md.name ? ppc_md.name : "");
> +	printk("%s %s%s%s%s%s %s\n",
> +	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
> +	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
> +	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
> +	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
> +	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
> +	       IS_ENABLED(CONFIG_NUMA) ? " NUMA" : "",
> +	       ppc_md.name ? ppc_md.name : "");
>   
>   	if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV) == NOTIFY_STOP)
>   		return 1;
>
Michael Ellerman Jan. 11, 2019, 10:30 a.m. | #2
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Le 10/01/2019 à 12:57, Michael Ellerman a écrit :
>> Using pr_cont() risks having our output interleaved with other output
>> from other CPUs. Instead print everything in a single printk() call.
>> 
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
>
>> ---
>>   arch/powerpc/kernel/traps.c | 26 ++++++++------------------
>>   1 file changed, 8 insertions(+), 18 deletions(-)
>> 
>> v2: Use a single printk with (mostly) compile time checks rather than
>> constructing the string with seq_buf.
>> 
>> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
>> index 64936b60d521..164fc92895be 100644
>> --- a/arch/powerpc/kernel/traps.c
>> +++ b/arch/powerpc/kernel/traps.c
>> @@ -257,24 +257,14 @@ static int __die(const char *str, struct pt_regs *regs, long err)
>>   {
>>   	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>
> Maybe this printk() should also be merge with the following to further 
> limit risks of interleaving ?

Possibly yeah.

Though I was comparing it to other arches and I think we could improve
the info on that line. So I'll leave it for now.

cheers

Patch

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 64936b60d521..164fc92895be 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -257,24 +257,14 @@  static int __die(const char *str, struct pt_regs *regs, long err)
 {
 	printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
 
-	if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
-		printk("LE ");
-	else
-		printk("BE ");
-
-	if (IS_ENABLED(CONFIG_PREEMPT))
-		pr_cont("PREEMPT ");
-
-	if (IS_ENABLED(CONFIG_SMP))
-		pr_cont("SMP NR_CPUS=%d ", NR_CPUS);
-
-	if (debug_pagealloc_enabled())
-		pr_cont("DEBUG_PAGEALLOC ");
-
-	if (IS_ENABLED(CONFIG_NUMA))
-		pr_cont("NUMA ");
-
-	pr_cont("%s\n", ppc_md.name ? ppc_md.name : "");
+	printk("%s %s%s%s%s%s %s\n",
+	       IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
+	       IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
+	       IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
+	       IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
+	       debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
+	       IS_ENABLED(CONFIG_NUMA) ? " NUMA" : "",
+	       ppc_md.name ? ppc_md.name : "");
 
 	if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV) == NOTIFY_STOP)
 		return 1;