* [PATCH] riscv: signal: refactor debug logging to use macros
@ 2026-03-30 4:34 Austin Kim
2026-03-31 3:36 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Austin Kim @ 2026-03-30 4:34 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Alexandre Ghiti
Cc: linux-riscv, linux-kernel, austindh.kim
From: Austin Kim <austin.kim@lge.com>
Replace manual #if DEBUG_SIG blocks with a unified DEBUGP macro.
This will improve code readability.
Signed-off-by: Austin Kim <austin.kim@lge.com>
---
arch/riscv/kernel/compat_signal.c | 10 ++++++----
arch/riscv/kernel/signal.c | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/arch/riscv/kernel/compat_signal.c b/arch/riscv/kernel/compat_signal.c
index 6ec4e3425..c82235be7 100644
--- a/arch/riscv/kernel/compat_signal.c
+++ b/arch/riscv/kernel/compat_signal.c
@@ -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;
}
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 59784dc11..1d7fddcff 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -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;
}
--
2.34.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] riscv: signal: refactor debug logging to use macros
2026-03-30 4:34 [PATCH] riscv: signal: refactor debug logging to use macros Austin Kim
@ 2026-03-31 3:36 ` Michael Ellerman
2026-03-31 6:51 ` Austin Kim
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2026-03-31 3:36 UTC (permalink / raw)
To: Austin Kim, Paul Walmsley, Palmer Dabbelt, Alexandre Ghiti
Cc: linux-riscv, linux-kernel
On 30/3/2026 15:34, Austin Kim wrote:
> From: Austin Kim <austin.kim@lge.com>
>
> Replace manual #if DEBUG_SIG blocks with a unified DEBUGP macro.
> This will improve code readability.
>
> Signed-off-by: Austin Kim <austin.kim@lge.com>
> ---
> arch/riscv/kernel/compat_signal.c | 10 ++++++----
> arch/riscv/kernel/signal.c | 10 ++++++----
> 2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/arch/riscv/kernel/compat_signal.c b/arch/riscv/kernel/compat_signal.c
> index 6ec4e3425..c82235be7 100644
> --- a/arch/riscv/kernel/compat_signal.c
> +++ b/arch/riscv/kernel/compat_signal.c
> @@ -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;
> }
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] riscv: signal: refactor debug logging to use macros
2026-03-31 3:36 ` Michael Ellerman
@ 2026-03-31 6:51 ` Austin Kim
0 siblings, 0 replies; 3+ messages in thread
From: Austin Kim @ 2026-03-31 6:51 UTC (permalink / raw)
To: Michael Ellerman
Cc: Paul Walmsley, Palmer Dabbelt, Alexandre Ghiti, linux-riscv,
linux-kernel
Hello, Michael
2026년 3월 31일 (화) PM 12:36, Michael Ellerman <mpe@kernel.org>님이 작성:
>
> On 30/3/2026 15:34, Austin Kim wrote:
> > From: Austin Kim <austin.kim@lge.com>
> >
> > Replace manual #if DEBUG_SIG blocks with a unified DEBUGP macro.
> > This will improve code readability.
> >
> > Signed-off-by: Austin Kim <austin.kim@lge.com>
> > ---
> > arch/riscv/kernel/compat_signal.c | 10 ++++++----
> > arch/riscv/kernel/signal.c | 10 ++++++----
> > 2 files changed, 12 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/compat_signal.c b/arch/riscv/kernel/compat_signal.c
> > index 6ec4e3425..c82235be7 100644
> > --- a/arch/riscv/kernel/compat_signal.c
> > +++ b/arch/riscv/kernel/compat_signal.c
> > @@ -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;
> > }
> Is there any reason not to use pr_devel()?
>
> Or pr_debug() if enabling it at runtime is desirable (with
> CONFIG_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
>
> cheers
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-31 6:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 4:34 [PATCH] riscv: signal: refactor debug logging to use macros Austin Kim
2026-03-31 3:36 ` Michael Ellerman
2026-03-31 6:51 ` Austin Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox