Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer
@ 2019-12-23  8:46 Zong Li
  2019-12-23  8:46 ` [PATCH 1/2] riscv: ftrace: correct the condition logic in function " Zong Li
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Zong Li @ 2019-12-23  8:46 UTC (permalink / raw)
  To: paul.walmsley, palmer, rostedt, anup, linux-kernel, linux-riscv; +Cc: Zong Li

Ftrace graph tracer is broken now, these patches fix the problem of ftrace graph
tracer and tested on QEMU and HiFive Unleashed board.

Zong Li (2):
  riscv: ftrace: correct the condition logic in function graph tracer
  clocksource/drivers/riscv: add notrace to riscv_sched_clock

 arch/riscv/kernel/ftrace.c        | 2 +-
 drivers/clocksource/timer-riscv.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.24.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] riscv: ftrace: correct the condition logic in function graph tracer
  2019-12-23  8:46 [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
@ 2019-12-23  8:46 ` " Zong Li
  2020-01-04  0:14   ` Paul Walmsley
  2019-12-23  8:46 ` [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock Zong Li
  2020-01-02  3:50 ` [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
  2 siblings, 1 reply; 7+ messages in thread
From: Zong Li @ 2019-12-23  8:46 UTC (permalink / raw)
  To: paul.walmsley, palmer, rostedt, anup, linux-kernel, linux-riscv; +Cc: Zong Li

The condition should be logical NOT to assign the hook address to parent
address. Because the return value 0 of function_graph_enter upon
success.

Fixes: e949b6db51dc (riscv/function_graph: Simplify with function_graph_enter())

Signed-off-by: Zong Li <zong.li@sifive.com>
---
 arch/riscv/kernel/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index b94d8db5ddcc..c40fdcdeb950 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -142,7 +142,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 	 */
 	old = *parent;
 
-	if (function_graph_enter(old, self_addr, frame_pointer, parent))
+	if (!function_graph_enter(old, self_addr, frame_pointer, parent))
 		*parent = return_hooker;
 }
 
-- 
2.24.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock
  2019-12-23  8:46 [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
  2019-12-23  8:46 ` [PATCH 1/2] riscv: ftrace: correct the condition logic in function " Zong Li
@ 2019-12-23  8:46 ` Zong Li
  2020-01-04  0:16   ` Paul Walmsley
  2020-01-02  3:50 ` [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
  2 siblings, 1 reply; 7+ messages in thread
From: Zong Li @ 2019-12-23  8:46 UTC (permalink / raw)
  To: paul.walmsley, palmer, rostedt, anup, linux-kernel, linux-riscv; +Cc: Zong Li

When enabling ftrace graph tracer, it gets the tracing clock in
ftrace_push_return_trace. Eventually, it invokes the riscv_sched_clock to
get the clock. If add mcount instrument in riscv_sched_clock, it will
call ftrace_push_return_trace and cause infinite loop.

The result of failure as follow:

command: echo function_graph >current_tracer
[   46.176787] Unable to handle kernel paging request at virtual address ffffffe04fb38c48
[   46.177309] Oops [#1]
[   46.177478] Modules linked in:
[   46.177770] CPU: 0 PID: 256 Comm: $d Not tainted 5.5.0-rc1 #47
[   46.177981] epc: ffffffe00035e59a ra : ffffffe00035e57e sp : ffffffe03a7569b0
[   46.178216]  gp : ffffffe000d29b90 tp : ffffffe03a756180 t0 : ffffffe03a756968
[   46.178430]  t1 : ffffffe00087f408 t2 : ffffffe03a7569a0 s0 : ffffffe03a7569f0
[   46.178643]  s1 : ffffffe00087f408 a0 : 0000000ac054cda4 a1 : 000000000087f411
[   46.178856]  a2 : 0000000ac054cda4 a3 : 0000000000373ca0 a4 : ffffffe04fb38c48
[   46.179099]  a5 : 00000000153e22a8 a6 : 00000000005522ff a7 : 0000000000000005
[   46.179338]  s2 : ffffffe03a756a90 s3 : ffffffe00032811c s4 : ffffffe03a756a58
[   46.179570]  s5 : ffffffe000d29fe0 s6 : 0000000000000001 s7 : 0000000000000003
[   46.179809]  s8 : 0000000000000003 s9 : 0000000000000002 s10: 0000000000000004
[   46.180053]  s11: 0000000000000000 t3 : 0000003fc815749c t4 : 00000000000efc90
[   46.180293]  t5 : ffffffe000d29658 t6 : 0000000000040000
[   46.180482] status: 0000000000000100 badaddr: ffffffe04fb38c48 cause: 000000000000000f

Signed-off-by: Zong Li <zong.li@sifive.com>
---
 drivers/clocksource/timer-riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index 4e54856ce2a5..c4f15c4068c0 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -56,7 +56,7 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs)
 	return get_cycles64();
 }
 
-static u64 riscv_sched_clock(void)
+static u64 notrace riscv_sched_clock(void)
 {
 	return get_cycles64();
 }
-- 
2.24.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer
  2019-12-23  8:46 [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
  2019-12-23  8:46 ` [PATCH 1/2] riscv: ftrace: correct the condition logic in function " Zong Li
  2019-12-23  8:46 ` [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock Zong Li
@ 2020-01-02  3:50 ` Zong Li
  2020-01-02 15:14   ` Steven Rostedt
  2 siblings, 1 reply; 7+ messages in thread
From: Zong Li @ 2020-01-02  3:50 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, rostedt, Anup Patel,
	linux-kernel@vger.kernel.org List, linux-riscv

On Mon, Dec 23, 2019 at 4:46 PM Zong Li <zong.li@sifive.com> wrote:
>
> Ftrace graph tracer is broken now, these patches fix the problem of ftrace graph
> tracer and tested on QEMU and HiFive Unleashed board.
>
> Zong Li (2):
>   riscv: ftrace: correct the condition logic in function graph tracer
>   clocksource/drivers/riscv: add notrace to riscv_sched_clock
>
>  arch/riscv/kernel/ftrace.c        | 2 +-
>  drivers/clocksource/timer-riscv.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> --
> 2.24.1
>

ping


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer
  2020-01-02  3:50 ` [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
@ 2020-01-02 15:14   ` Steven Rostedt
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-01-02 15:14 UTC (permalink / raw)
  To: Zong Li
  Cc: Anup Patel, linux-riscv, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Paul Walmsley

On Thu, 2 Jan 2020 11:50:22 +0800
Zong Li <zong.li@sifive.com> wrote:

> On Mon, Dec 23, 2019 at 4:46 PM Zong Li <zong.li@sifive.com> wrote:
> >
> > Ftrace graph tracer is broken now, these patches fix the problem of ftrace graph
> > tracer and tested on QEMU and HiFive Unleashed board.
> >
> > Zong Li (2):
> >   riscv: ftrace: correct the condition logic in function graph tracer
> >   clocksource/drivers/riscv: add notrace to riscv_sched_clock
> >
> >  arch/riscv/kernel/ftrace.c        | 2 +-
> >  drivers/clocksource/timer-riscv.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > --
> > 2.24.1
> >  
> 
> ping

Both patches look legit.

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] riscv: ftrace: correct the condition logic in function graph tracer
  2019-12-23  8:46 ` [PATCH 1/2] riscv: ftrace: correct the condition logic in function " Zong Li
@ 2020-01-04  0:14   ` Paul Walmsley
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Walmsley @ 2020-01-04  0:14 UTC (permalink / raw)
  To: Zong Li; +Cc: anup, linux-riscv, palmer, linux-kernel, rostedt

On Mon, 23 Dec 2019, Zong Li wrote:

> The condition should be logical NOT to assign the hook address to parent
> address. Because the return value 0 of function_graph_enter upon
> success.
> 
> Fixes: e949b6db51dc (riscv/function_graph: Simplify with function_graph_enter())
> 

There shouldn't be a blank line here - I've removed it in the queued 
version.

> Signed-off-by: Zong Li <zong.li@sifive.com>

Thanks, queued for v5.5-rc.


- Paul


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock
  2019-12-23  8:46 ` [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock Zong Li
@ 2020-01-04  0:16   ` Paul Walmsley
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Walmsley @ 2020-01-04  0:16 UTC (permalink / raw)
  To: Zong Li; +Cc: anup, linux-riscv, palmer, linux-kernel, rostedt

On Mon, 23 Dec 2019, Zong Li wrote:

> When enabling ftrace graph tracer, it gets the tracing clock in
> ftrace_push_return_trace. Eventually, it invokes the riscv_sched_clock to
> get the clock. If add mcount instrument in riscv_sched_clock, it will
> call ftrace_push_return_trace and cause infinite loop.
> 
> The result of failure as follow:
> 
> command: echo function_graph >current_tracer
> [   46.176787] Unable to handle kernel paging request at virtual address ffffffe04fb38c48
> [   46.177309] Oops [#1]
> [   46.177478] Modules linked in:
> [   46.177770] CPU: 0 PID: 256 Comm: $d Not tainted 5.5.0-rc1 #47
> [   46.177981] epc: ffffffe00035e59a ra : ffffffe00035e57e sp : ffffffe03a7569b0
> [   46.178216]  gp : ffffffe000d29b90 tp : ffffffe03a756180 t0 : ffffffe03a756968
> [   46.178430]  t1 : ffffffe00087f408 t2 : ffffffe03a7569a0 s0 : ffffffe03a7569f0
> [   46.178643]  s1 : ffffffe00087f408 a0 : 0000000ac054cda4 a1 : 000000000087f411
> [   46.178856]  a2 : 0000000ac054cda4 a3 : 0000000000373ca0 a4 : ffffffe04fb38c48
> [   46.179099]  a5 : 00000000153e22a8 a6 : 00000000005522ff a7 : 0000000000000005
> [   46.179338]  s2 : ffffffe03a756a90 s3 : ffffffe00032811c s4 : ffffffe03a756a58
> [   46.179570]  s5 : ffffffe000d29fe0 s6 : 0000000000000001 s7 : 0000000000000003
> [   46.179809]  s8 : 0000000000000003 s9 : 0000000000000002 s10: 0000000000000004
> [   46.180053]  s11: 0000000000000000 t3 : 0000003fc815749c t4 : 00000000000efc90
> [   46.180293]  t5 : ffffffe000d29658 t6 : 0000000000040000
> [   46.180482] status: 0000000000000100 badaddr: ffffffe04fb38c48 cause: 000000000000000f
> 
> Signed-off-by: Zong Li <zong.li@sifive.com>

Thanks; below is what's been queued for v5.5-rc.


- Paul


From: Zong Li <zong.li@sifive.com>
Date: Mon, 23 Dec 2019 16:46:14 +0800
Subject: [PATCH 1/2] clocksource/drivers/riscv: add notrace to
 riscv_sched_clock

When enabling ftrace graph tracer, it gets the tracing clock in
ftrace_push_return_trace().  Eventually, it invokes riscv_sched_clock()
to get the clock value.  If riscv_sched_clock() isn't marked with
'notrace', it will call ftrace_push_return_trace() and cause infinite
loop.

The result of failure as follow:

command: echo function_graph >current_tracer
[   46.176787] Unable to handle kernel paging request at virtual address ffffffe04fb38c48
[   46.177309] Oops [#1]
[   46.177478] Modules linked in:
[   46.177770] CPU: 0 PID: 256 Comm: $d Not tainted 5.5.0-rc1 #47
[   46.177981] epc: ffffffe00035e59a ra : ffffffe00035e57e sp : ffffffe03a7569b0
[   46.178216]  gp : ffffffe000d29b90 tp : ffffffe03a756180 t0 : ffffffe03a756968
[   46.178430]  t1 : ffffffe00087f408 t2 : ffffffe03a7569a0 s0 : ffffffe03a7569f0
[   46.178643]  s1 : ffffffe00087f408 a0 : 0000000ac054cda4 a1 : 000000000087f411
[   46.178856]  a2 : 0000000ac054cda4 a3 : 0000000000373ca0 a4 : ffffffe04fb38c48
[   46.179099]  a5 : 00000000153e22a8 a6 : 00000000005522ff a7 : 0000000000000005
[   46.179338]  s2 : ffffffe03a756a90 s3 : ffffffe00032811c s4 : ffffffe03a756a58
[   46.179570]  s5 : ffffffe000d29fe0 s6 : 0000000000000001 s7 : 0000000000000003
[   46.179809]  s8 : 0000000000000003 s9 : 0000000000000002 s10: 0000000000000004
[   46.180053]  s11: 0000000000000000 t3 : 0000003fc815749c t4 : 00000000000efc90
[   46.180293]  t5 : ffffffe000d29658 t6 : 0000000000040000
[   46.180482] status: 0000000000000100 badaddr: ffffffe04fb38c48 cause: 000000000000000f

Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
[paul.walmsley@sifive.com: cleaned up patch description]
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
---
 drivers/clocksource/timer-riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index 4e54856ce2a5..c4f15c4068c0 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -56,7 +56,7 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs)
 	return get_cycles64();
 }
 
-static u64 riscv_sched_clock(void)
+static u64 notrace riscv_sched_clock(void)
 {
 	return get_cycles64();
 }
-- 
2.24.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23  8:46 [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
2019-12-23  8:46 ` [PATCH 1/2] riscv: ftrace: correct the condition logic in function " Zong Li
2020-01-04  0:14   ` Paul Walmsley
2019-12-23  8:46 ` [PATCH 2/2] clocksource/drivers/riscv: add notrace to riscv_sched_clock Zong Li
2020-01-04  0:16   ` Paul Walmsley
2020-01-02  3:50 ` [PATCH 0/2] RISC-V: fixes issues of ftrace graph tracer Zong Li
2020-01-02 15:14   ` Steven Rostedt

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git