* [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
@ 2025-07-06 15:18 ChenMiao
2025-07-09 1:08 ` kernel test robot
2025-07-15 12:17 ` Alexandre Ghiti
0 siblings, 2 replies; 11+ messages in thread
From: ChenMiao @ 2025-07-06 15:18 UTC (permalink / raw)
To: Linux RISCV
Cc: chenmiao, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
Mathieu Desnoyers, Heiko Carstens, Pu Lehui, linux-kernel,
linux-trace-kernel
From: chenmiao <chenmiao.ku@gmail.com>
V1: The first version mainly involves modifications to the
configuration of the dynamic ftracer.
Link https://lore.kernel.org/all/f7e12c6d-892e-4ca3-9ef0-fbb524d04a48@ghiti.fr/
V2: After a series of discussions, Steven concluded that only
supporting the dynamic ftracer would suffice. Alex also pointed
out that if only the dynamic ftracer needs to be supported, the
code related to the static ftracer would become obsolete and
turn into dead code. He had already done some preliminary work on this.
Based on this, the modifications to the configuration were made,
and the dead code generated by the ftracer
(originally related to the static ftracer) was also removed.
Link https://lore.kernel.org/all/20250703115222.2d7c8cd5@batman.local.home/
Link https://github.com/linux-riscv/linux/pull/556/commits/0481092a5bec3818658981c11f629e06e66382b3
Signed-off-by: chenmiao <chenmiao.ku@gmail.com>
---
arch/riscv/Kconfig | 3 +-
arch/riscv/include/asm/ftrace.h | 3 --
arch/riscv/kernel/ftrace.c | 11 +-----
arch/riscv/kernel/mcount.S | 64 ---------------------------------
kernel/trace/Kconfig | 2 +-
5 files changed, 4 insertions(+), 79 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 36061f4732b7..95d24b19c466 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -97,8 +97,9 @@ config RISCV
select CLONE_BACKWARDS
select COMMON_CLK
select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
+ select DYNAMIC_FTRACE if FUNCTION_TRACER
select EDAC_SUPPORT
- select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
+ select FRAME_POINTER if PERF_EVENTS
select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
select GENERIC_ARCH_TOPOLOGY
diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
index 22ebea3c2b26..77ddb6dce0a8 100644
--- a/arch/riscv/include/asm/ftrace.h
+++ b/arch/riscv/include/asm/ftrace.h
@@ -49,7 +49,6 @@ struct dyn_arch_ftrace {
};
#endif
-#ifdef CONFIG_DYNAMIC_FTRACE
/*
* A general call in RISC-V is a pair of insts:
* 1) auipc: setting high-20 pc-related bits to ra register
@@ -237,6 +236,4 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsi
#endif /* __ASSEMBLY__ */
-#endif /* CONFIG_DYNAMIC_FTRACE */
-
#endif /* _ASM_RISCV_FTRACE_H */
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index 4c6c24380cfd..93bad646d233 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -13,7 +13,6 @@
#include <asm/cacheflush.h>
#include <asm/text-patching.h>
-#ifdef CONFIG_DYNAMIC_FTRACE
unsigned long ftrace_call_adjust(unsigned long addr)
{
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
@@ -191,13 +190,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
-#else /* CONFIG_DYNAMIC_FTRACE */
-unsigned long ftrace_call_adjust(unsigned long addr)
-{
- return addr;
-}
-#endif /* CONFIG_DYNAMIC_FTRACE */
-
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
unsigned long addr)
@@ -236,7 +228,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
*parent = return_hooker;
}
-#ifdef CONFIG_DYNAMIC_FTRACE
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct ftrace_regs *fregs)
{
@@ -257,5 +248,5 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
if (!function_graph_enter_regs(old, ip, frame_pointer, parent, fregs))
*parent = return_hooker;
}
-#endif /* CONFIG_DYNAMIC_FTRACE */
+
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S
index da4a4000e57e..bb550c15f1c9 100644
--- a/arch/riscv/kernel/mcount.S
+++ b/arch/riscv/kernel/mcount.S
@@ -14,13 +14,6 @@
.text
- .macro SAVE_ABI_STATE
- addi sp, sp, -16
- REG_S s0, 0*SZREG(sp)
- REG_S ra, 1*SZREG(sp)
- addi s0, sp, 16
- .endm
-
/*
* The call to ftrace_return_to_handler would overwrite the return
* register if a0 was not saved.
@@ -34,12 +27,6 @@
addi s0, sp, FREGS_SIZE_ON_STACK
.endm
- .macro RESTORE_ABI_STATE
- REG_L ra, 1*SZREG(sp)
- REG_L s0, 0*SZREG(sp)
- addi sp, sp, 16
- .endm
-
.macro RESTORE_RET_ABI_STATE
REG_L ra, FREGS_RA(sp)
REG_L s0, FREGS_S0(sp)
@@ -49,10 +36,8 @@
.endm
SYM_TYPED_FUNC_START(ftrace_stub)
-#ifdef CONFIG_DYNAMIC_FTRACE
.global _mcount
.set _mcount, ftrace_stub
-#endif
ret
SYM_FUNC_END(ftrace_stub)
@@ -79,53 +64,4 @@ SYM_FUNC_START(return_to_handler)
SYM_FUNC_END(return_to_handler)
#endif
-#ifndef CONFIG_DYNAMIC_FTRACE
-SYM_FUNC_START(_mcount)
- la t4, ftrace_stub
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
- la t0, ftrace_graph_return
- REG_L t1, 0(t0)
- bne t1, t4, .Ldo_ftrace_graph_caller
-
- la t3, ftrace_graph_entry
- REG_L t2, 0(t3)
- la t6, ftrace_graph_entry_stub
- bne t2, t6, .Ldo_ftrace_graph_caller
-#endif
- la t3, ftrace_trace_function
- REG_L t5, 0(t3)
- bne t5, t4, .Ldo_trace
- ret
-
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-/*
- * A pseudo representation for the function graph tracer:
- * prepare_to_return(&ra_to_caller_of_caller, ra_to_caller)
- */
-.Ldo_ftrace_graph_caller:
- addi a0, s0, -SZREG
- mv a1, ra
-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
- REG_L a2, -2*SZREG(s0)
-#endif
- SAVE_ABI_STATE
- call prepare_ftrace_return
- RESTORE_ABI_STATE
- ret
-#endif
-
-/*
- * A pseudo representation for the function tracer:
- * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller)
- */
-.Ldo_trace:
- REG_L a1, -SZREG(s0)
- mv a0, ra
-
- SAVE_ABI_STATE
- jalr t5
- RESTORE_ABI_STATE
- ret
-SYM_FUNC_END(_mcount)
-#endif
EXPORT_SYMBOL(_mcount)
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index a3f35c7d83b6..28afc6941e7a 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -275,7 +275,7 @@ config FUNCTION_TRACE_ARGS
funcgraph-args (for the function graph tracer)
config DYNAMIC_FTRACE
- bool "enable/disable function tracing dynamically"
+ bool
depends on FUNCTION_TRACER
depends on HAVE_DYNAMIC_FTRACE
default y
base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
--
2.45.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-06 15:18 [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection ChenMiao
@ 2025-07-09 1:08 ` kernel test robot
2025-07-10 11:53 ` Alexandre Ghiti
2025-07-15 12:17 ` Alexandre Ghiti
1 sibling, 1 reply; 11+ messages in thread
From: kernel test robot @ 2025-07-09 1:08 UTC (permalink / raw)
To: ChenMiao, Linux RISCV
Cc: oe-kbuild-all, chenmiao, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
Mathieu Desnoyers, Heiko Carstens, Pu Lehui, linux-kernel,
linux-trace-kernel
[-- Attachment #1: Type: text/plain, Size: 5122 bytes --]
Hi ChenMiao,
kernel test robot noticed the following build errors:
[auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
base: fda589c286040d9ba2d72a0eaf0a13945fc48026
patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: riscv-randconfig-r112-20250708 (attached as .config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce: (attached as reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
All errors (new ones prefixed by >>):
>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
addi sp, sp, -FREGS_SIZE_ON_STACK
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
>> <instantiation>:2:18: error: unexpected token
sw t0, FREGS_EPC(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:3:17: error: unexpected token
sw x1, FREGS_RA(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:7:17: error: unexpected token
sw x6, FREGS_T1(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:9:17: error: unexpected token
sw x7, FREGS_T2(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:10:18: error: unexpected token
sw x28, FREGS_T3(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:11:18: error: unexpected token
sw x29, FREGS_T4(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:12:18: error: unexpected token
sw x30, FREGS_T5(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:13:18: error: unexpected token
sw x31, FREGS_T6(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:16:18: error: unexpected token
sw x10, FREGS_A0(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:17:18: error: unexpected token
sw x11, FREGS_A1(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:18:18: error: unexpected token
sw x12, FREGS_A2(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:19:18: error: unexpected token
sw x13, FREGS_A3(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:20:18: error: unexpected token
sw x14, FREGS_A4(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:21:18: error: unexpected token
sw x15, FREGS_A5(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:22:18: error: unexpected token
sw x16, FREGS_A6(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:23:18: error: unexpected token
sw x17, FREGS_A7(sp)
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
^
<instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
addi a0, a0, FREGS_SIZE_ON_STACK
^
arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
SAVE_ABI_REGS
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
Selected by [y]:
- RISCV [=y] && FUNCTION_TRACER [=y]
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39394 bytes --]
[-- Attachment #3: reproduce --]
[-- Type: text/plain, Size: 949 bytes --]
reproduce:
git clone https://github.com/intel/lkp-tests.git ~/lkp-tests
# apt-get install sparse
# sparse version: v0.6.4-66-g0196afe1
# https://github.com/intel-lab-lkp/linux/commit/554547cdd15477e2cedac28c966a87607e43bb99
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
git checkout 554547cdd15477e2cedac28c966a87607e43bb99
# save the config file
mkdir build_dir && cp config build_dir/.config
~/lkp-tests/kbuild/make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build_dir ARCH=riscv olddefconfig
~/lkp-tests/kbuild/make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build_dir ARCH=riscv SHELL=/bin/bash
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-09 1:08 ` kernel test robot
@ 2025-07-10 11:53 ` Alexandre Ghiti
2025-07-10 12:34 ` Miao Chen
0 siblings, 1 reply; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-10 11:53 UTC (permalink / raw)
To: kernel test robot, ChenMiao, Linux RISCV
Cc: oe-kbuild-all, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Steven Rostedt, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
Heiko Carstens, Pu Lehui, linux-kernel, linux-trace-kernel
Hi ChenMiao,
On 7/9/25 03:08, kernel test robot wrote:
> Hi ChenMiao,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
>
> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
> :::::: branch date: 2 days ago
> :::::: commit date: 2 days ago
> config: riscv-randconfig-r112-20250708 (attached as .config)
> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> reproduce: (attached as reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> addi sp, sp, -FREGS_SIZE_ON_STACK
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
>>> <instantiation>:2:18: error: unexpected token
> sw t0, FREGS_EPC(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:3:17: error: unexpected token
> sw x1, FREGS_RA(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:7:17: error: unexpected token
> sw x6, FREGS_T1(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:9:17: error: unexpected token
> sw x7, FREGS_T2(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:10:18: error: unexpected token
> sw x28, FREGS_T3(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:11:18: error: unexpected token
> sw x29, FREGS_T4(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:12:18: error: unexpected token
> sw x30, FREGS_T5(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:13:18: error: unexpected token
> sw x31, FREGS_T6(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:16:18: error: unexpected token
> sw x10, FREGS_A0(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:17:18: error: unexpected token
> sw x11, FREGS_A1(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:18:18: error: unexpected token
> sw x12, FREGS_A2(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:19:18: error: unexpected token
> sw x13, FREGS_A3(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:20:18: error: unexpected token
> sw x14, FREGS_A4(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:21:18: error: unexpected token
> sw x15, FREGS_A5(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:22:18: error: unexpected token
> sw x16, FREGS_A6(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:23:18: error: unexpected token
> sw x17, FREGS_A7(sp)
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
> ^
> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> addi a0, a0, FREGS_SIZE_ON_STACK
> ^
> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> SAVE_ABI_REGS
>
> Kconfig warnings: (for reference only)
> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
> Selected by [y]:
> - RISCV [=y] && FUNCTION_TRACER [=y]
To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
That fixes the build error for me. Can you send a v3 with this change?
Thanks,
Alex
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-10 11:53 ` Alexandre Ghiti
@ 2025-07-10 12:34 ` Miao Chen
2025-07-10 14:32 ` Alexandre Ghiti
0 siblings, 1 reply; 11+ messages in thread
From: Miao Chen @ 2025-07-10 12:34 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
Hello Alex,
Sure, I'll checkout it. Btw, this is my first commit, so can u tell
how to reproduce failed case? Using the reproduce and .config.gz gived
by build-bot?
Thanks,
Chen Miao
Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
>
> Hi ChenMiao,
>
> On 7/9/25 03:08, kernel test robot wrote:
> > Hi ChenMiao,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
> > base: fda589c286040d9ba2d72a0eaf0a13945fc48026
> > patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
> > patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
> > :::::: branch date: 2 days ago
> > :::::: commit date: 2 days ago
> > config: riscv-randconfig-r112-20250708 (attached as .config)
> > compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> > reproduce: (attached as reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> > addi sp, sp, -FREGS_SIZE_ON_STACK
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> >>> <instantiation>:2:18: error: unexpected token
> > sw t0, FREGS_EPC(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:3:17: error: unexpected token
> > sw x1, FREGS_RA(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:7:17: error: unexpected token
> > sw x6, FREGS_T1(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:9:17: error: unexpected token
> > sw x7, FREGS_T2(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:10:18: error: unexpected token
> > sw x28, FREGS_T3(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:11:18: error: unexpected token
> > sw x29, FREGS_T4(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:12:18: error: unexpected token
> > sw x30, FREGS_T5(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:13:18: error: unexpected token
> > sw x31, FREGS_T6(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:16:18: error: unexpected token
> > sw x10, FREGS_A0(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:17:18: error: unexpected token
> > sw x11, FREGS_A1(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:18:18: error: unexpected token
> > sw x12, FREGS_A2(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:19:18: error: unexpected token
> > sw x13, FREGS_A3(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:20:18: error: unexpected token
> > sw x14, FREGS_A4(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:21:18: error: unexpected token
> > sw x15, FREGS_A5(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:22:18: error: unexpected token
> > sw x16, FREGS_A6(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:23:18: error: unexpected token
> > sw x17, FREGS_A7(sp)
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> > ^
> > <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> > addi a0, a0, FREGS_SIZE_ON_STACK
> > ^
> > arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> > SAVE_ABI_REGS
> >
> > Kconfig warnings: (for reference only)
> > WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
> > Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
> > Selected by [y]:
> > - RISCV [=y] && FUNCTION_TRACER [=y]
>
> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
>
> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
>
> That fixes the build error for me. Can you send a v3 with this change?
>
> Thanks,
>
> Alex
>
>
> >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-10 12:34 ` Miao Chen
@ 2025-07-10 14:32 ` Alexandre Ghiti
2025-07-10 15:56 ` Miao Chen
0 siblings, 1 reply; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-10 14:32 UTC (permalink / raw)
To: Miao Chen
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
On 7/10/25 14:34, Miao Chen wrote:
> Hello Alex,
>
> Sure, I'll checkout it. Btw, this is my first commit, so can u tell
> how to reproduce failed case? Using the reproduce and .config.gz gived
> by build-bot?
Yes exactly!
>
> Thanks,
>
> Chen Miao
>
> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
>> Hi ChenMiao,
>>
>> On 7/9/25 03:08, kernel test robot wrote:
>>> Hi ChenMiao,
>>>
>>> kernel test robot noticed the following build errors:
>>>
>>> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
>>>
>>> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
>>> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
>>> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
>>> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
>>> :::::: branch date: 2 days ago
>>> :::::: commit date: 2 days ago
>>> config: riscv-randconfig-r112-20250708 (attached as .config)
>>> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
>>> reproduce: (attached as reproduce)
>>>
>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>> the same patch/commit), kindly add following tags
>>> | Reported-by: kernel test robot <lkp@intel.com>
>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
>>>
>>> All errors (new ones prefixed by >>):
>>>
>>>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>> addi sp, sp, -FREGS_SIZE_ON_STACK
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>>>> <instantiation>:2:18: error: unexpected token
>>> sw t0, FREGS_EPC(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:3:17: error: unexpected token
>>> sw x1, FREGS_RA(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:7:17: error: unexpected token
>>> sw x6, FREGS_T1(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:9:17: error: unexpected token
>>> sw x7, FREGS_T2(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:10:18: error: unexpected token
>>> sw x28, FREGS_T3(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:11:18: error: unexpected token
>>> sw x29, FREGS_T4(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:12:18: error: unexpected token
>>> sw x30, FREGS_T5(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:13:18: error: unexpected token
>>> sw x31, FREGS_T6(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:16:18: error: unexpected token
>>> sw x10, FREGS_A0(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:17:18: error: unexpected token
>>> sw x11, FREGS_A1(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:18:18: error: unexpected token
>>> sw x12, FREGS_A2(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:19:18: error: unexpected token
>>> sw x13, FREGS_A3(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:20:18: error: unexpected token
>>> sw x14, FREGS_A4(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:21:18: error: unexpected token
>>> sw x15, FREGS_A5(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:22:18: error: unexpected token
>>> sw x16, FREGS_A6(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:23:18: error: unexpected token
>>> sw x17, FREGS_A7(sp)
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>> ^
>>> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>> addi a0, a0, FREGS_SIZE_ON_STACK
>>> ^
>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>> SAVE_ABI_REGS
>>>
>>> Kconfig warnings: (for reference only)
>>> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
>>> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
>>> Selected by [y]:
>>> - RISCV [=y] && FUNCTION_TRACER [=y]
>> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
>>
>> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
>>
>> That fixes the build error for me. Can you send a v3 with this change?
>>
>> Thanks,
>>
>> Alex
>>
>>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-10 14:32 ` Alexandre Ghiti
@ 2025-07-10 15:56 ` Miao Chen
2025-07-11 7:55 ` Alexandre Ghiti
0 siblings, 1 reply; 11+ messages in thread
From: Miao Chen @ 2025-07-10 15:56 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
Hello Alex,
I found where the error is, but there's a problem here:
config PORTABLE
bool
default !NONPORTABLE
select EFI
select MMU
select OF
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU &&
(CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
Because HAVE_DYNAMIC_FTRACE depends on the MMU—of course, it's
reasonable for DYNAMIC_FTRACE to depend on the MMU—*but since
NONPORTABLE is enabled by default, this causes PORTABLE to default to
n, thereby preventing the MMU from being enabled*. So, should I change
NONPORTABLE to default to n?
Thanks,
Alex
Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 22:33写道:
>
>
> On 7/10/25 14:34, Miao Chen wrote:
> > Hello Alex,
> >
> > Sure, I'll checkout it. Btw, this is my first commit, so can u tell
> > how to reproduce failed case? Using the reproduce and .config.gz gived
> > by build-bot?
>
>
> Yes exactly!
>
>
> >
> > Thanks,
> >
> > Chen Miao
> >
> > Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
> >> Hi ChenMiao,
> >>
> >> On 7/9/25 03:08, kernel test robot wrote:
> >>> Hi ChenMiao,
> >>>
> >>> kernel test robot noticed the following build errors:
> >>>
> >>> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
> >>>
> >>> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
> >>> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
> >>> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
> >>> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
> >>> :::::: branch date: 2 days ago
> >>> :::::: commit date: 2 days ago
> >>> config: riscv-randconfig-r112-20250708 (attached as .config)
> >>> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> >>> reproduce: (attached as reproduce)
> >>>
> >>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> >>> the same patch/commit), kindly add following tags
> >>> | Reported-by: kernel test robot <lkp@intel.com>
> >>> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
> >>>
> >>> All errors (new ones prefixed by >>):
> >>>
> >>>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> >>> addi sp, sp, -FREGS_SIZE_ON_STACK
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>>>> <instantiation>:2:18: error: unexpected token
> >>> sw t0, FREGS_EPC(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:3:17: error: unexpected token
> >>> sw x1, FREGS_RA(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:7:17: error: unexpected token
> >>> sw x6, FREGS_T1(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:9:17: error: unexpected token
> >>> sw x7, FREGS_T2(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:10:18: error: unexpected token
> >>> sw x28, FREGS_T3(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:11:18: error: unexpected token
> >>> sw x29, FREGS_T4(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:12:18: error: unexpected token
> >>> sw x30, FREGS_T5(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:13:18: error: unexpected token
> >>> sw x31, FREGS_T6(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:16:18: error: unexpected token
> >>> sw x10, FREGS_A0(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:17:18: error: unexpected token
> >>> sw x11, FREGS_A1(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:18:18: error: unexpected token
> >>> sw x12, FREGS_A2(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:19:18: error: unexpected token
> >>> sw x13, FREGS_A3(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:20:18: error: unexpected token
> >>> sw x14, FREGS_A4(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:21:18: error: unexpected token
> >>> sw x15, FREGS_A5(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:22:18: error: unexpected token
> >>> sw x16, FREGS_A6(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:23:18: error: unexpected token
> >>> sw x17, FREGS_A7(sp)
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>> ^
> >>> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> >>> addi a0, a0, FREGS_SIZE_ON_STACK
> >>> ^
> >>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>> SAVE_ABI_REGS
> >>>
> >>> Kconfig warnings: (for reference only)
> >>> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
> >>> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
> >>> Selected by [y]:
> >>> - RISCV [=y] && FUNCTION_TRACER [=y]
> >> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
> >>
> >> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
> >>
> >> That fixes the build error for me. Can you send a v3 with this change?
> >>
> >> Thanks,
> >>
> >> Alex
> >>
> >>
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-10 15:56 ` Miao Chen
@ 2025-07-11 7:55 ` Alexandre Ghiti
2025-07-11 8:24 ` Miao Chen
0 siblings, 1 reply; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-11 7:55 UTC (permalink / raw)
To: Miao Chen
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
Hi,
On 7/10/25 17:56, Miao Chen wrote:
> Hello Alex,
>
> I found where the error is, but there's a problem here:
>
> config PORTABLE
> bool
> default !NONPORTABLE
> select EFI
> select MMU
> select OF
>
> select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU &&
> (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
>
> Because HAVE_DYNAMIC_FTRACE depends on the MMU—of course, it's
> reasonable for DYNAMIC_FTRACE to depend on the MMU—*but since
> NONPORTABLE is enabled by default, this causes PORTABLE to default to
> n, thereby preventing the MMU from being enabled*. So, should I change
> NONPORTABLE to default to n?
NONPORTABLE is not enabled by default and PORTABLE=n does not prevent
MMU from being enabled.
IIUC, it seems like you don't have HAVE_DYNAMIC_FTRACE enabled but
that's probably because of your toolchain, not !MMU, can you check that
in your .config?
Thanks,
Alex
>
> Thanks,
>
> Alex
>
> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 22:33写道:
>>
>> On 7/10/25 14:34, Miao Chen wrote:
>>> Hello Alex,
>>>
>>> Sure, I'll checkout it. Btw, this is my first commit, so can u tell
>>> how to reproduce failed case? Using the reproduce and .config.gz gived
>>> by build-bot?
>>
>> Yes exactly!
>>
>>
>>> Thanks,
>>>
>>> Chen Miao
>>>
>>> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
>>>> Hi ChenMiao,
>>>>
>>>> On 7/9/25 03:08, kernel test robot wrote:
>>>>> Hi ChenMiao,
>>>>>
>>>>> kernel test robot noticed the following build errors:
>>>>>
>>>>> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
>>>>>
>>>>> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
>>>>> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
>>>>> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
>>>>> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
>>>>> :::::: branch date: 2 days ago
>>>>> :::::: commit date: 2 days ago
>>>>> config: riscv-randconfig-r112-20250708 (attached as .config)
>>>>> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
>>>>> reproduce: (attached as reproduce)
>>>>>
>>>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>>>> the same patch/commit), kindly add following tags
>>>>> | Reported-by: kernel test robot <lkp@intel.com>
>>>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
>>>>>
>>>>> All errors (new ones prefixed by >>):
>>>>>
>>>>>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>>>> addi sp, sp, -FREGS_SIZE_ON_STACK
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>>>> <instantiation>:2:18: error: unexpected token
>>>>> sw t0, FREGS_EPC(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:3:17: error: unexpected token
>>>>> sw x1, FREGS_RA(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:7:17: error: unexpected token
>>>>> sw x6, FREGS_T1(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:9:17: error: unexpected token
>>>>> sw x7, FREGS_T2(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:10:18: error: unexpected token
>>>>> sw x28, FREGS_T3(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:11:18: error: unexpected token
>>>>> sw x29, FREGS_T4(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:12:18: error: unexpected token
>>>>> sw x30, FREGS_T5(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:13:18: error: unexpected token
>>>>> sw x31, FREGS_T6(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:16:18: error: unexpected token
>>>>> sw x10, FREGS_A0(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:17:18: error: unexpected token
>>>>> sw x11, FREGS_A1(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:18:18: error: unexpected token
>>>>> sw x12, FREGS_A2(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:19:18: error: unexpected token
>>>>> sw x13, FREGS_A3(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:20:18: error: unexpected token
>>>>> sw x14, FREGS_A4(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:21:18: error: unexpected token
>>>>> sw x15, FREGS_A5(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:22:18: error: unexpected token
>>>>> sw x16, FREGS_A6(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:23:18: error: unexpected token
>>>>> sw x17, FREGS_A7(sp)
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>> ^
>>>>> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>>>> addi a0, a0, FREGS_SIZE_ON_STACK
>>>>> ^
>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>> SAVE_ABI_REGS
>>>>>
>>>>> Kconfig warnings: (for reference only)
>>>>> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
>>>>> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
>>>>> Selected by [y]:
>>>>> - RISCV [=y] && FUNCTION_TRACER [=y]
>>>> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
>>>>
>>>> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
>>>>
>>>> That fixes the build error for me. Can you send a v3 with this change?
>>>>
>>>> Thanks,
>>>>
>>>> Alex
>>>>
>>>>
>>> _______________________________________________
>>> linux-riscv mailing list
>>> linux-riscv@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-11 7:55 ` Alexandre Ghiti
@ 2025-07-11 8:24 ` Miao Chen
2025-07-15 8:59 ` Alexandre Ghiti
0 siblings, 1 reply; 11+ messages in thread
From: Miao Chen @ 2025-07-11 8:24 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
Hi,
I rechecked the .config file. I configured it using
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited
-fmax-warnings=unlimited' O=build_dir olddefconfig,
and obtained the following configuration. If NONPORTABLE is disabled,
the MMU will be enabled. I did not find any other settings that would
affect the enabling of NONPORTABLE—it is set to 'y' by default.
--------- CONFIG ---------------------
config NONPORTABLE
bool "Allow configurations that result in non-portable kernels"
Symbol: HAVE_DYNAMIC_FTRACE [=n]
Type : bool
Defined at kernel/trace/Kconfig:42
Selected by [n]:
- RISCV [=y] && !XIP_KERNEL [=n] && MMU [=n] &&
(CLANG_SUPPORTS_DYNAMIC_FTRACE [=n] || GCC_SUPPORTS_DYNAMIC_FTRACE
[=y])
Symbol: MMU [=n]
Type : bool
Defined at arch/riscv/Kconfig:298
Prompt: MMU-based Paged Memory Management Support
Location:
(1) -> MMU-based Paged Memory Management Support (MMU [=n])
Selected by [n]:
- PORTABLE [=n]
Symbol: PORTABLE [=n]
Type : bool
Defined at arch/riscv/Kconfig:1344
Selects: EFI [=n] && MMU [=n] && OF [=y]
Symbol: NONPORTABLE [=y]
│ Type : bool
│ Defined at arch/riscv/Kconfig:389
│ Prompt: Allow configurations that result in non-portable kernels
│ Location:
│ -> Platform type
│ (1) -> Allow configurations that result in non-portable kernels
(NONPORTABLE [=y])
Thanks,
Chen Miao
Alexandre Ghiti <alex@ghiti.fr> 于2025年7月11日周五 15:55写道:
>
> Hi,
>
> On 7/10/25 17:56, Miao Chen wrote:
> > Hello Alex,
> >
> > I found where the error is, but there's a problem here:
> >
> > config PORTABLE
> > bool
> > default !NONPORTABLE
> > select EFI
> > select MMU
> > select OF
> >
> > select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU &&
> > (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
> >
> > Because HAVE_DYNAMIC_FTRACE depends on the MMU—of course, it's
> > reasonable for DYNAMIC_FTRACE to depend on the MMU—*but since
> > NONPORTABLE is enabled by default, this causes PORTABLE to default to
> > n, thereby preventing the MMU from being enabled*. So, should I change
> > NONPORTABLE to default to n?
>
>
> NONPORTABLE is not enabled by default and PORTABLE=n does not prevent
> MMU from being enabled.
>
> IIUC, it seems like you don't have HAVE_DYNAMIC_FTRACE enabled but
> that's probably because of your toolchain, not !MMU, can you check that
> in your .config?
>
> Thanks,
>
> Alex
>
>
> >
> > Thanks,
> >
> > Alex
> >
> > Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 22:33写道:
> >>
> >> On 7/10/25 14:34, Miao Chen wrote:
> >>> Hello Alex,
> >>>
> >>> Sure, I'll checkout it. Btw, this is my first commit, so can u tell
> >>> how to reproduce failed case? Using the reproduce and .config.gz gived
> >>> by build-bot?
> >>
> >> Yes exactly!
> >>
> >>
> >>> Thanks,
> >>>
> >>> Chen Miao
> >>>
> >>> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
> >>>> Hi ChenMiao,
> >>>>
> >>>> On 7/9/25 03:08, kernel test robot wrote:
> >>>>> Hi ChenMiao,
> >>>>>
> >>>>> kernel test robot noticed the following build errors:
> >>>>>
> >>>>> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
> >>>>>
> >>>>> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
> >>>>> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
> >>>>> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
> >>>>> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
> >>>>> :::::: branch date: 2 days ago
> >>>>> :::::: commit date: 2 days ago
> >>>>> config: riscv-randconfig-r112-20250708 (attached as .config)
> >>>>> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> >>>>> reproduce: (attached as reproduce)
> >>>>>
> >>>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> >>>>> the same patch/commit), kindly add following tags
> >>>>> | Reported-by: kernel test robot <lkp@intel.com>
> >>>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
> >>>>>
> >>>>> All errors (new ones prefixed by >>):
> >>>>>
> >>>>>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> >>>>> addi sp, sp, -FREGS_SIZE_ON_STACK
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>>>> <instantiation>:2:18: error: unexpected token
> >>>>> sw t0, FREGS_EPC(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:3:17: error: unexpected token
> >>>>> sw x1, FREGS_RA(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:7:17: error: unexpected token
> >>>>> sw x6, FREGS_T1(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:9:17: error: unexpected token
> >>>>> sw x7, FREGS_T2(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:10:18: error: unexpected token
> >>>>> sw x28, FREGS_T3(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:11:18: error: unexpected token
> >>>>> sw x29, FREGS_T4(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:12:18: error: unexpected token
> >>>>> sw x30, FREGS_T5(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:13:18: error: unexpected token
> >>>>> sw x31, FREGS_T6(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:16:18: error: unexpected token
> >>>>> sw x10, FREGS_A0(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:17:18: error: unexpected token
> >>>>> sw x11, FREGS_A1(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:18:18: error: unexpected token
> >>>>> sw x12, FREGS_A2(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:19:18: error: unexpected token
> >>>>> sw x13, FREGS_A3(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:20:18: error: unexpected token
> >>>>> sw x14, FREGS_A4(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:21:18: error: unexpected token
> >>>>> sw x15, FREGS_A5(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:22:18: error: unexpected token
> >>>>> sw x16, FREGS_A6(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:23:18: error: unexpected token
> >>>>> sw x17, FREGS_A7(sp)
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>> ^
> >>>>> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
> >>>>> addi a0, a0, FREGS_SIZE_ON_STACK
> >>>>> ^
> >>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
> >>>>> SAVE_ABI_REGS
> >>>>>
> >>>>> Kconfig warnings: (for reference only)
> >>>>> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
> >>>>> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
> >>>>> Selected by [y]:
> >>>>> - RISCV [=y] && FUNCTION_TRACER [=y]
> >>>> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
> >>>>
> >>>> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
> >>>>
> >>>> That fixes the build error for me. Can you send a v3 with this change?
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Alex
> >>>>
> >>>>
> >>> _______________________________________________
> >>> linux-riscv mailing list
> >>> linux-riscv@lists.infradead.org
> >>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-11 8:24 ` Miao Chen
@ 2025-07-15 8:59 ` Alexandre Ghiti
0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-15 8:59 UTC (permalink / raw)
To: Miao Chen
Cc: kernel test robot, Linux RISCV, oe-kbuild-all, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Steven Rostedt, Masami Hiramatsu,
Mark Rutland, Mathieu Desnoyers, Heiko Carstens, Pu Lehui,
linux-kernel, linux-trace-kernel
Hi,
On 7/11/25 10:24, Miao Chen wrote:
> Hi,
>
> I rechecked the .config file. I configured it using
>
> make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
> CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited
> -fmax-warnings=unlimited' O=build_dir olddefconfig,
>
> and obtained the following configuration. If NONPORTABLE is disabled,
> the MMU will be enabled. I did not find any other settings that would
> affect the enabling of NONPORTABLE—it is set to 'y' by default.
NONPORTABLE being set does not prevent MMU to be enabled. I see that in
your config MMU is disabled and then HAVE_DYNAMIC_FTRACE is disabled, I
don't see anything wrong with this configuration so there is no need to
try to enable MMU.
This configuration shows that we need to check that HAVE_DYNAMIC_FTRACE
is set to enable DYNAMIC_FTRACE, otherwise we encounter the build errors
reported by kernel test robot.
Can you send a v3 with this change?
Also, can you change the patch title and patch log to something like this:
riscv: Stop supporting static ftrace
Now that DYNAMIC_FTRACE was introduced, there is no need to support
static ftrace as it is way less performant. This simplifies the
code and
prevents build failures as reported by kernel test robot when
!DYNAMIC_FTRACE.
Thanks,
Alex
>
>
> --------- CONFIG ---------------------
>
> config NONPORTABLE
> bool "Allow configurations that result in non-portable kernels"
>
> Symbol: HAVE_DYNAMIC_FTRACE [=n]
> Type : bool
> Defined at kernel/trace/Kconfig:42
> Selected by [n]:
> - RISCV [=y] && !XIP_KERNEL [=n] && MMU [=n] &&
> (CLANG_SUPPORTS_DYNAMIC_FTRACE [=n] || GCC_SUPPORTS_DYNAMIC_FTRACE
> [=y])
>
> Symbol: MMU [=n]
> Type : bool
> Defined at arch/riscv/Kconfig:298
> Prompt: MMU-based Paged Memory Management Support
> Location:
> (1) -> MMU-based Paged Memory Management Support (MMU [=n])
> Selected by [n]:
> - PORTABLE [=n]
>
> Symbol: PORTABLE [=n]
> Type : bool
> Defined at arch/riscv/Kconfig:1344
> Selects: EFI [=n] && MMU [=n] && OF [=y]
>
> Symbol: NONPORTABLE [=y]
> │ Type : bool
> │ Defined at arch/riscv/Kconfig:389
> │ Prompt: Allow configurations that result in non-portable kernels
> │ Location:
> │ -> Platform type
> │ (1) -> Allow configurations that result in non-portable kernels
> (NONPORTABLE [=y])
>
> Thanks,
>
> Chen Miao
>
> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月11日周五 15:55写道:
>> Hi,
>>
>> On 7/10/25 17:56, Miao Chen wrote:
>>> Hello Alex,
>>>
>>> I found where the error is, but there's a problem here:
>>>
>>> config PORTABLE
>>> bool
>>> default !NONPORTABLE
>>> select EFI
>>> select MMU
>>> select OF
>>>
>>> select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU &&
>>> (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
>>>
>>> Because HAVE_DYNAMIC_FTRACE depends on the MMU—of course, it's
>>> reasonable for DYNAMIC_FTRACE to depend on the MMU—*but since
>>> NONPORTABLE is enabled by default, this causes PORTABLE to default to
>>> n, thereby preventing the MMU from being enabled*. So, should I change
>>> NONPORTABLE to default to n?
>>
>> NONPORTABLE is not enabled by default and PORTABLE=n does not prevent
>> MMU from being enabled.
>>
>> IIUC, it seems like you don't have HAVE_DYNAMIC_FTRACE enabled but
>> that's probably because of your toolchain, not !MMU, can you check that
>> in your .config?
>>
>> Thanks,
>>
>> Alex
>>
>>
>>> Thanks,
>>>
>>> Alex
>>>
>>> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 22:33写道:
>>>> On 7/10/25 14:34, Miao Chen wrote:
>>>>> Hello Alex,
>>>>>
>>>>> Sure, I'll checkout it. Btw, this is my first commit, so can u tell
>>>>> how to reproduce failed case? Using the reproduce and .config.gz gived
>>>>> by build-bot?
>>>> Yes exactly!
>>>>
>>>>
>>>>> Thanks,
>>>>>
>>>>> Chen Miao
>>>>>
>>>>> Alexandre Ghiti <alex@ghiti.fr> 于2025年7月10日周四 19:53写道:
>>>>>> Hi ChenMiao,
>>>>>>
>>>>>> On 7/9/25 03:08, kernel test robot wrote:
>>>>>>> Hi ChenMiao,
>>>>>>>
>>>>>>> kernel test robot noticed the following build errors:
>>>>>>>
>>>>>>> [auto build test ERROR on fda589c286040d9ba2d72a0eaf0a13945fc48026]
>>>>>>>
>>>>>>> url: https://github.com/intel-lab-lkp/linux/commits/ChenMiao/riscv-ftrace-Fix-the-logic-issue-in-DYNAMIC_FTRACE-selection/20250706-231907
>>>>>>> base: fda589c286040d9ba2d72a0eaf0a13945fc48026
>>>>>>> patch link: https://lore.kernel.org/r/20250706151830.25091-1-chenmiao.ku%40gmail.com
>>>>>>> patch subject: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
>>>>>>> :::::: branch date: 2 days ago
>>>>>>> :::::: commit date: 2 days ago
>>>>>>> config: riscv-randconfig-r112-20250708 (attached as .config)
>>>>>>> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
>>>>>>> reproduce: (attached as reproduce)
>>>>>>>
>>>>>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>>>>>> the same patch/commit), kindly add following tags
>>>>>>> | Reported-by: kernel test robot <lkp@intel.com>
>>>>>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202507090650.YGY56SIA-lkp@intel.com/
>>>>>>>
>>>>>>> All errors (new ones prefixed by >>):
>>>>>>>
>>>>>>>>> <instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>>>>>> addi sp, sp, -FREGS_SIZE_ON_STACK
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>>>> <instantiation>:2:18: error: unexpected token
>>>>>>> sw t0, FREGS_EPC(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:3:17: error: unexpected token
>>>>>>> sw x1, FREGS_RA(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:7:17: error: unexpected token
>>>>>>> sw x6, FREGS_T1(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:9:17: error: unexpected token
>>>>>>> sw x7, FREGS_T2(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:10:18: error: unexpected token
>>>>>>> sw x28, FREGS_T3(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:11:18: error: unexpected token
>>>>>>> sw x29, FREGS_T4(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:12:18: error: unexpected token
>>>>>>> sw x30, FREGS_T5(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:13:18: error: unexpected token
>>>>>>> sw x31, FREGS_T6(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:16:18: error: unexpected token
>>>>>>> sw x10, FREGS_A0(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:17:18: error: unexpected token
>>>>>>> sw x11, FREGS_A1(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:18:18: error: unexpected token
>>>>>>> sw x12, FREGS_A2(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:19:18: error: unexpected token
>>>>>>> sw x13, FREGS_A3(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:20:18: error: unexpected token
>>>>>>> sw x14, FREGS_A4(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:21:18: error: unexpected token
>>>>>>> sw x15, FREGS_A5(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:22:18: error: unexpected token
>>>>>>> sw x16, FREGS_A6(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:23:18: error: unexpected token
>>>>>>> sw x17, FREGS_A7(sp)
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>> ^
>>>>>>> <instantiation>:25:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
>>>>>>> addi a0, a0, FREGS_SIZE_ON_STACK
>>>>>>> ^
>>>>>>> arch/riscv/kernel/mcount-dyn.S:185:2: note: while in macro instantiation
>>>>>>> SAVE_ABI_REGS
>>>>>>>
>>>>>>> Kconfig warnings: (for reference only)
>>>>>>> WARNING: unmet direct dependencies detected for DYNAMIC_FTRACE
>>>>>>> Depends on [n]: FTRACE [=y] && FUNCTION_TRACER [=y] && HAVE_DYNAMIC_FTRACE [=n]
>>>>>>> Selected by [y]:
>>>>>>> - RISCV [=y] && FUNCTION_TRACER [=y]
>>>>>> To avoid that, we should check HAVE_DYNAMIC_FTRACE too:
>>>>>>
>>>>>> select DYNAMIC_FTRACE if FUNCTION_TRACER && HAVE_DYNAMIC_FTRACE
>>>>>>
>>>>>> That fixes the build error for me. Can you send a v3 with this change?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Alex
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> linux-riscv mailing list
>>>>> linux-riscv@lists.infradead.org
>>>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
>>> _______________________________________________
>>> linux-riscv mailing list
>>> linux-riscv@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-06 15:18 [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection ChenMiao
2025-07-09 1:08 ` kernel test robot
@ 2025-07-15 12:17 ` Alexandre Ghiti
2025-07-16 11:07 ` Alexandre Ghiti
1 sibling, 1 reply; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-15 12:17 UTC (permalink / raw)
To: ChenMiao, Linux RISCV
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Steven Rostedt,
Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Heiko Carstens,
Pu Lehui, linux-kernel, linux-trace-kernel
On 7/6/25 17:18, ChenMiao wrote:
> From: chenmiao <chenmiao.ku@gmail.com>
>
> V1: The first version mainly involves modifications to the
> configuration of the dynamic ftracer.
>
> Link https://lore.kernel.org/all/f7e12c6d-892e-4ca3-9ef0-fbb524d04a48@ghiti.fr/
>
> V2: After a series of discussions, Steven concluded that only
> supporting the dynamic ftracer would suffice. Alex also pointed
> out that if only the dynamic ftracer needs to be supported, the
> code related to the static ftracer would become obsolete and
> turn into dead code. He had already done some preliminary work on this.
>
> Based on this, the modifications to the configuration were made,
> and the dead code generated by the ftracer
> (originally related to the static ftracer) was also removed.
>
> Link https://lore.kernel.org/all/20250703115222.2d7c8cd5@batman.local.home/
> Link https://github.com/linux-riscv/linux/pull/556/commits/0481092a5bec3818658981c11f629e06e66382b3
>
> Signed-off-by: chenmiao <chenmiao.ku@gmail.com>
> ---
> arch/riscv/Kconfig | 3 +-
> arch/riscv/include/asm/ftrace.h | 3 --
> arch/riscv/kernel/ftrace.c | 11 +-----
> arch/riscv/kernel/mcount.S | 64 ---------------------------------
> kernel/trace/Kconfig | 2 +-
> 5 files changed, 4 insertions(+), 79 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 36061f4732b7..95d24b19c466 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -97,8 +97,9 @@ config RISCV
> select CLONE_BACKWARDS
> select COMMON_CLK
> select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
> + select DYNAMIC_FTRACE if FUNCTION_TRACER
> select EDAC_SUPPORT
> - select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
> + select FRAME_POINTER if PERF_EVENTS
> select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
> select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
> select GENERIC_ARCH_TOPOLOGY
> diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
> index 22ebea3c2b26..77ddb6dce0a8 100644
> --- a/arch/riscv/include/asm/ftrace.h
> +++ b/arch/riscv/include/asm/ftrace.h
> @@ -49,7 +49,6 @@ struct dyn_arch_ftrace {
> };
> #endif
>
> -#ifdef CONFIG_DYNAMIC_FTRACE
> /*
> * A general call in RISC-V is a pair of insts:
> * 1) auipc: setting high-20 pc-related bits to ra register
> @@ -237,6 +236,4 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsi
>
> #endif /* __ASSEMBLY__ */
>
> -#endif /* CONFIG_DYNAMIC_FTRACE */
> -
> #endif /* _ASM_RISCV_FTRACE_H */
> diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
> index 4c6c24380cfd..93bad646d233 100644
> --- a/arch/riscv/kernel/ftrace.c
> +++ b/arch/riscv/kernel/ftrace.c
> @@ -13,7 +13,6 @@
> #include <asm/cacheflush.h>
> #include <asm/text-patching.h>
>
> -#ifdef CONFIG_DYNAMIC_FTRACE
> unsigned long ftrace_call_adjust(unsigned long addr)
> {
> if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
> @@ -191,13 +190,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> return 0;
> }
>
> -#else /* CONFIG_DYNAMIC_FTRACE */
> -unsigned long ftrace_call_adjust(unsigned long addr)
> -{
> - return addr;
> -}
> -#endif /* CONFIG_DYNAMIC_FTRACE */
> -
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
> int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
> unsigned long addr)
> @@ -236,7 +228,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
> *parent = return_hooker;
> }
>
> -#ifdef CONFIG_DYNAMIC_FTRACE
> void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
> struct ftrace_ops *op, struct ftrace_regs *fregs)
> {
> @@ -257,5 +248,5 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
> if (!function_graph_enter_regs(old, ip, frame_pointer, parent, fregs))
> *parent = return_hooker;
> }
> -#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S
> index da4a4000e57e..bb550c15f1c9 100644
> --- a/arch/riscv/kernel/mcount.S
> +++ b/arch/riscv/kernel/mcount.S
> @@ -14,13 +14,6 @@
>
> .text
>
> - .macro SAVE_ABI_STATE
> - addi sp, sp, -16
> - REG_S s0, 0*SZREG(sp)
> - REG_S ra, 1*SZREG(sp)
> - addi s0, sp, 16
> - .endm
> -
> /*
> * The call to ftrace_return_to_handler would overwrite the return
> * register if a0 was not saved.
> @@ -34,12 +27,6 @@
> addi s0, sp, FREGS_SIZE_ON_STACK
> .endm
>
> - .macro RESTORE_ABI_STATE
> - REG_L ra, 1*SZREG(sp)
> - REG_L s0, 0*SZREG(sp)
> - addi sp, sp, 16
> - .endm
> -
> .macro RESTORE_RET_ABI_STATE
> REG_L ra, FREGS_RA(sp)
> REG_L s0, FREGS_S0(sp)
> @@ -49,10 +36,8 @@
> .endm
>
> SYM_TYPED_FUNC_START(ftrace_stub)
> -#ifdef CONFIG_DYNAMIC_FTRACE
> .global _mcount
> .set _mcount, ftrace_stub
> -#endif
> ret
> SYM_FUNC_END(ftrace_stub)
>
> @@ -79,53 +64,4 @@ SYM_FUNC_START(return_to_handler)
> SYM_FUNC_END(return_to_handler)
> #endif
>
> -#ifndef CONFIG_DYNAMIC_FTRACE
> -SYM_FUNC_START(_mcount)
> - la t4, ftrace_stub
> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> - la t0, ftrace_graph_return
> - REG_L t1, 0(t0)
> - bne t1, t4, .Ldo_ftrace_graph_caller
> -
> - la t3, ftrace_graph_entry
> - REG_L t2, 0(t3)
> - la t6, ftrace_graph_entry_stub
> - bne t2, t6, .Ldo_ftrace_graph_caller
> -#endif
> - la t3, ftrace_trace_function
> - REG_L t5, 0(t3)
> - bne t5, t4, .Ldo_trace
> - ret
> -
> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> -/*
> - * A pseudo representation for the function graph tracer:
> - * prepare_to_return(&ra_to_caller_of_caller, ra_to_caller)
> - */
> -.Ldo_ftrace_graph_caller:
> - addi a0, s0, -SZREG
> - mv a1, ra
> -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
> - REG_L a2, -2*SZREG(s0)
> -#endif
> - SAVE_ABI_STATE
> - call prepare_ftrace_return
> - RESTORE_ABI_STATE
> - ret
> -#endif
> -
> -/*
> - * A pseudo representation for the function tracer:
> - * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller)
> - */
> -.Ldo_trace:
> - REG_L a1, -SZREG(s0)
> - mv a0, ra
> -
> - SAVE_ABI_STATE
> - jalr t5
> - RESTORE_ABI_STATE
> - ret
> -SYM_FUNC_END(_mcount)
> -#endif
> EXPORT_SYMBOL(_mcount)
> diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
> index a3f35c7d83b6..28afc6941e7a 100644
> --- a/kernel/trace/Kconfig
> +++ b/kernel/trace/Kconfig
> @@ -275,7 +275,7 @@ config FUNCTION_TRACE_ARGS
> funcgraph-args (for the function graph tracer)
>
> config DYNAMIC_FTRACE
> - bool "enable/disable function tracing dynamically"
> + bool
> depends on FUNCTION_TRACER
> depends on HAVE_DYNAMIC_FTRACE
> default y
>
> base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
I have just given it a try but I'm getting the following errors:
../arch/riscv/kernel/ftrace.c: In function 'arch_ftrace_update_code':
../arch/riscv/kernel/ftrace.c:44:9: error: implicit declaration of
function 'ftrace_modify_all_code' [-Werror=implicit-function-declaration]
44 | ftrace_modify_all_code(command);
| ^~~~~~~~~~~~~~~~~~~~~~
../arch/riscv/kernel/ftrace.c: At top level:
../arch/riscv/kernel/ftrace.c:116:5: warning: no previous prototype for
'ftrace_make_call' [-Wmissing-prototypes]
116 | int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
| ^~~~~~~~~~~~~~~~
../arch/riscv/kernel/ftrace.c: In function 'ftrace_make_call':
../arch/riscv/kernel/ftrace.c:118:52: error: invalid use of undefined
type 'struct dyn_ftrace'
118 | unsigned long distance, orig_addr, pc = rec->ip -
MCOUNT_AUIPC_SIZE;
| ^~
../arch/riscv/kernel/ftrace.c:125:37: error: 'ftrace_caller' undeclared
(first use in this function); did you mean 'ftrace_kill'?
125 | orig_addr = (unsigned long)&ftrace_caller;
| ^~~~~~~~~~~~~
| ftrace_kill
../arch/riscv/kernel/ftrace.c:125:37: note: each undeclared identifier
is reported only once for each function it appears in
../arch/riscv/kernel/ftrace.c:128:24: error: 'FTRACE_ADDR' undeclared
(first use in this function)
128 | addr = FTRACE_ADDR;
| ^~~~~~~~~~~
../arch/riscv/kernel/ftrace.c: At top level:
../arch/riscv/kernel/ftrace.c:133:5: warning: no previous prototype for
'ftrace_make_nop' [-Wmissing-prototypes]
133 | int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
unsigned long addr)
| ^~~~~~~~~~~~~~~
../arch/riscv/kernel/ftrace.c: In function 'ftrace_make_nop':
../arch/riscv/kernel/ftrace.c:142:41: error: invalid use of undefined
type 'struct dyn_ftrace'
142 | if (patch_insn_write((void *)rec->ip, &nop4,
MCOUNT_NOP4_SIZE))
| ^~
../arch/riscv/kernel/ftrace.c: In function 'ftrace_init_nop':
../arch/riscv/kernel/ftrace.c:157:31: error: invalid use of undefined
type 'struct dyn_ftrace'
157 | unsigned long pc = rec->ip - MCOUNT_AUIPC_SIZE;
| ^~
CC drivers/nvme/target/io-cmd-bdev.o
../arch/riscv/kernel/ftrace.c:167:35: error: 'ftrace_caller' undeclared
(first use in this function); did you mean 'ftrace_kill'?
167 | offset = (unsigned long) &ftrace_caller - pc;
| ^~~~~~~~~~~~~
| ftrace_kill
../arch/riscv/kernel/ftrace.c: At top level:
../arch/riscv/kernel/ftrace.c:177:5: warning: no previous prototype for
'ftrace_update_ftrace_func' [-Wmissing-prototypes]
177 | int ftrace_update_ftrace_func(ftrace_func_t func)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection
2025-07-15 12:17 ` Alexandre Ghiti
@ 2025-07-16 11:07 ` Alexandre Ghiti
0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Ghiti @ 2025-07-16 11:07 UTC (permalink / raw)
To: ChenMiao, Linux RISCV
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Steven Rostedt,
Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Heiko Carstens,
Pu Lehui, linux-kernel, linux-trace-kernel
On 7/15/25 14:17, Alexandre Ghiti wrote:
> On 7/6/25 17:18, ChenMiao wrote:
>> From: chenmiao <chenmiao.ku@gmail.com>
>>
>> V1: The first version mainly involves modifications to the
>> configuration of the dynamic ftracer.
>>
>> Link
>> https://lore.kernel.org/all/f7e12c6d-892e-4ca3-9ef0-fbb524d04a48@ghiti.fr/
>>
>> V2: After a series of discussions, Steven concluded that only
>> supporting the dynamic ftracer would suffice. Alex also pointed
>> out that if only the dynamic ftracer needs to be supported, the
>> code related to the static ftracer would become obsolete and
>> turn into dead code. He had already done some preliminary work on this.
>>
>> Based on this, the modifications to the configuration were made,
>> and the dead code generated by the ftracer
>> (originally related to the static ftracer) was also removed.
>>
>> Link
>> https://lore.kernel.org/all/20250703115222.2d7c8cd5@batman.local.home/
>> Link
>> https://github.com/linux-riscv/linux/pull/556/commits/0481092a5bec3818658981c11f629e06e66382b3
>>
>> Signed-off-by: chenmiao <chenmiao.ku@gmail.com>
>> ---
>> arch/riscv/Kconfig | 3 +-
>> arch/riscv/include/asm/ftrace.h | 3 --
>> arch/riscv/kernel/ftrace.c | 11 +-----
>> arch/riscv/kernel/mcount.S | 64 ---------------------------------
>> kernel/trace/Kconfig | 2 +-
>> 5 files changed, 4 insertions(+), 79 deletions(-)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 36061f4732b7..95d24b19c466 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -97,8 +97,9 @@ config RISCV
>> select CLONE_BACKWARDS
>> select COMMON_CLK
>> select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
>> + select DYNAMIC_FTRACE if FUNCTION_TRACER
>> select EDAC_SUPPORT
>> - select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER &&
>> !DYNAMIC_FTRACE)
>> + select FRAME_POINTER if PERF_EVENTS
>> select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if
>> DYNAMIC_FTRACE
>> select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
>> select GENERIC_ARCH_TOPOLOGY
>> diff --git a/arch/riscv/include/asm/ftrace.h
>> b/arch/riscv/include/asm/ftrace.h
>> index 22ebea3c2b26..77ddb6dce0a8 100644
>> --- a/arch/riscv/include/asm/ftrace.h
>> +++ b/arch/riscv/include/asm/ftrace.h
>> @@ -49,7 +49,6 @@ struct dyn_arch_ftrace {
>> };
>> #endif
>> -#ifdef CONFIG_DYNAMIC_FTRACE
>> /*
>> * A general call in RISC-V is a pair of insts:
>> * 1) auipc: setting high-20 pc-related bits to ra register
>> @@ -237,6 +236,4 @@ static inline void
>> arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsi
>> #endif /* __ASSEMBLY__ */
>> -#endif /* CONFIG_DYNAMIC_FTRACE */
>> -
>> #endif /* _ASM_RISCV_FTRACE_H */
>> diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
>> index 4c6c24380cfd..93bad646d233 100644
>> --- a/arch/riscv/kernel/ftrace.c
>> +++ b/arch/riscv/kernel/ftrace.c
>> @@ -13,7 +13,6 @@
>> #include <asm/cacheflush.h>
>> #include <asm/text-patching.h>
>> -#ifdef CONFIG_DYNAMIC_FTRACE
>> unsigned long ftrace_call_adjust(unsigned long addr)
>> {
>> if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
>> @@ -191,13 +190,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>> return 0;
>> }
>> -#else /* CONFIG_DYNAMIC_FTRACE */
>> -unsigned long ftrace_call_adjust(unsigned long addr)
>> -{
>> - return addr;
>> -}
>> -#endif /* CONFIG_DYNAMIC_FTRACE */
>> -
>> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
>> int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>> unsigned long addr)
>> @@ -236,7 +228,6 @@ void prepare_ftrace_return(unsigned long *parent,
>> unsigned long self_addr,
>> *parent = return_hooker;
>> }
>> -#ifdef CONFIG_DYNAMIC_FTRACE
>> void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
>> struct ftrace_ops *op, struct ftrace_regs *fregs)
>> {
>> @@ -257,5 +248,5 @@ void ftrace_graph_func(unsigned long ip, unsigned
>> long parent_ip,
>> if (!function_graph_enter_regs(old, ip, frame_pointer, parent,
>> fregs))
>> *parent = return_hooker;
>> }
>> -#endif /* CONFIG_DYNAMIC_FTRACE */
>> +
>> #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
>> diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S
>> index da4a4000e57e..bb550c15f1c9 100644
>> --- a/arch/riscv/kernel/mcount.S
>> +++ b/arch/riscv/kernel/mcount.S
>> @@ -14,13 +14,6 @@
>> .text
>> - .macro SAVE_ABI_STATE
>> - addi sp, sp, -16
>> - REG_S s0, 0*SZREG(sp)
>> - REG_S ra, 1*SZREG(sp)
>> - addi s0, sp, 16
>> - .endm
>> -
>> /*
>> * The call to ftrace_return_to_handler would overwrite the return
>> * register if a0 was not saved.
>> @@ -34,12 +27,6 @@
>> addi s0, sp, FREGS_SIZE_ON_STACK
>> .endm
>> - .macro RESTORE_ABI_STATE
>> - REG_L ra, 1*SZREG(sp)
>> - REG_L s0, 0*SZREG(sp)
>> - addi sp, sp, 16
>> - .endm
>> -
>> .macro RESTORE_RET_ABI_STATE
>> REG_L ra, FREGS_RA(sp)
>> REG_L s0, FREGS_S0(sp)
>> @@ -49,10 +36,8 @@
>> .endm
>> SYM_TYPED_FUNC_START(ftrace_stub)
>> -#ifdef CONFIG_DYNAMIC_FTRACE
>> .global _mcount
>> .set _mcount, ftrace_stub
>> -#endif
>> ret
>> SYM_FUNC_END(ftrace_stub)
>> @@ -79,53 +64,4 @@ SYM_FUNC_START(return_to_handler)
>> SYM_FUNC_END(return_to_handler)
>> #endif
>> -#ifndef CONFIG_DYNAMIC_FTRACE
>> -SYM_FUNC_START(_mcount)
>> - la t4, ftrace_stub
>> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
>> - la t0, ftrace_graph_return
>> - REG_L t1, 0(t0)
>> - bne t1, t4, .Ldo_ftrace_graph_caller
>> -
>> - la t3, ftrace_graph_entry
>> - REG_L t2, 0(t3)
>> - la t6, ftrace_graph_entry_stub
>> - bne t2, t6, .Ldo_ftrace_graph_caller
>> -#endif
>> - la t3, ftrace_trace_function
>> - REG_L t5, 0(t3)
>> - bne t5, t4, .Ldo_trace
>> - ret
>> -
>> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
>> -/*
>> - * A pseudo representation for the function graph tracer:
>> - * prepare_to_return(&ra_to_caller_of_caller, ra_to_caller)
>> - */
>> -.Ldo_ftrace_graph_caller:
>> - addi a0, s0, -SZREG
>> - mv a1, ra
>> -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
>> - REG_L a2, -2*SZREG(s0)
>> -#endif
>> - SAVE_ABI_STATE
>> - call prepare_ftrace_return
>> - RESTORE_ABI_STATE
>> - ret
>> -#endif
>> -
>> -/*
>> - * A pseudo representation for the function tracer:
>> - * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller)
>> - */
>> -.Ldo_trace:
>> - REG_L a1, -SZREG(s0)
>> - mv a0, ra
>> -
>> - SAVE_ABI_STATE
>> - jalr t5
>> - RESTORE_ABI_STATE
>> - ret
>> -SYM_FUNC_END(_mcount)
>> -#endif
>> EXPORT_SYMBOL(_mcount)
>> diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
>> index a3f35c7d83b6..28afc6941e7a 100644
>> --- a/kernel/trace/Kconfig
>> +++ b/kernel/trace/Kconfig
>> @@ -275,7 +275,7 @@ config FUNCTION_TRACE_ARGS
>> funcgraph-args (for the function graph tracer)
>> config DYNAMIC_FTRACE
>> - bool "enable/disable function tracing dynamically"
>> + bool
>> depends on FUNCTION_TRACER
>> depends on HAVE_DYNAMIC_FTRACE
>> default y
>>
>> base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
>
>
> I have just given it a try but I'm getting the following errors:
>
> ../arch/riscv/kernel/ftrace.c: In function 'arch_ftrace_update_code':
> ../arch/riscv/kernel/ftrace.c:44:9: error: implicit declaration of
> function 'ftrace_modify_all_code' [-Werror=implicit-function-declaration]
> 44 | ftrace_modify_all_code(command);
> | ^~~~~~~~~~~~~~~~~~~~~~
> ../arch/riscv/kernel/ftrace.c: At top level:
> ../arch/riscv/kernel/ftrace.c:116:5: warning: no previous prototype
> for 'ftrace_make_call' [-Wmissing-prototypes]
> 116 | int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> | ^~~~~~~~~~~~~~~~
> ../arch/riscv/kernel/ftrace.c: In function 'ftrace_make_call':
> ../arch/riscv/kernel/ftrace.c:118:52: error: invalid use of undefined
> type 'struct dyn_ftrace'
> 118 | unsigned long distance, orig_addr, pc = rec->ip -
> MCOUNT_AUIPC_SIZE;
> | ^~
> ../arch/riscv/kernel/ftrace.c:125:37: error: 'ftrace_caller'
> undeclared (first use in this function); did you mean 'ftrace_kill'?
> 125 | orig_addr = (unsigned long)&ftrace_caller;
> | ^~~~~~~~~~~~~
> | ftrace_kill
> ../arch/riscv/kernel/ftrace.c:125:37: note: each undeclared identifier
> is reported only once for each function it appears in
> ../arch/riscv/kernel/ftrace.c:128:24: error: 'FTRACE_ADDR' undeclared
> (first use in this function)
> 128 | addr = FTRACE_ADDR;
> | ^~~~~~~~~~~
> ../arch/riscv/kernel/ftrace.c: At top level:
> ../arch/riscv/kernel/ftrace.c:133:5: warning: no previous prototype
> for 'ftrace_make_nop' [-Wmissing-prototypes]
> 133 | int ftrace_make_nop(struct module *mod, struct dyn_ftrace
> *rec, unsigned long addr)
> | ^~~~~~~~~~~~~~~
> ../arch/riscv/kernel/ftrace.c: In function 'ftrace_make_nop':
> ../arch/riscv/kernel/ftrace.c:142:41: error: invalid use of undefined
> type 'struct dyn_ftrace'
> 142 | if (patch_insn_write((void *)rec->ip, &nop4,
> MCOUNT_NOP4_SIZE))
> | ^~
> ../arch/riscv/kernel/ftrace.c: In function 'ftrace_init_nop':
> ../arch/riscv/kernel/ftrace.c:157:31: error: invalid use of undefined
> type 'struct dyn_ftrace'
> 157 | unsigned long pc = rec->ip - MCOUNT_AUIPC_SIZE;
> | ^~
> CC drivers/nvme/target/io-cmd-bdev.o
> ../arch/riscv/kernel/ftrace.c:167:35: error: 'ftrace_caller'
> undeclared (first use in this function); did you mean 'ftrace_kill'?
> 167 | offset = (unsigned long) &ftrace_caller - pc;
> | ^~~~~~~~~~~~~
> | ftrace_kill
> ../arch/riscv/kernel/ftrace.c: At top level:
> ../arch/riscv/kernel/ftrace.c:177:5: warning: no previous prototype
> for 'ftrace_update_ftrace_func' [-Wmissing-prototypes]
> 177 | int ftrace_update_ftrace_func(ftrace_func_t func)
I'll send a simple version this afternoon to fix the build error so that
we can merge it in 6.16. That will be a simple version that does not
remove the dead code.
I'll add your SoB, let me know if you want to work on removing the dead
code in a follow-up patch targeting 6.17.
Thanks,
Alex
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-07-16 11:07 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-06 15:18 [PATCH V2] riscv: ftrace: Fix the logic issue in DYNAMIC_FTRACE selection ChenMiao
2025-07-09 1:08 ` kernel test robot
2025-07-10 11:53 ` Alexandre Ghiti
2025-07-10 12:34 ` Miao Chen
2025-07-10 14:32 ` Alexandre Ghiti
2025-07-10 15:56 ` Miao Chen
2025-07-11 7:55 ` Alexandre Ghiti
2025-07-11 8:24 ` Miao Chen
2025-07-15 8:59 ` Alexandre Ghiti
2025-07-15 12:17 ` Alexandre Ghiti
2025-07-16 11:07 ` Alexandre Ghiti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).