Re: [RFC PATCH v1 1/1] tracing/kprobe: Add multi-probe support for 'perf_kprobe' PMU
From: Jiri Olsa
Date: Tue Aug 22 2023 - 09:13:43 EST
On Mon, Aug 21, 2023 at 02:24:06PM +0200, Francis Laniel wrote:
> Hi.
>
> Le dimanche 20 août 2023, 22:34:40 CEST Jiri Olsa a écrit :
> > On Sat, Aug 19, 2023 at 10:11:05AM +0900, Masami Hiramatsu wrote:
> >
> > SNIP
> >
> > > > > > > > + func_addr = kallsyms_lookup_name(func);
> > > > > > > > + for (i = 0; i < array.size; i++) {
> > > > > > > > + struct trace_kprobe *tk_same_name;
> > > > > > > > + unsigned long address;
> > > > > > > > +
> > > > > > > > + address = array.addrs[i];
> > > > > > > > + /* Skip the function address as we already
> registered it. */
> > > > > > > > + if (address == func_addr)
> > > > > > > > + continue;
> > > > > > > > +
> > > > > > > > + /*
> > > > > > > > + * alloc_trace_kprobe() first considers symbol name,
> so we
> > > > > > > > set
> > > > > > > > + * this to NULL to allocate this kprobe on the given
> address.
> > > > > > > > + */
> > > > > > > > + tk_same_name =
> alloc_trace_kprobe(KPROBE_EVENT_SYSTEM, event,
> > > > > > > > + (void *)address, NULL,
> offs,
> > > > > > > > + 0 /* maxactive */,
> > > > > > > > + 0 /* nargs */,
> is_return);
> > > > > > > > +
> > > > > > > > + if (IS_ERR(tk_same_name)) {
> > > > > > > > + ret = -ENOMEM;
> > > > > > > > + goto error_free;
> > > > > > > > + }
> > > > > > > > +
> > > > > > > > + init_trace_event_call(tk_same_name);
> > > > > > > > +
> > > > > > > > + if (traceprobe_set_print_fmt(&tk_same_name->tp,
> ptype) < 0) {
> > > > > > > > + ret = -ENOMEM;
> >
> > also are we leaking tk_same_name in here?
> >
> > > > > > > > + goto error_free;
> > > > > > > > + }
> > > > > > > > +
> > > > > > > > + ret = append_trace_kprobe(tk_same_name, tk);
> > > > > > > > + if (ret)
> >
> > and here?
>
> Good catch!
> Do you know if the appended probes are automatically freed? If so, can you
> please indicate which function handles this?
hum, I don't see the release code going through the list of appended probes,
so I wonder you need to somehow do that in destroy_local_trace_kprobe
jirka