From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Florent Revest <revest@chromium.org>,
Mark Rutland <mark.rutland@arm.com>,
Will Deacon <will@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
bpf@vger.kernel.org
Subject: Re: [PATCH v5 2/9] tracing/probes: Add fprobe events for tracing function entry and exit.
Date: Fri, 21 Apr 2023 08:41:06 +0900 [thread overview]
Message-ID: <20230421084106.5a02844971e18cdd8ad163be@kernel.org> (raw)
In-Reply-To: <20230420184932.pgv5wiqqt4fzswdk@MacBook-Pro-6.local>
On Thu, 20 Apr 2023 11:49:32 -0700
Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
> On Thu, Apr 20, 2023 at 08:25:50PM +0900, Masami Hiramatsu (Google) wrote:
> > +static int fentry_perf_func(struct trace_fprobe *tf, unsigned long entry_ip,
> > + struct pt_regs *regs)
> > +{
> > + struct trace_event_call *call = trace_probe_event_call(&tf->tp);
> > + struct fentry_trace_entry_head *entry;
> > + struct hlist_head *head;
> > + int size, __size, dsize;
> > + int rctx;
> > +
> > + if (bpf_prog_array_valid(call)) {
> > + unsigned long orig_ip = instruction_pointer(regs);
> > + int ret;
> > +
> > + ret = trace_call_bpf(call, regs);
>
> Please do not call bpf from fprobe.
> There is no use case for it.
OK.
>
> > +
> > + /*
> > + * We need to check and see if we modified the pc of the
> > + * pt_regs, and if so return 1 so that we don't do the
> > + * single stepping.
> > + */
> > + if (orig_ip != instruction_pointer(regs))
> > + return 1;
> > + if (!ret)
> > + return 0;
> > + }
> > +
> > + head = this_cpu_ptr(call->perf_events);
> > + if (hlist_empty(head))
> > + return 0;
> > +
> > + dsize = __get_data_size(&tf->tp, regs);
> > + __size = sizeof(*entry) + tf->tp.size + dsize;
> > + size = ALIGN(__size + sizeof(u32), sizeof(u64));
> > + size -= sizeof(u32);
> > +
> > + entry = perf_trace_buf_alloc(size, NULL, &rctx);
> > + if (!entry)
> > + return 0;
> > +
> > + entry->ip = entry_ip;
> > + memset(&entry[1], 0, dsize);
> > + store_trace_args(&entry[1], &tf->tp, regs, sizeof(*entry), dsize);
> > + perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs,
> > + head, NULL);
> > + return 0;
> > +}
> > +NOKPROBE_SYMBOL(fentry_perf_func);
> > +
> > +static void
> > +fexit_perf_func(struct trace_fprobe *tf, unsigned long entry_ip,
> > + unsigned long ret_ip, struct pt_regs *regs)
> > +{
> > + struct trace_event_call *call = trace_probe_event_call(&tf->tp);
> > + struct fexit_trace_entry_head *entry;
> > + struct hlist_head *head;
> > + int size, __size, dsize;
> > + int rctx;
> > +
> > + if (bpf_prog_array_valid(call) && !trace_call_bpf(call, regs))
> > + return;
>
> Same here.
> These two parts look like copy-paste from kprobes.
> I suspect this code wasn't tested at all.
OK, I missed to test that bpf part. I thought bpf could be appended to
any "trace-event" (looks like trace-event), isn't it?
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2023-04-20 23:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 11:25 [PATCH v5 0/9] tracing: Add fprobe events Masami Hiramatsu (Google)
2023-04-20 11:25 ` [PATCH v5 1/9] fprobe: Pass return address to the handlers Masami Hiramatsu (Google)
2023-04-20 11:25 ` [PATCH v5 2/9] tracing/probes: Add fprobe events for tracing function entry and exit Masami Hiramatsu (Google)
2023-04-20 18:49 ` Alexei Starovoitov
2023-04-20 23:41 ` Masami Hiramatsu [this message]
2023-04-20 23:46 ` Alexei Starovoitov
2023-04-21 5:38 ` Masami Hiramatsu
2023-04-21 16:31 ` Alexei Starovoitov
2023-04-24 4:24 ` Masami Hiramatsu
2023-04-20 11:26 ` [PATCH v5 3/9] selftests/ftrace: Add fprobe related testcases Masami Hiramatsu (Google)
2023-04-20 11:26 ` [PATCH v5 4/9] tracing/probes: Add tracepoint support on fprobe_event Masami Hiramatsu (Google)
2023-04-21 0:18 ` kernel test robot
2023-04-23 7:41 ` Jiri Olsa
2023-04-23 13:37 ` Masami Hiramatsu
2023-04-24 7:38 ` Jiri Olsa
2023-04-20 11:26 ` [PATCH v5 5/9] tracing/probes: Move event parameter fetching code to common parser Masami Hiramatsu (Google)
2023-04-20 11:26 ` [PATCH v5 6/9] tracing/probes: Support function parameters if BTF is available Masami Hiramatsu (Google)
2023-04-20 19:08 ` Alan Maguire
2023-04-21 0:56 ` Masami Hiramatsu
2023-04-21 1:01 ` Alexei Starovoitov
2023-04-20 11:26 ` [PATCH v5 7/9] tracing/probes: Add $$args meta argument for all function args Masami Hiramatsu (Google)
2023-04-20 11:26 ` [PATCH v5 8/9] selftests/ftrace: Add tracepoint probe test case Masami Hiramatsu (Google)
2023-04-20 11:26 ` [PATCH v5 9/9] selftests/ftrace: Add BTF arguments test cases Masami Hiramatsu (Google)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230421084106.5a02844971e18cdd8ad163be@kernel.org \
--to=mhiramat@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=revest@chromium.org \
--cc=rostedt@goodmis.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).