From: Feng Yang <yangfeng59949@163.com>
To: andrii.nakryiko@gmail.com
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
daniel@iogearbox.net, eddyz87@gmail.com, haoluo@google.com,
john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
martin.lau@linux.dev, mathieu.desnoyers@efficios.com,
mattbobrowski@google.com, mhiramat@kernel.org,
rostedt@goodmis.org, sdf@fomichev.me, song@kernel.org,
yangfeng59949@163.com, yonghong.song@linux.dev
Subject: Re: [PATCH bpf-next v3] bpf: Remove redundant checks
Date: Thu, 17 Apr 2025 21:36:41 +0800 [thread overview]
Message-ID: <20250417133641.7518-1-yangfeng59949@163.com> (raw)
In-Reply-To: <CAEf4Bzai7NL-3=1SVi4-WWYWEY6Lzrb8GBfKnt6FG8sNm2OMRQ@mail.gmail.com>
On Thu, 17 Apr 2025 17:52:45 +0800 Feng Yang wrote:
> > > case BPF_FUNC_get_smp_processor_id:
> > > return &bpf_get_smp_processor_id_proto;
> >
> > this one should be cleaned up as well and
> > bpf_get_smp_processor_id_proto removed. All BPF programs either
> > disable CPU preemption or CPU migration, so bpf_base_func_proto's
> > implementation should work just fine (but please do it as a separate
> > patch)
> >
> BPF_CALL_0(bpf_get_smp_processor_id)
> {
> return smp_processor_id();
> }
> const struct bpf_func_proto bpf_get_smp_processor_id_proto = {
> .func = bpf_get_smp_processor_id,
> .gpl_only = false,
> .ret_type = RET_INTEGER,
> .allow_fastcall = true,
> };
> When attempting to remove bpf_get_smp_processor_id_proto,
> it was observed that bpf_get_smp_processor_id is extensively used.
> Should we also replace all instances of bpf_get_smp_processor_id with bpf_get_raw_cpu_id in these cases?
>
> For example:
> #define ___BPF_FUNC_MAPPER(FN, ctx...) \
> ......
> FN(get_smp_processor_id, 8, ##ctx) \
> samples/bpf/sockex3_kern.c:
> static struct globals *this_cpu_globals(void)
> {
> u32 key = bpf_get_smp_processor_id();
> return bpf_map_lookup_elem(&percpu_map, &key);
> }
> and so on......
> Thanks.
I think I understand the issue now: removing this bpf_get_smp_processor_id has no impact.
For the code:
case BPF_FUNC_get_smp_processor_id:
return &bpf_get_raw_smp_processor_id_proto;
This configuration allows bpf_get_smp_processor_id to actually invoke the bpf_get_raw_smp_processor_id_proto function implementation.
Thanks.
prev parent reply other threads:[~2025-04-17 13:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:02 Feng Yang
2025-04-16 21:55 ` Andrii Nakryiko
2025-04-16 22:44 ` Zvi Effron
2025-04-23 17:05 ` Andrii Nakryiko
2025-04-17 9:52 ` Feng Yang
2025-04-17 13:36 ` Feng Yang [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=20250417133641.7518-1-yangfeng59949@163.com \
--to=yangfeng59949@163.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=mattbobrowski@google.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--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
all inboxes | Powered by JetHome®