From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04AE42737E1; Mon, 3 Nov 2025 13:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762177952; cv=none; b=jtZhU3VDoIpXQWSn+cBKoKG726tsN1G24jMMrSXa0zc6gka0Q6Xr2qOf43SJliQIJ+uLL0gYMatoC4pT2iCLgzGWEKNtie4AFyPxU7z/at6ptBkvPmhQ5tdxrBOYzgkP6C4FTuaRyTe9ms0gO4APQVhEMqF69Ch/LpvBmmxNRCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762177952; c=relaxed/simple; bh=LnIXWhB4Cj25CtLtbkxdXBEJn5oy2Pmquj/q2xJaGeo=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Z+aObB7anfmqP1ndS6jswf8akQKsUytcMEHk8CUT0JV0rfueuHG94n+nLOmRf/eVwvO7zsqVBXknnPLnX25cEi7lxPSnf3FchEIO7XdqhKxY+v1Eze9Gm9PTwT5TCPipswwyks1iaaIMx++Vc9MxhB5d6AbP1+JXu9L+vpTYh58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N1evdoJB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N1evdoJB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A049BC4CEE7; Mon, 3 Nov 2025 13:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762177951; bh=LnIXWhB4Cj25CtLtbkxdXBEJn5oy2Pmquj/q2xJaGeo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=N1evdoJBP+xR1+ihgvW3cL4M+Y3RsyN60QP/c06iS/qtugdx74TT5UAaHwJd4nfv1 bsAe25z7oj3H2G2M2lfXI2x9m5o4ZtCxURAPkQ6KdFs+UkbvP9pESRy8O67ls+x4vg TyfsyaxA2IiWcgJ8htc6uSpEmjad/l8dAKZWkXyfWhmv6aG9kys6wJmehTKDe7Wjhj IOYQU5zuxHM1UIK83qYLVvcGLX86j82UhxhSCgdMsyhbYdgl/9tvWO/jrzbilszPuM O7qePIubGKo34dTbn6FzjwFJ2/8KaNFZ/t3Sp/pKb9tE0EkV+EAAm/TMtzEaZGTIWJ o7IfKFZVF60Ew== Date: Mon, 3 Nov 2025 22:52:27 +0900 From: Masami Hiramatsu (Google) To: Menglong Dong Cc: rostedt@goodmis.org, jolsa@kernel.org, mathieu.desnoyers@efficios.com, jiang.biao@linux.dev, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH v3] tracing: fprobe: use ftrace if CONFIG_DYNAMIC_FTRACE_WITH_ARGS Message-Id: <20251103225227.b8a44e718ddd9515a9960e51@kernel.org> In-Reply-To: <20251103063434.47388-1-dongml2@chinatelecom.cn> References: <20251103063434.47388-1-dongml2@chinatelecom.cn> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Nov 2025 14:34:34 +0800 Menglong Dong wrote: > For now, we will use ftrace for the fprobe if fp->exit_handler not exists > and CONFIG_DYNAMIC_FTRACE_WITH_REGS is enabled. > > However, CONFIG_DYNAMIC_FTRACE_WITH_REGS is not supported by some arch, > such as arm. What we need in the fprobe is the function arguments, so we > can use ftrace for fprobe if CONFIG_DYNAMIC_FTRACE_WITH_ARGS is enabled. > > Therefore, use ftrace if CONFIG_DYNAMIC_FTRACE_WITH_REGS or > CONFIG_DYNAMIC_FTRACE_WITH_ARGS enabled. > Looks good to me. Thanks! > Signed-off-by: Menglong Dong > --- > v3: > - fix the build warning when CONFIG_MODULES not enabled > > v2: > - remove the definition of FPROBE_USE_FTRACE > --- > kernel/trace/fprobe.c | 32 ++++++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 10 deletions(-) > > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > index ecd623eef68b..0b1ee8e585f2 100644 > --- a/kernel/trace/fprobe.c > +++ b/kernel/trace/fprobe.c > @@ -44,6 +44,7 @@ > static struct hlist_head fprobe_table[FPROBE_TABLE_SIZE]; > static struct rhltable fprobe_ip_table; > static DEFINE_MUTEX(fprobe_mutex); > +static struct fgraph_ops fprobe_graph_ops; > > static u32 fprobe_node_hashfn(const void *data, u32 len, u32 seed) > { > @@ -254,7 +255,7 @@ static inline int __fprobe_kprobe_handler(unsigned long ip, unsigned long parent > return ret; > } > > -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > +#if defined(CONFIG_DYNAMIC_FTRACE_WITH_ARGS) || defined(CONFIG_DYNAMIC_FTRACE_WITH_REGS) > /* 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 +296,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, > }; > static int fprobe_ftrace_active; > > @@ -335,6 +336,15 @@ static bool fprobe_is_ftrace(struct fprobe *fp) > { > return !fp->exit_handler; > } > + > +#ifdef CONFIG_MODULES > +static void fprobe_set_ips(unsigned long *ips, unsigned int cnt, int remove, > + int reset) > +{ > + ftrace_set_filter_ips(&fprobe_graph_ops.ops, ips, cnt, remove, reset); > + ftrace_set_filter_ips(&fprobe_ftrace_ops, ips, cnt, remove, reset); > +} > +#endif > #else > static int fprobe_ftrace_add_ips(unsigned long *addrs, int num) > { > @@ -349,7 +359,15 @@ static bool fprobe_is_ftrace(struct fprobe *fp) > { > return false; > } > + > +#ifdef CONFIG_MODULES > +static void fprobe_set_ips(unsigned long *ips, unsigned int cnt, int remove, > + int reset) > +{ > + ftrace_set_filter_ips(&fprobe_graph_ops.ops, ips, cnt, remove, reset); > +} > #endif > +#endif /* !CONFIG_DYNAMIC_FTRACE_WITH_ARGS && !CONFIG_DYNAMIC_FTRACE_WITH_REGS */ > > /* fgraph_ops callback, this processes fprobes which have exit_handler. */ > static int fprobe_fgraph_entry(struct ftrace_graph_ent *trace, struct fgraph_ops *gops, > @@ -596,14 +614,8 @@ static int fprobe_module_callback(struct notifier_block *nb, > } while (node == ERR_PTR(-EAGAIN)); > rhashtable_walk_exit(&iter); > > - if (alist.index > 0) { > - ftrace_set_filter_ips(&fprobe_graph_ops.ops, > - alist.addrs, alist.index, 1, 0); > -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > - ftrace_set_filter_ips(&fprobe_ftrace_ops, > - alist.addrs, alist.index, 1, 0); > -#endif > - } > + if (alist.index > 0) > + fprobe_set_ips(alist.addrs, alist.index, 1, 0); > mutex_unlock(&fprobe_mutex); > > kfree(alist.addrs); > -- > 2.51.2 > -- Masami Hiramatsu (Google)