From: Steven Rostedt <rostedt@goodmis.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: Re: [RFC bpf-next 4/4] selftests/bpf: Add attach bench test
Date: Thu, 28 Apr 2022 16:05:19 -0400 [thread overview]
Message-ID: <20220428160519.04cc40c0@gandalf.local.home> (raw)
In-Reply-To: <CAADnVQKi+4oBt2C__qz7QoHqTtXYLUjaqwTNFoSE=up9c9k4cA@mail.gmail.com>
On Thu, 28 Apr 2022 11:59:55 -0700
Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
> > The weak function gets a call to ftrace, but it still gets compiled into
> > vmlinux but its symbol is dropped due to it being overridden. Thus, the
> > mcount_loc finds this call to fentry, and maps it to the symbol that is
> > before it, which just happened to be __bpf_tramp_exit.
>
> Ouch. That _is_ a bug in recordmocount.
Exactly HOW is it a bug in recordmcount?
The job of recordmcount is to create a section of all the locations that
call fentry. That is EXACTLY what it did. No bug there! It did its job.
In fact, recordmcount probably didn't even get called. If you see this on
x86 with gcc version greater than 8 (which I do), recordmcount is not even
used. gcc creates this section internally instead.
>
> > I made that weak function "notrace" and the __bpf_tramp_exit disappeared
> > from the available_filter_functions list.
>
> That's a hack. We cannot rely on such hacks for all weak functions.
Then don't do anything. The only thing this bug causes is perhaps some
confusion, because functions before weak functions that are overridden will
be listed incorrectly in the available_filter_functions file. And that's
because of the way it is created with respect to kallsyms.
If you enable __bpf_tramp_exit, it will not do anything to that function.
What it will do is enable the location inside of the weak function that no
longer has its symbol shown.
One solution is to simply get the end of the function that is provided by
kallsyms to make sure the fentry call location is inside the function, and
if it is not, then not show that function in available_filter_functions but
instead show something like "** unnamed function **" or whatever.
I could write a patch to do that when I get the time. But because the only
issue that this causes is some confusion among the users and does not cause
any issue with functionality, then it is low priority.
-- Steve
next prev parent reply other threads:[~2022-04-28 20:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 12:52 [RFC bpf-next 0/4] bpf: Speed up symbol resolving in kprobe multi link Jiri Olsa
2022-04-07 12:52 ` [RFC bpf-next 1/4] kallsyms: Add kallsyms_lookup_names function Jiri Olsa
2022-04-08 0:57 ` Masami Hiramatsu
2022-04-13 7:27 ` Jiri Olsa
2022-04-08 23:19 ` Alexei Starovoitov
2022-04-09 20:24 ` Jiri Olsa
2022-04-12 20:46 ` Jiri Olsa
2022-04-15 0:47 ` Masami Hiramatsu
2022-04-15 22:39 ` Jiri Olsa
2022-04-11 22:15 ` Andrii Nakryiko
2022-04-12 20:28 ` Jiri Olsa
2022-04-07 12:52 ` [RFC bpf-next 2/4] fprobe: Resolve symbols with kallsyms_lookup_names Jiri Olsa
2022-04-08 0:58 ` Masami Hiramatsu
2022-04-07 12:52 ` [RFC bpf-next 3/4] bpf: Resolve symbols with kallsyms_lookup_names for kprobe multi link Jiri Olsa
2022-04-08 23:26 ` Alexei Starovoitov
2022-04-09 20:24 ` Jiri Olsa
2022-04-11 22:15 ` Andrii Nakryiko
2022-04-11 22:15 ` Andrii Nakryiko
2022-04-12 18:42 ` Jiri Olsa
2022-04-07 12:52 ` [RFC bpf-next 4/4] selftests/bpf: Add attach bench test Jiri Olsa
2022-04-11 22:15 ` Andrii Nakryiko
2022-04-12 0:49 ` Masami Hiramatsu
2022-04-12 22:51 ` Andrii Nakryiko
2022-04-16 14:21 ` Masami Hiramatsu
2022-04-18 17:33 ` Steven Rostedt
2022-04-28 13:58 ` Steven Rostedt
2022-04-28 13:59 ` Steven Rostedt
2022-04-28 18:59 ` Alexei Starovoitov
2022-04-28 20:05 ` Steven Rostedt [this message]
2022-04-28 23:32 ` Andrii Nakryiko
2022-04-28 23:53 ` Steven Rostedt
2022-04-29 0:09 ` Steven Rostedt
2022-04-29 0:31 ` Steven Rostedt
2022-04-13 16:44 ` Steven Rostedt
2022-04-13 16:45 ` Andrii Nakryiko
2022-04-13 16:59 ` Steven Rostedt
2022-04-13 19:02 ` Andrii Nakryiko
2022-04-12 15:44 ` Jiri Olsa
2022-04-12 22:59 ` Andrii Nakryiko
2022-04-08 23:29 ` [RFC bpf-next 0/4] bpf: Speed up symbol resolving in kprobe multi link Alexei Starovoitov
2022-04-09 20:24 ` Jiri Olsa
2022-04-11 22:15 ` Andrii Nakryiko
2022-04-11 22:18 ` Alexei Starovoitov
2022-04-11 22:21 ` Andrii Nakryiko
2022-04-12 15:46 ` Jiri Olsa
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=20220428160519.04cc40c0@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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