[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240127002414.660f2e477d210bc54ca4df89@kernel.org>
Date: Sat, 27 Jan 2024 00:24:14 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Jiri Olsa <olsajiri@...il.com>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, Steven Rostedt
<rostedt@...dmis.org>, Florent Revest <revest@...omium.org>,
linux-trace-kernel@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, bpf <bpf@...r.kernel.org>, Sven
Schnelle <svens@...ux.ibm.com>, Alexei Starovoitov <ast@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Daniel Borkmann
<daniel@...earbox.net>, Alan Maguire <alan.maguire@...cle.com>, Mark
Rutland <mark.rutland@....com>, Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>, Guo Ren <guoren@...nel.org>
Subject: Re: [PATCH v6 32/36] fprobe: Rewrite fprobe on function-graph
tracer
On Thu, 25 Jan 2024 16:11:51 +0100
Jiri Olsa <olsajiri@...il.com> wrote:
> On Fri, Jan 12, 2024 at 07:17:06PM +0900, Masami Hiramatsu (Google) wrote:
>
> SNIP
>
> > * Register @fp to ftrace for enabling the probe on the address given by @addrs.
> > @@ -298,23 +547,27 @@ EXPORT_SYMBOL_GPL(register_fprobe);
> > */
> > int register_fprobe_ips(struct fprobe *fp, unsigned long *addrs, int num)
> > {
> > - int ret;
> > -
> > - if (!fp || !addrs || num <= 0)
> > - return -EINVAL;
> > -
> > - fprobe_init(fp);
> > + struct fprobe_hlist *hlist_array;
> > + int ret, i;
> >
> > - ret = ftrace_set_filter_ips(&fp->ops, addrs, num, 0, 0);
> > + ret = fprobe_init(fp, addrs, num);
> > if (ret)
> > return ret;
> >
> > - ret = fprobe_init_rethook(fp, num);
> > - if (!ret)
> > - ret = register_ftrace_function(&fp->ops);
> > + mutex_lock(&fprobe_mutex);
> > +
> > + hlist_array = fp->hlist_array;
> > + ret = fprobe_graph_add_ips(addrs, num);
>
> so fprobe_graph_add_ips registers the ftrace_ops and actually starts
> the tracing.. and in the code below we prepare fprobe data that is
> checked in the ftrace_ops callback.. should we do this this earlier
> before calling fprobe_graph_add_ips/register_ftrace_graph?
Good catch! but I think this is safe because fprobe_entry() checks
the fprobe_ip_table[] (insert_fprobe_node updates it) at first.
Thus until the hash table is updated, fprobe_entry() handler will
return soon.
----
static int fprobe_entry(unsigned long func, unsigned long ret_ip,
struct ftrace_regs *fregs, struct fgraph_ops *gops)
{
struct fprobe_hlist_node *node, *first;
unsigned long *fgraph_data = NULL;
unsigned long header;
int reserved_words;
struct fprobe *fp;
int used, ret;
if (WARN_ON_ONCE(!fregs))
return 0;
first = node = find_first_fprobe_node(func);
if (unlikely(!first))
return 0;
----
The fprobe_table (add_fprobe_hash updates it) is used for return handler,
that will be used by fprobe_return().
So I think it should be safe too. Or I might missed something?
Thank you,
>
> jirka
>
> > + if (!ret) {
> > + add_fprobe_hash(fp);
> > + for (i = 0; i < hlist_array->size; i++)
> > + insert_fprobe_node(&hlist_array->array[i]);
> > + }
> > + mutex_unlock(&fprobe_mutex);
> >
> > if (ret)
> > fprobe_fail_cleanup(fp);
> > +
> > return ret;
> > }
> > EXPORT_SYMBOL_GPL(register_fprobe_ips);
> > @@ -352,14 +605,13 @@ EXPORT_SYMBOL_GPL(register_fprobe_syms);
>
> SNIP
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists