From: Tao Chen <chen.dylane@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] libbpf: Add bpf_program__set_section_name api
Date: Tue, 26 Mar 2024 22:54:53 +0800 [thread overview]
Message-ID: <47529e7e-437e-4601-a5dc-518b38aaf496@gmail.com> (raw)
In-Reply-To: <CAEf4Bzag72gYXWJ2+mPnWaysyTK0OC3NjnasxNsb+N0NxXY2fw@mail.gmail.com>
Hi, Andrii, thank you for your reply. I read the apis again in libbpf.h,
as you say, it seems that this patch no need. Thanks again.
在 2024/3/26 上午1:25, Andrii Nakryiko 写道:
> On Mon, Mar 25, 2024 at 8:48 AM Tao Chen <chen.dylane@gmail.com> wrote:
>>
>> The new api can be used to reset the function we want to trace in
>> runtime. So we need not to change the code again when we just do
>> minor changes to the trace function in kprobe or other ebpf event
>> type. We can replace the old section with new section passed in via
>> parameter. Maybe the following scenario we can use the api:
>>
>> 1. solve "*.isra.o" issue caused by compiler in new kernel
>> obj = offcputime_bpf__open();
>> bpf_program__set_section_name(*(obj->skeleton->obj),
>> "kprobe/finish_task_switch", "kprobe/finish_task_switch.isra.0");
>>
>> 2. dynamic adjustment for trace function offset
>> obj = offcputime_bpf__open();
>> bpf_program__set_section_name(*(obj->skeleton->obj),
>> "kprobe/finish_task_switch+23", "kprobe/finish_task_switch+45");
>>
>> Signed-off-by: Tao Chen <chen.dylane@gmail.com>
>> ---
>> tools/lib/bpf/libbpf.c | 24 ++++++++++++++++++++++++
>> tools/lib/bpf/libbpf.h | 2 ++
>> tools/lib/bpf/libbpf.map | 1 +
>> 3 files changed, 27 insertions(+)
>>
>
> This is a wrong approach. SEC() is immutable and serves as a hint to
> libbpf on program type and possibly some attach parameters. But after
> that libbpf allows to override all of them though APIs like
> bpf_program__set_type() and others. Attach APIs always allow to
> specify all the target parameters, including kprobe function name and
> so on.
>
> Please check all of the libbpf APIs in libbpf.h.
>
> pw-bot: cr
>
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index 96ff1aa4bf6a..94f32e845c61 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -8576,6 +8576,30 @@ const char *bpf_program__section_name(const struct bpf_program *prog)
>> return prog->sec_name;
>> }
>>
>
> [...]
prev parent reply other threads:[~2024-03-26 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 15:47 [RFC PATCH] libbpf: Add bpf_program__set_section_name api Tao Chen
2024-03-25 17:25 ` Andrii Nakryiko
2024-03-26 14:54 ` Tao Chen [this message]
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=47529e7e-437e-4601-a5dc-518b38aaf496@gmail.com \
--to=chen.dylane@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=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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