Re: [PATCH] tracing: fprobe: use ftrace if CONFIG_DYNAMIC_FTRACE_WITH_ARGS
From: Menglong Dong
Date: Wed Oct 29 2025 - 10:09:51 EST
On Wed, Oct 29, 2025 at 10:00 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Wed, 29 Oct 2025 10:15:14 +0800
> Menglong Dong <menglong8.dong@xxxxxxxxx> wrote:
>
> > -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> > +#if defined(CONFIG_DYNAMIC_FTRACE_WITH_ARGS) || defined(CONFIG_DYNAMIC_FTRACE_WITH_REGS)
> > +#define FPROBE_USE_FTRACE
> > +#endif
> > +
> > +#ifdef FPROBE_USE_FTRACE
> > /* ftrace_ops callback, this processes fprobes which have only entry_handler. */
> > static void fprobe_ftrace_entry(unsigned long ip, unsigned long parent_ip,
> > struct ftrace_ops *ops, struct ftrace_regs *fregs)
> > @@ -295,7 +299,7 @@ NOKPROBE_SYMBOL(fprobe_ftrace_entry);
> >
> > static struct ftrace_ops fprobe_ftrace_ops = {
> > .func = fprobe_ftrace_entry,
> > - .flags = FTRACE_OPS_FL_SAVE_REGS,
> > + .flags = FTRACE_OPS_FL_SAVE_ARGS,
>
> If an arch defines DYNAMIC_FTRACE_WITH_REGS but not
> DYNAMIC_FTRACE_WITH_ARGS, then this will fail to build.
Hi, it won't fail here, as FTRACE_OPS_FL_SAVE_ARGS has
following definition:
#ifndef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
#define FTRACE_OPS_FL_SAVE_ARGS FTRACE_OPS_FL_SAVE_REGS
#else
#define FTRACE_OPS_FL_SAVE_ARGS 0
#endif
Which means it will fallback to FTRACE_OPS_FL_SAVE_REGS if
CONFIG_DYNAMIC_FTRACE_WITH_ARGS not defined.
I have commit a PR to the bpf CI, and all testings passed and no
building error happens:
https://github.com/kernel-patches/bpf/pull/10110
Thanks!
Menglong Dong
>
> > };
> > static int fprobe_ftrace_active;
> >
>
> Perhaps do:
>
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
> # define FPROBE_FTRACE_TYPE FTRACE_OPS_FL_SAVE_ARGS
> #elif defined(CONFIG_DYNAMIC_FTRACE_WITH_REGS)
> # define FPROBE_FTRACE_TYPE FTRACE_OPS_FL_SAVE_REGS,
> #endif
>
> #ifdef FPROBE_FTRACE_TYPE
> [..]
> static struct ftrace_ops fprobe_ftrace_ops = {
> .func = fprobe_ftrace_entry,
> .flags = FTRACE_FTRACE_TYPE,
>
>
> ?
>
> -- Steve