* [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-24 11:20 ` [PATCH 1/2] riscv: Add dump stack in show_regs Kefeng Wang
@ 2020-11-24 11:20 ` Kefeng Wang
2020-11-25 22:58 ` Atish Patra
2020-11-26 13:33 ` [PATCH v2] riscv: Using printk directly in __show_regs Kefeng Wang
2020-11-25 23:04 ` [PATCH 1/2] riscv: Add dump stack in show_regs Atish Patra
2020-12-14 11:52 ` Kefeng Wang
2 siblings, 2 replies; 21+ messages in thread
From: Kefeng Wang @ 2020-11-24 11:20 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv; +Cc: Kefeng Wang
Using printk directly and align the printing formats.
Before:
epc: ffffffe0008dc23a ra : ffffffe0008dc238 sp : ffffffe081ddbd80 gp : ffffffe0010e2c70 tp : ffffffe0800d47c0 t0 : ffffffe001018620
t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe081ddbda0 s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baaf90
a2 : 0000000000000010 a3 : 0000000000000001 a4 : 1db93e333d1e1200 a5 : 1db93e333d1e1200 a6 : 0000000000000030 a7 : ffffffffffffffff
s2 : 0000000000000000 s3 : ffffffe000b9ac80 s4 : ffffffe081d9f000 s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe081ddbe80
s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8 s11: 0000003fffbd9fa2 t3 : 1db93e333d1e1200 t4 : 0000000000000002
t5 : 0000003ff778eac8 t6 : ffffffe081ddbac8status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
After:
epc: ffffffe0008dc23e ra : ffffffe0008dc23c sp : ffffffe08221bd80
gp : ffffffe0010e2c70 tp : ffffffe081cb1ec0 t0 : ffffffe001018620
t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe08221bda0
s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baafb8
a2 : 0000000000000010 a3 : 0000000000000001 a4 : eee4a3de5cb81700
a5 : eee4a3de5cb81700 a6 : 0000000000000030 a7 : ffffffffffffffff
s2 : 0000000000000000 s3 : ffffffe000b9aca8 s4 : ffffffe081d52000
s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe08221be80
s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8
s11: 0000003fffe33fa2 t3 : eee4a3de5cb81700 t4 : 0000000000000002
t5 : 0000003fcc454ac8 t6 : ffffffe08221bac8
status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
arch/riscv/kernel/process.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index e41b733abeaa..2119d49feea5 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
{
show_regs_print_info(KERN_DEFAULT);
- pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
+ printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
regs->epc, regs->ra, regs->sp);
- pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
+ printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
regs->gp, regs->tp, regs->t0);
- pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
+ printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
regs->t1, regs->t2, regs->s0);
- pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
+ printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
regs->s1, regs->a0, regs->a1);
- pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
+ printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
regs->a2, regs->a3, regs->a4);
- pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
+ printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
regs->a5, regs->a6, regs->a7);
- pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
+ printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
regs->s2, regs->s3, regs->s4);
- pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
+ printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
regs->s5, regs->s6, regs->s7);
- pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
+ printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
regs->s8, regs->s9, regs->s10);
- pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
+ printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
regs->s11, regs->t3, regs->t4);
- pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
+ printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
regs->t5, regs->t6);
- pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
+ printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
regs->status, regs->badaddr, regs->cause);
}
void show_regs(struct pt_regs *regs)
--
2.26.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-24 11:20 ` [PATCH 2/2] riscv: Fix __show_regs printing formats Kefeng Wang
@ 2020-11-25 22:58 ` Atish Patra
2020-11-26 1:10 ` Kefeng Wang
2020-11-26 13:33 ` [PATCH v2] riscv: Using printk directly in __show_regs Kefeng Wang
1 sibling, 1 reply; 21+ messages in thread
From: Atish Patra @ 2020-11-25 22:58 UTC (permalink / raw)
To: Kefeng Wang; +Cc: linux-riscv, Albert Ou, Palmer Dabbelt, Paul Walmsley
On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Using printk directly and align the printing formats.
>
Why switch to printk ? IIRC, pr_* is preferred over printk for any new code.
> Before:
> epc: ffffffe0008dc23a ra : ffffffe0008dc238 sp : ffffffe081ddbd80 gp : ffffffe0010e2c70 tp : ffffffe0800d47c0 t0 : ffffffe001018620
> t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe081ddbda0 s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baaf90
> a2 : 0000000000000010 a3 : 0000000000000001 a4 : 1db93e333d1e1200 a5 : 1db93e333d1e1200 a6 : 0000000000000030 a7 : ffffffffffffffff
> s2 : 0000000000000000 s3 : ffffffe000b9ac80 s4 : ffffffe081d9f000 s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe081ddbe80
> s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8 s11: 0000003fffbd9fa2 t3 : 1db93e333d1e1200 t4 : 0000000000000002
> t5 : 0000003ff778eac8 t6 : ffffffe081ddbac8status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
>
> After:
> epc: ffffffe0008dc23e ra : ffffffe0008dc23c sp : ffffffe08221bd80
> gp : ffffffe0010e2c70 tp : ffffffe081cb1ec0 t0 : ffffffe001018620
> t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe08221bda0
> s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baafb8
> a2 : 0000000000000010 a3 : 0000000000000001 a4 : eee4a3de5cb81700
> a5 : eee4a3de5cb81700 a6 : 0000000000000030 a7 : ffffffffffffffff
> s2 : 0000000000000000 s3 : ffffffe000b9aca8 s4 : ffffffe081d52000
> s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe08221be80
> s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8
> s11: 0000003fffe33fa2 t3 : eee4a3de5cb81700 t4 : 0000000000000002
> t5 : 0000003fcc454ac8 t6 : ffffffe08221bac8
> status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> arch/riscv/kernel/process.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index e41b733abeaa..2119d49feea5 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
> {
> show_regs_print_info(KERN_DEFAULT);
>
> - pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
> + printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
> regs->epc, regs->ra, regs->sp);
> - pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
> + printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
> regs->gp, regs->tp, regs->t0);
> - pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
> + printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
> regs->t1, regs->t2, regs->s0);
> - pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
> + printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
> regs->s1, regs->a0, regs->a1);
> - pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
> + printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
> regs->a2, regs->a3, regs->a4);
> - pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
> + printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
> regs->a5, regs->a6, regs->a7);
> - pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
> + printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
> regs->s2, regs->s3, regs->s4);
> - pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
> + printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
> regs->s5, regs->s6, regs->s7);
> - pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
> + printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
> regs->s8, regs->s9, regs->s10);
> - pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
> + printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
> regs->s11, regs->t3, regs->t4);
> - pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
> + printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
> regs->t5, regs->t6);
>
> - pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> + printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> regs->status, regs->badaddr, regs->cause);
> }
> void show_regs(struct pt_regs *regs)
> --
> 2.26.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
--
Regards,
Atish
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-25 22:58 ` Atish Patra
@ 2020-11-26 1:10 ` Kefeng Wang
2020-11-26 10:02 ` John Ogness
0 siblings, 1 reply; 21+ messages in thread
From: Kefeng Wang @ 2020-11-26 1:10 UTC (permalink / raw)
To: Atish Patra
Cc: linux-riscv, Albert Ou, Palmer Dabbelt, John Ogness, Paul Walmsley
+ John
On 2020/11/26 6:58, Atish Patra wrote:
> On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> Using printk directly and align the printing formats.
>>
> Why switch to printk ? IIRC, pr_* is preferred over printk for any new code.
The stack output is strange, that is why I move to printk, and the old
kernel looks good.
after some test, I fould first bad commit:
[cfe2790b163acdc9c058a63bff310923e84a16b4] printk: move printk_info into
separate array
Hi John, there is printk-rework from you in v5.10-rc1, could you check
it ?
Thanks
>
>> Before:
>> epc: ffffffe0008dc23a ra : ffffffe0008dc238 sp : ffffffe081ddbd80 gp : ffffffe0010e2c70 tp : ffffffe0800d47c0 t0 : ffffffe001018620
>> t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe081ddbda0 s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baaf90
>> a2 : 0000000000000010 a3 : 0000000000000001 a4 : 1db93e333d1e1200 a5 : 1db93e333d1e1200 a6 : 0000000000000030 a7 : ffffffffffffffff
>> s2 : 0000000000000000 s3 : ffffffe000b9ac80 s4 : ffffffe081d9f000 s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe081ddbe80
>> s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8 s11: 0000003fffbd9fa2 t3 : 1db93e333d1e1200 t4 : 0000000000000002
>> t5 : 0000003ff778eac8 t6 : ffffffe081ddbac8status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
>>
>> After:
>> epc: ffffffe0008dc23e ra : ffffffe0008dc23c sp : ffffffe08221bd80
>> gp : ffffffe0010e2c70 tp : ffffffe081cb1ec0 t0 : ffffffe001018620
>> t1 : 0000000000000064 t2 : 000000000000000a s0 : ffffffe08221bda0
>> s1 : 0000000000000270 a0 : 000000000000002e a1 : ffffffe000baafb8
>> a2 : 0000000000000010 a3 : 0000000000000001 a4 : eee4a3de5cb81700
>> a5 : eee4a3de5cb81700 a6 : 0000000000000030 a7 : ffffffffffffffff
>> s2 : 0000000000000000 s3 : ffffffe000b9aca8 s4 : ffffffe081d52000
>> s5 : 0000000000000048 s6 : 000000000000000c s7 : ffffffe08221be80
>> s8 : 0000000000000000 s9 : 00000000000b1688 s10: 0000000000099dc8
>> s11: 0000003fffe33fa2 t3 : eee4a3de5cb81700 t4 : 0000000000000002
>> t5 : 0000003fcc454ac8 t6 : ffffffe08221bac8
>> status: 0000000000000120 badaddr: 0000000000000000 cause: 000000000000000d
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-26 1:10 ` Kefeng Wang
@ 2020-11-26 10:02 ` John Ogness
2020-11-26 11:55 ` John Ogness
0 siblings, 1 reply; 21+ messages in thread
From: John Ogness @ 2020-11-26 10:02 UTC (permalink / raw)
To: Kefeng Wang, Atish Patra
Cc: Petr Mladek, linux-riscv, Albert Ou, Palmer Dabbelt, Paul Walmsley
+Petr
On 2020-11-26, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> On 2020/11/26 6:58, Atish Patra wrote:
>> On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>> Using printk directly and align the printing formats.
>>>
>> Why switch to printk ? IIRC, pr_* is preferred over printk for any new code.
>
> The stack output is strange, that is why I move to printk, and the old
> kernel looks good.
This is just a quick response to let you know I can reproduce the issue
and I am investigating.
@Petr: The proposed change and output difference is here [0].
John Ogness
[0] http://lists.infradead.org/pipermail/linux-riscv/2020-November/003320.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-26 10:02 ` John Ogness
@ 2020-11-26 11:55 ` John Ogness
2020-11-26 12:49 ` Kefeng Wang
0 siblings, 1 reply; 21+ messages in thread
From: John Ogness @ 2020-11-26 11:55 UTC (permalink / raw)
To: Kefeng Wang, Atish Patra
Cc: Petr Mladek, linux-riscv, Albert Ou, Palmer Dabbelt, Paul Walmsley
On 2020-11-26, John Ogness <john.ogness@linutronix.de> wrote:
> On 2020-11-26, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> On 2020/11/26 6:58, Atish Patra wrote:
>>> On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>> Using printk directly and align the printing formats.
>>>>
>>> Why switch to printk ? IIRC, pr_* is preferred over printk for any new code.
>>
>> The stack output is strange, that is why I move to printk, and the old
>> kernel looks good.
>
> This is just a quick response to let you know I can reproduce the issue
> and I am investigating.
>
> @Petr: The proposed change and output difference is here [0].
This is a bug in continuous line handling. I have posted [0] a fix to
LKML.
Note that a pr_cont() message with a trailing newline will "terminate"
the continous line so that it can no longer be continued. Having a bunch
of:
pr_cont("...\n");
lines is technically wrong. If you really want the full block to be a
single message, put the newline at the beginning of the pr_cont()
message or add some whitespace after a newline at the end. For example:
pr_cont("\n....");
or
pr_cont("...\n ");
Although I would suggest making them separate printk calls. With
CONFIG_PRINTK_CALLER it is still possible to sort out simultaneous dumps
from multiple CPUs.
Thank you for reporting this!
John Ogness
[0] https://lkml.kernel.org/r/20201126114836.14750-1-john.ogness@linutronix.de
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] riscv: Fix __show_regs printing formats
2020-11-26 11:55 ` John Ogness
@ 2020-11-26 12:49 ` Kefeng Wang
0 siblings, 0 replies; 21+ messages in thread
From: Kefeng Wang @ 2020-11-26 12:49 UTC (permalink / raw)
To: John Ogness, Atish Patra
Cc: Petr Mladek, linux-riscv, Albert Ou, Palmer Dabbelt, Paul Walmsley
On 2020/11/26 19:55, John Ogness wrote:
> On 2020-11-26, John Ogness <john.ogness@linutronix.de> wrote:
>> On 2020-11-26, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>> On 2020/11/26 6:58, Atish Patra wrote:
>>>> On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>>> Using printk directly and align the printing formats.
>>>>>
>>>> Why switch to printk ? IIRC, pr_* is preferred over printk for any new code.
>>> The stack output is strange, that is why I move to printk, and the old
>>> kernel looks good.
>> This is just a quick response to let you know I can reproduce the issue
>> and I am investigating.
>>
>> @Petr: The proposed change and output difference is here [0].
> This is a bug in continuous line handling. I have posted [0] a fix to
> LKML.
Yes, it fixes the output issue.
>
> Note that a pr_cont() message with a trailing newline will "terminate"
> the continous line so that it can no longer be continued. Having a bunch
> of:
>
> pr_cont("...\n");
>
> lines is technically wrong. If you really want the full block to be a
> single message, put the newline at the beginning of the pr_cont()
> message or add some whitespace after a newline at the end. For example:
>
> pr_cont("\n....");
> or
> pr_cont("...\n ");
>
> Although I would suggest making them separate printk calls. With
> CONFIG_PRINTK_CALLER it is still possible to sort out simultaneous dumps
> from multiple CPUs.
Thanks for your explanation. I will re-post patch with changelog refresh.
>
> Thank you for reporting this!
>
> John Ogness
>
> [0] https://lkml.kernel.org/r/20201126114836.14750-1-john.ogness@linutronix.de
> .
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2] riscv: Using printk directly in __show_regs
2020-11-24 11:20 ` [PATCH 2/2] riscv: Fix __show_regs printing formats Kefeng Wang
2020-11-25 22:58 ` Atish Patra
@ 2020-11-26 13:33 ` Kefeng Wang
2020-12-11 1:43 ` Palmer Dabbelt
1 sibling, 1 reply; 21+ messages in thread
From: Kefeng Wang @ 2020-11-26 13:33 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv, Palmer Dabbelt
Cc: Kefeng Wang, John Ogness
Covert bulk of pr_cont("...\n") to separate printk calls.
Note that a pr_cont() message with a trailing newline will
"terminate" the continous line so that it can no longer be
continued, also it is possible to sort out simultaneous dumps
from multiple CPUs with CONFIG_PRINTK_CALLER enabled.
And align the printing formats.
Suggested-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
arch/riscv/kernel/process.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index e41b733abeaa..2119d49feea5 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
{
show_regs_print_info(KERN_DEFAULT);
- pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
+ printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
regs->epc, regs->ra, regs->sp);
- pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
+ printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
regs->gp, regs->tp, regs->t0);
- pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
+ printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
regs->t1, regs->t2, regs->s0);
- pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
+ printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
regs->s1, regs->a0, regs->a1);
- pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
+ printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
regs->a2, regs->a3, regs->a4);
- pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
+ printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
regs->a5, regs->a6, regs->a7);
- pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
+ printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
regs->s2, regs->s3, regs->s4);
- pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
+ printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
regs->s5, regs->s6, regs->s7);
- pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
+ printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
regs->s8, regs->s9, regs->s10);
- pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
+ printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
regs->s11, regs->t3, regs->t4);
- pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
+ printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
regs->t5, regs->t6);
- pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
+ printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
regs->status, regs->badaddr, regs->cause);
}
void show_regs(struct pt_regs *regs)
--
2.26.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v2] riscv: Using printk directly in __show_regs
2020-11-26 13:33 ` [PATCH v2] riscv: Using printk directly in __show_regs Kefeng Wang
@ 2020-12-11 1:43 ` Palmer Dabbelt
2020-12-11 8:48 ` John Ogness
0 siblings, 1 reply; 21+ messages in thread
From: Palmer Dabbelt @ 2020-12-11 1:43 UTC (permalink / raw)
To: wangkefeng.wang
Cc: linux-riscv, aou, wangkefeng.wang, john.ogness, Paul Walmsley
On Thu, 26 Nov 2020 05:33:38 PST (-0800), wangkefeng.wang@huawei.com wrote:
> Covert bulk of pr_cont("...\n") to separate printk calls.
>
> Note that a pr_cont() message with a trailing newline will
> "terminate" the continous line so that it can no longer be
> continued, also it is possible to sort out simultaneous dumps
> from multiple CPUs with CONFIG_PRINTK_CALLER enabled.
>
> And align the printing formats.
>
> Suggested-by: John Ogness <john.ogness@linutronix.de>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> arch/riscv/kernel/process.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index e41b733abeaa..2119d49feea5 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
> {
> show_regs_print_info(KERN_DEFAULT);
>
> - pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
> + printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
> regs->epc, regs->ra, regs->sp);
> - pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
> + printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
> regs->gp, regs->tp, regs->t0);
> - pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
> + printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
> regs->t1, regs->t2, regs->s0);
> - pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
> + printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
> regs->s1, regs->a0, regs->a1);
> - pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
> + printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
> regs->a2, regs->a3, regs->a4);
> - pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
> + printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
> regs->a5, regs->a6, regs->a7);
> - pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
> + printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
> regs->s2, regs->s3, regs->s4);
> - pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
> + printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
> regs->s5, regs->s6, regs->s7);
> - pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
> + printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
> regs->s8, regs->s9, regs->s10);
> - pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
> + printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
> regs->s11, regs->t3, regs->t4);
> - pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
> + printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
> regs->t5, regs->t6);
>
> - pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> + printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> regs->status, regs->badaddr, regs->cause);
> }
> void show_regs(struct pt_regs *regs)
For some reason I remember having these as printk()s originally, but I don't
see that in the git history so maybe it was from before we merged the port? I
don't really understand the difference here, and I thought using printk()
directly wasn't recommended?
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2] riscv: Using printk directly in __show_regs
2020-12-11 1:43 ` Palmer Dabbelt
@ 2020-12-11 8:48 ` John Ogness
2020-12-14 11:49 ` Kefeng Wang
0 siblings, 1 reply; 21+ messages in thread
From: John Ogness @ 2020-12-11 8:48 UTC (permalink / raw)
To: Palmer Dabbelt, wangkefeng.wang
Cc: linux-riscv, aou, wangkefeng.wang, Paul Walmsley
On 2020-12-10, Palmer Dabbelt <palmerdabbelt@google.com> wrote:
> On Thu, 26 Nov 2020 05:33:38 PST (-0800), wangkefeng.wang@huawei.com wrote:
>> Covert bulk of pr_cont("...\n") to separate printk calls.
>>
>> Note that a pr_cont() message with a trailing newline will
>> "terminate" the continous line so that it can no longer be
>> continued, also it is possible to sort out simultaneous dumps
>> from multiple CPUs with CONFIG_PRINTK_CALLER enabled.
>>
>> And align the printing formats.
>>
>> Suggested-by: John Ogness <john.ogness@linutronix.de>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> arch/riscv/kernel/process.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
>> index e41b733abeaa..2119d49feea5 100644
>> --- a/arch/riscv/kernel/process.c
>> +++ b/arch/riscv/kernel/process.c
>> @@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
>> {
>> show_regs_print_info(KERN_DEFAULT);
>>
>> - pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
>> + printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
>> regs->epc, regs->ra, regs->sp);
>> - pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
>> + printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
>> regs->gp, regs->tp, regs->t0);
>> - pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
>> + printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
>> regs->t1, regs->t2, regs->s0);
>> - pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
>> + printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
>> regs->s1, regs->a0, regs->a1);
>> - pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
>> + printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
>> regs->a2, regs->a3, regs->a4);
>> - pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
>> + printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
>> regs->a5, regs->a6, regs->a7);
>> - pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
>> + printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
>> regs->s2, regs->s3, regs->s4);
>> - pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
>> + printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
>> regs->s5, regs->s6, regs->s7);
>> - pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
>> + printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
>> regs->s8, regs->s9, regs->s10);
>> - pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
>> + printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
>> regs->s11, regs->t3, regs->t4);
>> - pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
>> + printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
>> regs->t5, regs->t6);
>>
>> - pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
>> + printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
>> regs->status, regs->badaddr, regs->cause);
>> }
>> void show_regs(struct pt_regs *regs)
>
> For some reason I remember having these as printk()s originally, but I
> don't see that in the git history so maybe it was from before we
> merged the port? I don't really understand the difference here, and I
> thought using printk() directly wasn't recommended?
There no difference between:
pr_cont("...\n");
and
printk("...\n");
except for the very first call, which will try to continue from whatever
was printed before. (But even that only makes a difference if the
previous call did not have a newline at the end.)
Note that the printk() being used does not specify the loglevel. Perhaps
it is intentional that the default loglevel (which can be specified by
the user) is used? Otherwise, if a particular loglevel _is_ desired,
then the appropriate pr_info/pr_warn/... should be used.
Also, this patch is also sneaking in some formatting changes. Previously
the columns were not aligned correctly. That spacing is also fixed
here. The spacing change _is_ a real improvement.
John Ogness
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2] riscv: Using printk directly in __show_regs
2020-12-11 8:48 ` John Ogness
@ 2020-12-14 11:49 ` Kefeng Wang
0 siblings, 0 replies; 21+ messages in thread
From: Kefeng Wang @ 2020-12-14 11:49 UTC (permalink / raw)
To: John Ogness, Palmer Dabbelt; +Cc: linux-riscv, aou, Paul Walmsley
On 2020/12/11 16:48, John Ogness wrote:
> On 2020-12-10, Palmer Dabbelt <palmerdabbelt@google.com> wrote:
>> On Thu, 26 Nov 2020 05:33:38 PST (-0800), wangkefeng.wang@huawei.com wrote:
>>> Covert bulk of pr_cont("...\n") to separate printk calls.
>>>
>>> Note that a pr_cont() message with a trailing newline will
>>> "terminate" the continous line so that it can no longer be
>>> continued, also it is possible to sort out simultaneous dumps
>>> from multiple CPUs with CONFIG_PRINTK_CALLER enabled.
>>>
>>> And align the printing formats.
>>>
>>> Suggested-by: John Ogness <john.ogness@linutronix.de>
>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>> ---
>>> arch/riscv/kernel/process.c | 24 ++++++++++++------------
>>> 1 file changed, 12 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
>>> index e41b733abeaa..2119d49feea5 100644
>>> --- a/arch/riscv/kernel/process.c
>>> +++ b/arch/riscv/kernel/process.c
>>> @@ -44,30 +44,30 @@ void __show_regs(struct pt_regs *regs)
>>> {
>>> show_regs_print_info(KERN_DEFAULT);
>>>
>>> - pr_cont("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
>>> + printk("epc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
>>> regs->epc, regs->ra, regs->sp);
>>> - pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
>>> + printk("gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
>>> regs->gp, regs->tp, regs->t0);
>>> - pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
>>> + printk("t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
>>> regs->t1, regs->t2, regs->s0);
>>> - pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
>>> + printk("s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
>>> regs->s1, regs->a0, regs->a1);
>>> - pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
>>> + printk("a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
>>> regs->a2, regs->a3, regs->a4);
>>> - pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
>>> + printk("a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
>>> regs->a5, regs->a6, regs->a7);
>>> - pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
>>> + printk("s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
>>> regs->s2, regs->s3, regs->s4);
>>> - pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
>>> + printk("s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
>>> regs->s5, regs->s6, regs->s7);
>>> - pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
>>> + printk("s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
>>> regs->s8, regs->s9, regs->s10);
>>> - pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
>>> + printk("s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
>>> regs->s11, regs->t3, regs->t4);
>>> - pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
>>> + printk("t5 : " REG_FMT " t6 : " REG_FMT "\n",
>>> regs->t5, regs->t6);
>>>
>>> - pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
>>> + printk("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
>>> regs->status, regs->badaddr, regs->cause);
>>> }
>>> void show_regs(struct pt_regs *regs)
>> For some reason I remember having these as printk()s originally, but I
>> don't see that in the git history so maybe it was from before we
>> merged the port? I don't really understand the difference here, and I
>> thought using printk() directly wasn't recommended?
The original reason which I changed to printk is the strange out-print,
see v1 patch [1],
but it's found that there is a regression in v5.10 printk rework, and
being fixed by commit
4ad9921af4f1 ("printk: finalize records with trailing newlines").
The v2 patch major change is align the printing (not a big change) and
in case of rearrangement of
print when CONFIG_PRINTK_CALLER enabled
[1]
https://patchwork.kernel.org/project/linux-riscv/patch/20201124112054.106960-2-wangkefeng.wang@huawei.com/
> There no difference between:
>
> pr_cont("...\n");
> and
> printk("...\n");
>
> except for the very first call, which will try to continue from whatever
> was printed before. (But even that only makes a difference if the
> previous call did not have a newline at the end.)
>
> Note that the printk() being used does not specify the loglevel. Perhaps
> it is intentional that the default loglevel (which can be specified by
> the user) is used? Otherwise, if a particular loglevel _is_ desired,
> then the appropriate pr_info/pr_warn/... should be used.
>
> Also, this patch is also sneaking in some formatting changes. Previously
> the columns were not aligned correctly. That spacing is also fixed
> here. The spacing change _is_ a real improvement.
>
> John Ogness
> .
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] riscv: Add dump stack in show_regs
2020-11-24 11:20 ` [PATCH 1/2] riscv: Add dump stack in show_regs Kefeng Wang
2020-11-24 11:20 ` [PATCH 2/2] riscv: Fix __show_regs printing formats Kefeng Wang
@ 2020-11-25 23:04 ` Atish Patra
2020-12-14 11:52 ` Kefeng Wang
2 siblings, 0 replies; 21+ messages in thread
From: Atish Patra @ 2020-11-25 23:04 UTC (permalink / raw)
To: Kefeng Wang; +Cc: linux-riscv, Albert Ou, Palmer Dabbelt, Paul Walmsley
On Tue, Nov 24, 2020 at 3:17 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Like commit 1149aad10b1e ("arm64: Add dump_backtrace() in show_regs"),
> dump the stack in riscv show_regs as common code expects.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> NOTE: The patches based on
> https://patchwork.kernel.org/project/linux-riscv/list/?series=383349
>
> arch/riscv/include/asm/bug.h | 1 +
> arch/riscv/include/asm/stacktrace.h | 2 ++
> arch/riscv/kernel/process.c | 9 ++++++++-
> arch/riscv/kernel/stacktrace.c | 10 ++++++++--
> arch/riscv/kernel/traps.c | 3 ++-
> 5 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> index d6f1ec08d97b..d3804a2f9aad 100644
> --- a/arch/riscv/include/asm/bug.h
> +++ b/arch/riscv/include/asm/bug.h
> @@ -85,6 +85,7 @@ do { \
> struct pt_regs;
> struct task_struct;
>
> +void __show_regs(struct pt_regs *regs);
> void die(struct pt_regs *regs, const char *str);
> void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
>
> diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h
> index 470a65c4ccdc..3450c1912afd 100644
> --- a/arch/riscv/include/asm/stacktrace.h
> +++ b/arch/riscv/include/asm/stacktrace.h
> @@ -13,5 +13,7 @@ struct stackframe {
>
> extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
> bool (*fn)(void *, unsigned long), void *arg);
> +extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
> + const char *loglvl);
>
> #endif /* _ASM_RISCV_STACKTRACE_H */
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index 19225ec65db6..e41b733abeaa 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -18,6 +18,7 @@
> #include <asm/unistd.h>
> #include <asm/processor.h>
> #include <asm/csr.h>
> +#include <asm/stacktrace.h>
> #include <asm/string.h>
> #include <asm/switch_to.h>
> #include <asm/thread_info.h>
> @@ -39,7 +40,7 @@ void arch_cpu_idle(void)
> local_irq_enable();
> }
>
> -void show_regs(struct pt_regs *regs)
> +void __show_regs(struct pt_regs *regs)
> {
> show_regs_print_info(KERN_DEFAULT);
>
> @@ -69,6 +70,12 @@ void show_regs(struct pt_regs *regs)
> pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> regs->status, regs->badaddr, regs->cause);
> }
> +void show_regs(struct pt_regs *regs)
> +{
> + __show_regs(regs);
> + if (!user_mode(regs))
> + dump_backtrace(regs, NULL, KERN_DEFAULT);
> +}
>
> void start_thread(struct pt_regs *regs, unsigned long pc,
> unsigned long sp)
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 48b870a685b3..76dadf6d396b 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -101,10 +101,16 @@ static bool print_trace_address(void *arg, unsigned long pc)
> return true;
> }
>
> +void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
> + const char *loglvl)
> +{
> + pr_cont("%sCall Trace:\n", loglvl);
> + walk_stackframe(task, regs, print_trace_address, (void *)loglvl);
> +}
> +
> void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
> {
> - pr_cont("Call Trace:\n");
> - walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
> + dump_backtrace(NULL, task, loglvl);
> }
>
> static bool save_wchan(void *arg, unsigned long pc)
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index ad14f4466d92..570eb078b1e1 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -16,6 +16,7 @@
> #include <linux/module.h>
> #include <linux/irq.h>
>
> +#include <asm/bug.h>
> #include <asm/processor.h>
> #include <asm/ptrace.h>
> #include <asm/csr.h>
> @@ -66,7 +67,7 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
> tsk->comm, task_pid_nr(tsk), signo, code, addr);
> print_vma_addr(KERN_CONT " in ", instruction_pointer(regs));
> pr_cont("\n");
> - show_regs(regs);
> + __show_regs(regs);
> }
>
> force_sig_fault(signo, code, (void __user *)addr);
> --
> 2.26.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
LGTM.
Reviewed-by: Atish Patra <atish.patra@wdc.com>
--
Regards,
Atish
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] riscv: Add dump stack in show_regs
2020-11-24 11:20 ` [PATCH 1/2] riscv: Add dump stack in show_regs Kefeng Wang
2020-11-24 11:20 ` [PATCH 2/2] riscv: Fix __show_regs printing formats Kefeng Wang
2020-11-25 23:04 ` [PATCH 1/2] riscv: Add dump stack in show_regs Atish Patra
@ 2020-12-14 11:52 ` Kefeng Wang
2021-01-09 22:24 ` Palmer Dabbelt
2 siblings, 1 reply; 21+ messages in thread
From: Kefeng Wang @ 2020-12-14 11:52 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv, Palmer Dabbelt
hi Palmer, kindly ping...
On 2020/11/24 19:20, Kefeng Wang wrote:
> Like commit 1149aad10b1e ("arm64: Add dump_backtrace() in show_regs"),
> dump the stack in riscv show_regs as common code expects.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> NOTE: The patches based on
> https://patchwork.kernel.org/project/linux-riscv/list/?series=383349
>
> arch/riscv/include/asm/bug.h | 1 +
> arch/riscv/include/asm/stacktrace.h | 2 ++
> arch/riscv/kernel/process.c | 9 ++++++++-
> arch/riscv/kernel/stacktrace.c | 10 ++++++++--
> arch/riscv/kernel/traps.c | 3 ++-
> 5 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> index d6f1ec08d97b..d3804a2f9aad 100644
> --- a/arch/riscv/include/asm/bug.h
> +++ b/arch/riscv/include/asm/bug.h
> @@ -85,6 +85,7 @@ do { \
> struct pt_regs;
> struct task_struct;
>
> +void __show_regs(struct pt_regs *regs);
> void die(struct pt_regs *regs, const char *str);
> void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
>
> diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h
> index 470a65c4ccdc..3450c1912afd 100644
> --- a/arch/riscv/include/asm/stacktrace.h
> +++ b/arch/riscv/include/asm/stacktrace.h
> @@ -13,5 +13,7 @@ struct stackframe {
>
> extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
> bool (*fn)(void *, unsigned long), void *arg);
> +extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
> + const char *loglvl);
>
> #endif /* _ASM_RISCV_STACKTRACE_H */
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index 19225ec65db6..e41b733abeaa 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -18,6 +18,7 @@
> #include <asm/unistd.h>
> #include <asm/processor.h>
> #include <asm/csr.h>
> +#include <asm/stacktrace.h>
> #include <asm/string.h>
> #include <asm/switch_to.h>
> #include <asm/thread_info.h>
> @@ -39,7 +40,7 @@ void arch_cpu_idle(void)
> local_irq_enable();
> }
>
> -void show_regs(struct pt_regs *regs)
> +void __show_regs(struct pt_regs *regs)
> {
> show_regs_print_info(KERN_DEFAULT);
>
> @@ -69,6 +70,12 @@ void show_regs(struct pt_regs *regs)
> pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
> regs->status, regs->badaddr, regs->cause);
> }
> +void show_regs(struct pt_regs *regs)
> +{
> + __show_regs(regs);
> + if (!user_mode(regs))
> + dump_backtrace(regs, NULL, KERN_DEFAULT);
> +}
>
> void start_thread(struct pt_regs *regs, unsigned long pc,
> unsigned long sp)
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 48b870a685b3..76dadf6d396b 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -101,10 +101,16 @@ static bool print_trace_address(void *arg, unsigned long pc)
> return true;
> }
>
> +void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
> + const char *loglvl)
> +{
> + pr_cont("%sCall Trace:\n", loglvl);
> + walk_stackframe(task, regs, print_trace_address, (void *)loglvl);
> +}
> +
> void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
> {
> - pr_cont("Call Trace:\n");
> - walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
> + dump_backtrace(NULL, task, loglvl);
> }
>
> static bool save_wchan(void *arg, unsigned long pc)
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index ad14f4466d92..570eb078b1e1 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -16,6 +16,7 @@
> #include <linux/module.h>
> #include <linux/irq.h>
>
> +#include <asm/bug.h>
> #include <asm/processor.h>
> #include <asm/ptrace.h>
> #include <asm/csr.h>
> @@ -66,7 +67,7 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
> tsk->comm, task_pid_nr(tsk), signo, code, addr);
> print_vma_addr(KERN_CONT " in ", instruction_pointer(regs));
> pr_cont("\n");
> - show_regs(regs);
> + __show_regs(regs);
> }
>
> force_sig_fault(signo, code, (void __user *)addr);
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] riscv: Add dump stack in show_regs
2020-12-14 11:52 ` Kefeng Wang
@ 2021-01-09 22:24 ` Palmer Dabbelt
2021-01-11 3:23 ` Kefeng Wang
0 siblings, 1 reply; 21+ messages in thread
From: Palmer Dabbelt @ 2021-01-09 22:24 UTC (permalink / raw)
To: wangkefeng.wang; +Cc: linux-riscv, aou, Paul Walmsley
On Mon, 14 Dec 2020 03:52:19 PST (-0800), wangkefeng.wang@huawei.com wrote:
> hi Palmer, kindly ping...
Sorry, it looks like I missed this because it's all threaded together. I'm not
really sure what you're trying to do here: you've got three patch sets in one
thread, one of which seems to be a v2 of only a single patch.
Do you mind sending out a standalone version of this?
>
> On 2020/11/24 19:20, Kefeng Wang wrote:
>> Like commit 1149aad10b1e ("arm64: Add dump_backtrace() in show_regs"),
>> dump the stack in riscv show_regs as common code expects.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> NOTE: The patches based on
>> https://patchwork.kernel.org/project/linux-riscv/list/?series=383349
>>
>> arch/riscv/include/asm/bug.h | 1 +
>> arch/riscv/include/asm/stacktrace.h | 2 ++
>> arch/riscv/kernel/process.c | 9 ++++++++-
>> arch/riscv/kernel/stacktrace.c | 10 ++++++++--
>> arch/riscv/kernel/traps.c | 3 ++-
>> 5 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
>> index d6f1ec08d97b..d3804a2f9aad 100644
>> --- a/arch/riscv/include/asm/bug.h
>> +++ b/arch/riscv/include/asm/bug.h
>> @@ -85,6 +85,7 @@ do { \
>> struct pt_regs;
>> struct task_struct;
>>
>> +void __show_regs(struct pt_regs *regs);
>> void die(struct pt_regs *regs, const char *str);
>> void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
>>
>> diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h
>> index 470a65c4ccdc..3450c1912afd 100644
>> --- a/arch/riscv/include/asm/stacktrace.h
>> +++ b/arch/riscv/include/asm/stacktrace.h
>> @@ -13,5 +13,7 @@ struct stackframe {
>>
>> extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>> bool (*fn)(void *, unsigned long), void *arg);
>> +extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
>> + const char *loglvl);
>>
>> #endif /* _ASM_RISCV_STACKTRACE_H */
>> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
>> index 19225ec65db6..e41b733abeaa 100644
>> --- a/arch/riscv/kernel/process.c
>> +++ b/arch/riscv/kernel/process.c
>> @@ -18,6 +18,7 @@
>> #include <asm/unistd.h>
>> #include <asm/processor.h>
>> #include <asm/csr.h>
>> +#include <asm/stacktrace.h>
>> #include <asm/string.h>
>> #include <asm/switch_to.h>
>> #include <asm/thread_info.h>
>> @@ -39,7 +40,7 @@ void arch_cpu_idle(void)
>> local_irq_enable();
>> }
>>
>> -void show_regs(struct pt_regs *regs)
>> +void __show_regs(struct pt_regs *regs)
>> {
>> show_regs_print_info(KERN_DEFAULT);
>>
>> @@ -69,6 +70,12 @@ void show_regs(struct pt_regs *regs)
>> pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
>> regs->status, regs->badaddr, regs->cause);
>> }
>> +void show_regs(struct pt_regs *regs)
>> +{
>> + __show_regs(regs);
>> + if (!user_mode(regs))
>> + dump_backtrace(regs, NULL, KERN_DEFAULT);
>> +}
>>
>> void start_thread(struct pt_regs *regs, unsigned long pc,
>> unsigned long sp)
>> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
>> index 48b870a685b3..76dadf6d396b 100644
>> --- a/arch/riscv/kernel/stacktrace.c
>> +++ b/arch/riscv/kernel/stacktrace.c
>> @@ -101,10 +101,16 @@ static bool print_trace_address(void *arg, unsigned long pc)
>> return true;
>> }
>>
>> +void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
>> + const char *loglvl)
>> +{
>> + pr_cont("%sCall Trace:\n", loglvl);
>> + walk_stackframe(task, regs, print_trace_address, (void *)loglvl);
>> +}
>> +
>> void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
>> {
>> - pr_cont("Call Trace:\n");
>> - walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
>> + dump_backtrace(NULL, task, loglvl);
>> }
>>
>> static bool save_wchan(void *arg, unsigned long pc)
>> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>> index ad14f4466d92..570eb078b1e1 100644
>> --- a/arch/riscv/kernel/traps.c
>> +++ b/arch/riscv/kernel/traps.c
>> @@ -16,6 +16,7 @@
>> #include <linux/module.h>
>> #include <linux/irq.h>
>>
>> +#include <asm/bug.h>
>> #include <asm/processor.h>
>> #include <asm/ptrace.h>
>> #include <asm/csr.h>
>> @@ -66,7 +67,7 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
>> tsk->comm, task_pid_nr(tsk), signo, code, addr);
>> print_vma_addr(KERN_CONT " in ", instruction_pointer(regs));
>> pr_cont("\n");
>> - show_regs(regs);
>> + __show_regs(regs);
>> }
>>
>> force_sig_fault(signo, code, (void __user *)addr);
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] riscv: Add dump stack in show_regs
2021-01-09 22:24 ` Palmer Dabbelt
@ 2021-01-11 3:23 ` Kefeng Wang
0 siblings, 0 replies; 21+ messages in thread
From: Kefeng Wang @ 2021-01-11 3:23 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: linux-riscv, aou, Paul Walmsley
On 2021/1/10 6:24, Palmer Dabbelt wrote:
> On Mon, 14 Dec 2020 03:52:19 PST (-0800), wangkefeng.wang@huawei.com
> wrote:
>> hi Palmer, kindly ping...
>
> Sorry, it looks like I missed this because it's all threaded
> together. I'm not
> really sure what you're trying to do here: you've got three patch sets
> in one
> thread, one of which seems to be a v2 of only a single patch.
> Do you mind sending out a standalone version of this?
Sure, I will rebase on the top of 5.11-rc3 and resend them.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 21+ messages in thread