riscv: signal: refactor debug logging to use macros
PATCH 1/1 riscv: signal: refactor debug logging to use macros
From: Austin Kim <[email protected]>
Replace manual #if DEBUG_SIG blocks with a unified DEBUGP macro. This will improve code readability.
--- arch/riscv/kernel/compat_signal.c | 10 ++++++---- arch/riscv/kernel/signal.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)
arch/riscv/kernel/compat_signal.c +6 -4
@@ -12,7 +12,11 @@#include <asm/ucontext.h> #include <asm/vdso.h> -#define COMPAT_DEBUG_SIG 0 +#ifdef DEBUG_SIG +# define DEBUGP(fmt, args...) pr_info("%s: " fmt, __func__, ##args) +#else +# define DEBUGP(fmt, args...) +#endif struct compat_sigcontext {struct compat_user_regs_struct sc_regs;
@@ -233,11 +237,9 @@ int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, regs->a1 = (unsigned long )(&frame->info);/* a1: siginfo pointer */ regs->a2 = (unsigned long )(&frame->uc);/* a2: ucontext pointer */ -#if COMPAT_DEBUG_SIG -pr_info ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , +DEBUGP ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , current->comm,task_pid_nr (current), ksig->sig, (void *)regs->epc, (void *)regs->ra, frame); -#endif return 0 ; }
arch/riscv/kernel/signal.c +6 -4
@@ -30,7 +30,11 @@ extern u32 __user_rt_sigreturn[2];static size_t riscv_v_sc_size__ro_after_init ;static size_t riscv_zicfiss_sc_size__ro_after_init ; -#define DEBUG_SIG 0 +#ifdef DEBUG_SIG +# define DEBUGP(fmt, args...) pr_info("%s: " fmt, __func__, ##args) +#else +# define DEBUGP(fmt, args...) +#endif struct rt_sigframe {struct siginfo info;
@@ -471,11 +475,9 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, regs->a1 = (unsigned long )(&frame->info);/* a1: siginfo pointer */ regs->a2 = (unsigned long )(&frame->uc);/* a2: ucontext pointer */ -#if DEBUG_SIG -pr_info ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , +DEBUGP ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , current->comm,task_pid_nr (current), ksig->sig, (void *)regs->epc, (void *)regs->ra, frame); -#endif return 0 ; }
Signature · 1 line
2.34.1
Quoted 31 lines · Austin Kim
From: Austin Kim <[email protected]>
Replace manual #if
DEBUG_SIGblocks with a unified DEBUGP macro. This will improve code readability.Signed-off-by Austin Kim <[email protected]>--- arch/riscv/kernel/compat_signal.c | 10 ++++++---- arch/riscv/kernel/signal.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)arch/riscv/kernel/compat_signal.c +5
-1@@ -12,7 +12,11 @@#include <asm/ucontext.h> #include <asm/vdso.h> -#define COMPAT_DEBUG_SIG 0 +#ifdef DEBUG_SIG +# define DEBUGP(fmt, args...) pr_info("%s: " fmt, __func__, ##args) +#else +# define DEBUGP(fmt, args...) +#endif struct compat_sigcontext {struct compat_user_regs_struct sc_regs;@@ -233,11 +237,9 @@ int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, regs->a1 = (unsigned long )(&frame->info);/* a1: siginfo pointer */ regs->a2 = (unsigned long )(&frame->uc);/* a2: ucontext pointer */
arch/riscv/kernel/compat_signal.c int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, · line 245
Quoted 10 lines
arch/riscv/kernel/compat_signal.c +1
-3-#if COMPAT_DEBUG_SIG -pr_info ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , +DEBUGP ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , current->comm,task_pid_nr (current), ksig->sig, (void *)regs->epc, (void *)regs->ra, frame); -#endif return 0 ; }
Is there any reason not to use pr_devel()?
Or pr_debug() if enabling it at runtime is desirable (with CONFIG_DYNAMIC_DEBUG=y).
cheers
Hello, Michael
2026년 3월 31일 (화) PM 12:36, Michael Ellerman <[email protected]>님이 작성:
Quoted 41 lines · Austin Kim
Quoted 39 lines
From: Austin Kim <[email protected]>
Replace manual #if
DEBUG_SIGblocks with a unified DEBUGP macro. This will improve code readability.Signed-off-by Austin Kim <[email protected]>--- arch/riscv/kernel/compat_signal.c | 10 ++++++---- arch/riscv/kernel/signal.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)arch/riscv/kernel/compat_signal.c +6
-4@@ -12,7 +12,11 @@#include <asm/ucontext.h> #include <asm/vdso.h> -#define COMPAT_DEBUG_SIG 0 +#ifdef DEBUG_SIG +# define DEBUGP(fmt, args...) pr_info("%s: " fmt, __func__, ##args) +#else +# define DEBUGP(fmt, args...) +#endif struct compat_sigcontext {struct compat_user_regs_struct sc_regs;@@ -233,11 +237,9 @@ int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, regs->a1 = (unsigned long )(&frame->info);/* a1: siginfo pointer */ regs->a2 = (unsigned long )(&frame->uc);/* a2: ucontext pointer */ -#if COMPAT_DEBUG_SIG -pr_info ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , +DEBUGP ("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n" , current->comm,task_pid_nr (current), ksig->sig, (void *)regs->epc, (void *)regs->ra, frame); -#endif
Quoted 6 lines
arch/riscv/kernel/compat_signal.c int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, · line 245
Quoted 2 lines
arch/riscv/kernel/compat_signal.c +0
-0return 0 ; }Is there any reason not to use
pr_devel()?Or
pr_debug()if enabling it at runtime is desirable (withCONFIG_DYNAMIC_DEBUG=y).
Thank you for the idea.pr_debug() is another good option, as it can be enabled with CONFIG_DYNAMIC_DEBUG=y.
The code will look simpler this way. I will propose another patch.
BR,
Austin Kim
Quoted 2 lines
cheers