2018-06-25 12:39:16

by Dmitry Vyukov

[permalink] [raw]
Subject: [PATCH v2] arch/x86: get rid of KERN_CONT in show_fault_oops()

From: Dmitry Vyukov <[email protected]>

KERN_CONT leads to split lines in kernel output
and complicates useful changes to printk like
printing context before each line.

Only acceptable use of continuations is basically
boot-time testing.

Get rid of it.

Signed-off-by: Dmitry Vyukov <[email protected]>

---

Changes since v1:
- use pr_alert() instead of printk(KERN_ALERT)
---
arch/x86/mm/fault.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9a84a0d08727..b9ceeaadde48 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -671,13 +671,9 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
}

- printk(KERN_ALERT "BUG: unable to handle kernel ");
- if (address < PAGE_SIZE)
- printk(KERN_CONT "NULL pointer dereference");
- else
- printk(KERN_CONT "paging request");
-
- printk(KERN_CONT " at %px\n", (void *) address);
+ pr_alert("BUG: unable to handle kernel %s at %px\n",
+ (address < PAGE_SIZE ? "NULL pointer dereference" :
+ "paging request"), (void *) address);

dump_pagetable(address);
}
--
2.18.0.rc2.346.g013aa6912e-goog



2018-06-25 15:06:10

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v2] arch/x86: get rid of KERN_CONT in show_fault_oops()

On Mon, 2018-06-25 at 14:38 +0200, Dmitry Vyukov wrote:
> From: Dmitry Vyukov <[email protected]>
>
> KERN_CONT leads to split lines in kernel output
> and complicates useful changes to printk like
> printing context before each line.
>
> Only acceptable use of continuations is basically
> boot-time testing.
>
> Get rid of it.
>
> Signed-off-by: Dmitry Vyukov <[email protected]>
>
> ---
>
> Changes since v1:
> - use pr_alert() instead of printk(KERN_ALERT)
> ---
> arch/x86/mm/fault.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
[]
> @@ -671,13 +671,9 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
> printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
> }
>
> - printk(KERN_ALERT "BUG: unable to handle kernel ");
> - if (address < PAGE_SIZE)
> - printk(KERN_CONT "NULL pointer dereference");
> - else
> - printk(KERN_CONT "paging request");
> -
> - printk(KERN_CONT " at %px\n", (void *) address);
> + pr_alert("BUG: unable to handle kernel %s at %px\n",
> + (address < PAGE_SIZE ? "NULL pointer dereference" :
> + "paging request"), (void *) address);

Perhaps remove the used-once KERN_CRIT uses of
nx_warning and smep_warning strings and maybe the
unnecessary parentheses and spaces used here too.


2018-06-26 01:30:49

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH v2] arch/x86: get rid of KERN_CONT in show_fault_oops()

On (06/25/18 14:38), Dmitry Vyukov wrote:
> From: Dmitry Vyukov <[email protected]>
>
> KERN_CONT leads to split lines in kernel output
> and complicates useful changes to printk like
> printing context before each line.
>
> Only acceptable use of continuations is basically
> boot-time testing.
>
> Get rid of it.
>
> Signed-off-by: Dmitry Vyukov <[email protected]>

FWIW, looks good to me

Reviewed-by: Sergey Senozhatsky <[email protected]>

-ss

2018-06-26 07:31:20

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: [PATCH v2] arch/x86: get rid of KERN_CONT in show_fault_oops()

On Mon, Jun 25, 2018 at 5:03 PM, Joe Perches <[email protected]> wrote:
> On Mon, 2018-06-25 at 14:38 +0200, Dmitry Vyukov wrote:
>> From: Dmitry Vyukov <[email protected]>
>>
>> KERN_CONT leads to split lines in kernel output
>> and complicates useful changes to printk like
>> printing context before each line.
>>
>> Only acceptable use of continuations is basically
>> boot-time testing.
>>
>> Get rid of it.
>>
>> Signed-off-by: Dmitry Vyukov <[email protected]>
>>
>> ---
>>
>> Changes since v1:
>> - use pr_alert() instead of printk(KERN_ALERT)
>> ---
>> arch/x86/mm/fault.c | 10 +++-------
>> 1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> []
>> @@ -671,13 +671,9 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
>> printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
>> }
>>
>> - printk(KERN_ALERT "BUG: unable to handle kernel ");
>> - if (address < PAGE_SIZE)
>> - printk(KERN_CONT "NULL pointer dereference");
>> - else
>> - printk(KERN_CONT "paging request");
>> -
>> - printk(KERN_CONT " at %px\n", (void *) address);
>> + pr_alert("BUG: unable to handle kernel %s at %px\n",
>> + (address < PAGE_SIZE ? "NULL pointer dereference" :
>> + "paging request"), (void *) address);
>
> Perhaps remove the used-once KERN_CRIT uses of
> nx_warning and smep_warning strings and maybe the
> unnecessary parentheses and spaces used here too.


Mailed v3 with both changes.

Andy actually already pointed to parentheses in v1 but I forgot about it in v2.

Subject: [tip:x86/urgent] x86/mm: Get rid of KERN_CONT in show_fault_oops()

Commit-ID: 4188f063e3694ccbf2a2044cf17cc325f91e458f
Gitweb: https://git.kernel.org/tip/4188f063e3694ccbf2a2044cf17cc325f91e458f
Author: Dmitry Vyukov <[email protected]>
AuthorDate: Mon, 25 Jun 2018 14:38:08 +0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 26 Jun 2018 09:00:25 +0200

x86/mm: Get rid of KERN_CONT in show_fault_oops()

KERN_CONT leads to split lines in kernel output
and complicates useful changes to printk like
printing context before each line.

Only acceptable use of continuations is basically
boot-time testing.

Get rid of it.

Signed-off-by: Dmitry Vyukov <[email protected]>
Reviewed-by: Sergey Senozhatsky <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Removed unnecessary parentheses and prettified the printk statement. ]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/mm/fault.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9a84a0d08727..ee85766e6329 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -671,13 +671,9 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
}

- printk(KERN_ALERT "BUG: unable to handle kernel ");
- if (address < PAGE_SIZE)
- printk(KERN_CONT "NULL pointer dereference");
- else
- printk(KERN_CONT "paging request");
-
- printk(KERN_CONT " at %px\n", (void *) address);
+ pr_alert("BUG: unable to handle kernel %s at %px\n",
+ address < PAGE_SIZE ? "NULL pointer dereference" : "paging request",
+ (void *)address);

dump_pagetable(address);
}