Skip to contentSkip to conversation

Add dynamic ftrace support for RISC-V platforms

PATCH In review Alan Kao 2 participants 11 messages Feb 13, 2018 – Feb 24, 2018

Subsystems (2)
lore
Share & tools
lore

Alan Kao

author
#0 lore raw

v4 cover Add dynamic ftrace support for RISC-V platforms

This patch set includes the building blocks of dynamic ftrace features for RISC-V machines.

Changes in v4:
- Organize code structure according to changes in v3
- Rebase onto the riscv-linux-4.15 branch at github's riscv/riscv-linux repo. Note that this set is based on the previous ftrace patch, which provided basic support.

Changes in v3:
- Replace the nops at the tracer call sites into "call ftrace_stub" instructions for better understanding (1/6, 2/6 and 5/6)

Changes in v2:
- Fix the return value as writing to kernel text goes wrong (2/6)
- Replace manual comparisons by calling memcmp (2/6)
- Simplify the conditional assignment in the Makefile (1/6)

Alan Kao (6):
riscv/ftrace: Add RECORD_MCOUNT support riscv/ftrace: Add dynamic function tracer support riscv/ftrace: Add dynamic function graph tracer support riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

 arch/riscv/Kconfig              |   3 +
 arch/riscv/Makefile             |   3 +
 arch/riscv/include/asm/ftrace.h |  56 ++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 175 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  | 239 ++++++++++++++++++++++++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 ++--
 arch/riscv/kernel/stacktrace.c  |   6 +
 scripts/recordmcount.pl         |   5 +
 9 files changed, 501 insertions(+), 13 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S
Signature · 1 line
2.15.1
author
#1 lore raw

PATCH v4 1/6 riscv/ftrace: Add RECORD_MCOUNT support

Now recordmcount.pl recognizes RISC-V object files. For the mechanism to work, we have to disable the linker relaxation.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/Kconfig      | 1 +
 arch/riscv/Makefile     | 3 +++
 scripts/recordmcount.pl | 5 +++++
 3 files changed, 9 insertions(+)
arch/riscv/Kconfig +1 -0
index 9e1074fd5cca..570af19a54ea 100644
@@ -120,6 +120,7 @@ config ARCH_RV64I
 	select 64BIT
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_GRAPH_TRACER
+	select HAVE_FTRACE_MCOUNT_RECORD
 
 endchoice
 
arch/riscv/Makefile +3 -0
index 6719dd30ec5b..899226e0da7d 100644
@@ -11,6 +11,9 @@
 LDFLAGS         :=
 OBJCOPYFLAGS    := -O binary
 LDFLAGS_vmlinux :=
+ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+	LDFLAGS_vmlinux := --no-relax
+endif
 KBUILD_AFLAGS_MODULE += -fPIC
 KBUILD_CFLAGS_MODULE += -fPIC
 
scripts/recordmcount.pl +5 -0
index 2033af758173..d44d55db7c06 100755
@@ -376,6 +376,11 @@ if ($arch eq "x86_64") {
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$";
     $type = ".quad";
     $alignment = 8;
+} elsif ($arch eq "riscv") {
+    $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
+    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$";
+    $type = ".quad";
+    $alignment = 2;
 } else {
     die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
 }
Signature · 1 line
2.15.1
author
#2 lore raw

PATCH v4 2/6 riscv/ftrace: Add dynamic function tracer support

In reply to Alan Kao

We now have dynamic ftrace with the following added items:

* ftrace_make_call, ftrace_make_nop (in kernel/ftrace.c) The two functions turn each recorded call site of filtered functions into a call to ftrace_caller or nops

* ftracce_update_ftrace_func (in kernel/ftrace.c)
turns the nops at ftrace_call into a call to a generic entry for function tracers.

* ftrace_caller (in kernel/mcount-dyn.S)
The entry where each _mcount call sites calls to once they are filtered to be traced.

Also, this patch fixes the semantic problems in mcount.S, which will be treated as only a reference implementation once we have the dynamic ftrace.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/Kconfig              |   1 +
 arch/riscv/include/asm/ftrace.h |  54 +++++++++++++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 103 +++++++++++++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  |  50 +++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 +++++----
 6 files changed, 223 insertions(+), 12 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S
arch/riscv/Kconfig +1 -0
index 570af19a54ea..df05acbb53d3 100644
@@ -121,6 +121,7 @@ config ARCH_RV64I
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
+	select HAVE_DYNAMIC_FTRACE
 
 endchoice
 
arch/riscv/include/asm/ftrace.h +54 -0

57 lines not on this page · raw message

arch/riscv/kernel/Makefile +3 -2
index 196f62ffc428..d7bdf888f1ca 100644
@@ -34,7 +34,8 @@ CFLAGS_setup.o := -mcmodel=medany
 obj-$(CONFIG_SMP)		+= smpboot.o
 obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_MODULES)		+= module.o
-obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o
-obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
+
+obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o ftrace.o
+obj-$(CONFIG_DYNAMIC_FTRACE)	+= mcount-dyn.o
 
 clean:
arch/riscv/kernel/ftrace.c +102 -1

114 lines not on this page · raw message

arch/riscv/kernel/mcount-dyn.S new file +50 -0

50 lines not on this page · raw message

arch/riscv/kernel/mcount.S +13 -9
index c46a778627be..ce9bdc57a2a1 100644
@@ -32,13 +32,13 @@
 	addi	s0, sp, 32
 	.endm
 
-	.macro STORE_ABI_STATE
+	.macro RESTORE_ABI_STATE
 	ld	ra, 8(sp)
 	ld	s0, 0(sp)
 	addi	sp, sp, 16
 	.endm
 
-	.macro STORE_RET_ABI_STATE
+	.macro RESTORE_RET_ABI_STATE
 	ld	ra, 24(sp)
 	ld	s0, 16(sp)
 	ld	a0, 8(sp)
@@ -46,6 +46,10 @@
 	.endm
 
 ENTRY(ftrace_stub)
+#ifdef CONFIG_DYNAMIC_FTRACE
+       .global _mcount
+       .set    _mcount, ftrace_stub
+#endif
 	ret
 ENDPROC(ftrace_stub)
 
@@ -66,15 +70,15 @@ ENTRY(return_to_handler)
 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
 	mv	a0, t6
 #endif
-	la	t0, ftrace_return_to_handler
-	jalr	t0
+	call	ftrace_return_to_handler
 	mv	a1, a0
-	STORE_RET_ABI_STATE
+	RESTORE_RET_ABI_STATE
 	jalr	a1
 ENDPROC(return_to_handler)
 EXPORT_SYMBOL(return_to_handler)
 #endif
 
+#ifndef CONFIG_DYNAMIC_FTRACE
 ENTRY(_mcount)
 	la	t4, ftrace_stub
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
@@ -104,9 +108,8 @@ do_ftrace_graph_caller:
 	ld	a2, -16(s0)
 #endif
 	SAVE_ABI_STATE
-	la	t0, prepare_ftrace_return
-	jalr	t0
-	STORE_ABI_STATE
+	call	prepare_ftrace_return
+	RESTORE_ABI_STATE
 	ret
 #endif
 
@@ -120,7 +123,8 @@ do_trace:
 
 	SAVE_ABI_STATE
 	jalr	t5
-	STORE_ABI_STATE
+	RESTORE_ABI_STATE
 	ret
 ENDPROC(_mcount)
 EXPORT_SYMBOL(_mcount)
+#endif
Signature · 1 line
2.15.1
author
#3 lore raw

PATCH v4 3/6 riscv/ftrace: Add dynamic function graph tracer support

In reply to Alan Kao

Once the function_graph tracer is enabled, a filtered function has the following call sequence:

* ftracer_caller ==> on/off by ftrace_make_call/ftrace_make_nop
* ftrace_graph_caller
* ftrace_graph_call ==> on/off by ftrace_en/disable_ftrace_graph_caller
* prepare_ftrace_return

Considering the following DYNAMIC_FTRACE_WITH_REGS feature, it would be more extendable to have a ftrace_graph_caller function, instead of calling prepare_ftrace_return directly in ftrace_caller.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/kernel/ftrace.c     | 55 +++++++++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S | 64 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+), 1 deletion(-)
arch/riscv/kernel/ftrace.c +54 -1
index be4b24332d97..5bbe1afd9463 100644
@@ -139,4 +139,57 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 		return;
 	*parent = return_hooker;
 }
-#endif
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+extern void ftrace_graph_call(void);
+int ftrace_enable_ftrace_graph_caller(void)
+{
+	unsigned int call[2];
+	static int init_graph = 1;
+	int ret;
+
+	make_call(&ftrace_graph_call, &ftrace_stub, call);
+
+	/*
+	 * When enabling graph tracer for the first time, ftrace_graph_call
+	 * should contains a call to ftrace_stub.  Once it has been disabled,
+	 * the 8-bytes at the position becomes NOPs.
+	 */
+	if (init_graph) {
+		ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+						call);
+		init_graph = 0;
+	} else {
+		ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+						NULL);
+	}
+
+	if (ret)
+		return ret;
+
+	return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
+				    (unsigned long)&prepare_ftrace_return, true);
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+	unsigned int call[2];
+	int ret;
+
+	make_call(&ftrace_graph_call, &prepare_ftrace_return, call);
+
+	/*
+	 * This is to make sure that ftrace_enable_ftrace_graph_caller
+	 * did the right thing.
+	 */
+	ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+					call);
+
+	if (ret)
+		return ret;
+
+	return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
+				    (unsigned long)&prepare_ftrace_return, false);
+}
+#endif /* CONFIG_DYNAMIC_FTRACE */
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
arch/riscv/kernel/mcount-dyn.S +64 -0

94 lines not on this page · raw message

Signature · 1 line
2.15.1
author
#4 lore raw

PATCH v4 4/6 riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support

In reply to Alan Kao
Cc Greentime Hu <[email protected]>
---
 arch/riscv/include/asm/ftrace.h | 1 +
 arch/riscv/kernel/mcount-dyn.S  | 3 +++
 2 files changed, 4 insertions(+)
arch/riscv/include/asm/ftrace.h +1 -0
index 078743aacfd3..fedadc40e358 100644
@@ -9,6 +9,7 @@
 #define HAVE_FUNCTION_GRAPH_FP_TEST
 #endif
 
+#define ARCH_SUPPORTS_FTRACE_OPS 1
 #ifndef __ASSEMBLY__
 void _mcount(void);
 static inline unsigned long ftrace_call_adjust(unsigned long addr)
arch/riscv/kernel/mcount-dyn.S +3 -0
index 739e07a6fd85..6bbc3f88fcb3 100644
@@ -74,9 +74,12 @@ ENTRY(ftrace_caller)
 	/*
 	 * a0: the address in the caller when calling ftrace_caller
 	 * a1: the caller's return address
+	 * a2: the address of global variable function_trace_op
 	 */
 	ld	a1, -8(s0)
 	addi	a0, ra, -MCOUNT_INSN_SIZE
+	la	t5, function_trace_op
+	ld	a2, 0(t5)
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	/*
Signature · 1 line
2.15.1
author
#5 lore raw

PATCH v4 5/6 riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support

In reply to Alan Kao
Cc Greentime Hu <[email protected]>
---
 arch/riscv/Kconfig              |   1 +
 arch/riscv/include/asm/ftrace.h |   1 +
 arch/riscv/kernel/ftrace.c      |  17 ++++++
 arch/riscv/kernel/mcount-dyn.S  | 122 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+)
arch/riscv/Kconfig +1 -0
index df05acbb53d3..e4f9bac8ed76 100644
@@ -122,6 +122,7 @@ config ARCH_RV64I
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_DYNAMIC_FTRACE
+	select HAVE_DYNAMIC_FTRACE_WITH_REGS
 
 endchoice
 
arch/riscv/include/asm/ftrace.h +1 -0
index fedadc40e358..c6dcc5291f97 100644
@@ -8,6 +8,7 @@
 #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER)
 #define HAVE_FUNCTION_GRAPH_FP_TEST
 #endif
+#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
 
 #define ARCH_SUPPORTS_FTRACE_OPS 1
 #ifndef __ASSEMBLY__
arch/riscv/kernel/ftrace.c +17 -0
index 5bbe1afd9463..48b5353691c3 100644
@@ -106,6 +106,23 @@ int __init ftrace_dyn_arch_init(void)
 }
 #endif
 
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
+		       unsigned long addr)
+{
+	unsigned int call[2];
+	int ret;
+
+	make_call(rec->ip, old_addr, call);
+	ret = ftrace_check_current_call(rec->ip, call);
+
+	if (ret)
+		return ret;
+
+	return __ftrace_modify_call(rec->ip, addr, true);
+}
+#endif
+
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 /*
  * Most of this function is copied from arm64.
arch/riscv/kernel/mcount-dyn.S +122 -0

125 lines not on this page · raw message

Signature · 1 line
2.15.1
author
#6 lore raw

PATCH v4 6/6 riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

In reply to Alan Kao

In walk_stackframe, the pc now receives the address from calling ftrace_graph_ret_addr instead of manual calculation.

Note that the original calculation,

        pc = frame->ra - 4

is buggy when the instruction at the return address happened to be a compressed inst. But since it is not a critical part of ftrace, it is ignored for now to ease the review process.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/kernel/ftrace.c     | 2 +-
 arch/riscv/kernel/stacktrace.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
arch/riscv/kernel/ftrace.c +1 -1
index 48b5353691c3..1157b6b52d25 100644
@@ -151,7 +151,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 		return;
 
 	err = ftrace_push_return_trace(old, self_addr, &trace.depth,
-				       frame_pointer, NULL);
+				       frame_pointer, parent);
 	if (err == -EBUSY)
 		return;
 	*parent = return_hooker;
arch/riscv/kernel/stacktrace.c +6 -0
index 559aae781154..a4b1d94371a0 100644
@@ -18,6 +18,7 @@
 #include <linux/sched/debug.h>
 #include <linux/sched/task_stack.h>
 #include <linux/stacktrace.h>
+#include <linux/ftrace.h>
 
 #ifdef CONFIG_FRAME_POINTER
 
@@ -63,7 +64,12 @@ static void notrace walk_stackframe(struct task_struct *task,
 		frame = (struct stackframe *)fp - 1;
 		sp = fp;
 		fp = frame->fp;
+#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
+		pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
+					   (unsigned long *)(fp - 8));
+#else
 		pc = frame->ra - 0x4;
+#endif
 	}
 }
 
Signature · 1 line
2.15.1
author
#7 lore raw
In reply to Alan Kao
Quoted 26 lines · Alan Quey-Liang Kao(高魁良)

This patch set includes the building blocks of dynamic ftrace features for RISC-V machines.

Changes in v4:
- Organize code structure according to changes in v3
- Rebase onto the riscv-linux-4.15 branch at github's riscv/riscv-linux repo. Note that this set is based on the previous ftrace patch, which provided basic support.

Changes in v3:
- Replace the nops at the tracer call sites into "call ftrace_stub" instructions for better understanding (1/6, 2/6 and 5/6)

Changes in v2:
- Fix the return value as writing to kernel text goes wrong (2/6)
- Replace manual comparisons by calling memcmp (2/6)
- Simplify the conditional assignment in the Makefile (1/6)

Alan Kao (6):
riscv/ftrace: Add RECORD_MCOUNT support riscv/ftrace: Add dynamic function tracer support riscv/ftrace: Add dynamic function graph tracer support riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

Quoted 15 lines
 arch/riscv/Kconfig              |   3 +
 arch/riscv/Makefile             |   3 +
 arch/riscv/include/asm/ftrace.h |  56 ++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 175 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  | 239 ++++++++++++++++++++++++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 ++--
 arch/riscv/kernel/stacktrace.c  |   6 +
 scripts/recordmcount.pl         |   5 +
 9 files changed, 501 insertions(+), 13 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S
Signature · 1 line
2.15.1

Any comments?

#8 lore raw
Quoted 39 lines · On Tue, 20 Feb 2018 18:45:39 PST (-0800), [email protected] wrote:
Quoted 38 lines · Alan Quey-Liang Kao(高魁良)

This patch set includes the building blocks of dynamic ftrace features for RISC-V machines.

Changes in v4:
- Organize code structure according to changes in v3
- Rebase onto the riscv-linux-4.15 branch at github's riscv/riscv-linux repo. Note that this set is based on the previous ftrace patch, which provided basic support.

Changes in v3:
- Replace the nops at the tracer call sites into "call ftrace_stub" instructions for better understanding (1/6, 2/6 and 5/6)

Changes in v2:
- Fix the return value as writing to kernel text goes wrong (2/6)
- Replace manual comparisons by calling memcmp (2/6)
- Simplify the conditional assignment in the Makefile (1/6)

Alan Kao (6):
riscv/ftrace: Add RECORD_MCOUNT support riscv/ftrace: Add dynamic function tracer support riscv/ftrace: Add dynamic function graph tracer support riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

 arch/riscv/Kconfig              |   3 +
 arch/riscv/Makefile             |   3 +
 arch/riscv/include/asm/ftrace.h |  56 ++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 175 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  | 239 ++++++++++++++++++++++++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 ++--
 arch/riscv/kernel/stacktrace.c  |   6 +
 scripts/recordmcount.pl         |   5 +
 9 files changed, 501 insertions(+), 13 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.15.1

Any comments?

Sorry, my email latency is a bit long now as I'm still backed up from FOSDEM. This looks good, it should already be in our for-next branch.

#9 lore raw
In reply to Alan Kao
Quoted 26 lines · On Mon, 12 Feb 2018 21:13:15 PST (-0800), [email protected] wrote:

This patch set includes the building blocks of dynamic ftrace features for RISC-V machines.

Changes in v4:
- Organize code structure according to changes in v3
- Rebase onto the riscv-linux-4.15 branch at github's riscv/riscv-linux repo. Note that this set is based on the previous ftrace patch, which provided basic support.

Changes in v3:
- Replace the nops at the tracer call sites into "call ftrace_stub" instructions for better understanding (1/6, 2/6 and 5/6)

Changes in v2:
- Fix the return value as writing to kernel text goes wrong (2/6)
- Replace manual comparisons by calling memcmp (2/6)
- Simplify the conditional assignment in the Makefile (1/6)

Alan Kao (6):
riscv/ftrace: Add RECORD_MCOUNT support riscv/ftrace: Add dynamic function tracer support riscv/ftrace: Add dynamic function graph tracer support riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

Quoted 11 lines
 arch/riscv/Kconfig              |   3 +
 arch/riscv/Makefile             |   3 +
 arch/riscv/include/asm/ftrace.h |  56 ++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 175 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  | 239 ++++++++++++++++++++++++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 ++--
 arch/riscv/kernel/stacktrace.c  |   6 +
 scripts/recordmcount.pl         |   5 +
 9 files changed, 501 insertions(+), 13 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S

Thanks! I've added this to our for-next tree, it should be good to go for 4.17. Sorry this took a while, I'm still a bit behind from FOSDEM.

author
#10 lore raw
Quoted 39 lines · Palmer Dabbelt
Quoted 26 lines · On Mon, 12 Feb 2018 21:13:15 PST (-0800), [email protected] wrote:

This patch set includes the building blocks of dynamic ftrace features for RISC-V machines.

Changes in v4:
- Organize code structure according to changes in v3
- Rebase onto the riscv-linux-4.15 branch at github's riscv/riscv-linux repo. Note that this set is based on the previous ftrace patch, which provided basic support.

Changes in v3:
- Replace the nops at the tracer call sites into "call ftrace_stub" instructions for better understanding (1/6, 2/6 and 5/6)

Changes in v2:
- Fix the return value as writing to kernel text goes wrong (2/6)
- Replace manual comparisons by calling memcmp (2/6)
- Simplify the conditional assignment in the Makefile (1/6)

Alan Kao (6):
riscv/ftrace: Add RECORD_MCOUNT support riscv/ftrace: Add dynamic function tracer support riscv/ftrace: Add dynamic function graph tracer support riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support

Quoted 11 lines
 arch/riscv/Kconfig              |   3 +
 arch/riscv/Makefile             |   3 +
 arch/riscv/include/asm/ftrace.h |  56 ++++++++++
 arch/riscv/kernel/Makefile      |   5 +-
 arch/riscv/kernel/ftrace.c      | 175 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/mcount-dyn.S  | 239 ++++++++++++++++++++++++++++++++++++++++
 arch/riscv/kernel/mcount.S      |  22 ++--
 arch/riscv/kernel/stacktrace.c  |   6 +
 scripts/recordmcount.pl         |   5 +
 9 files changed, 501 insertions(+), 13 deletions(-)
 create mode 100644 arch/riscv/kernel/mcount-dyn.S
Quoted 2 lines

Thanks! I've added this to our for-next tree, it should be good to go for 4.17. Sorry this took a while, I'm still a bit behind from FOSDEM.

Thanks!

Alan