Re: [PATCH] bpf: Remove duplicate judgments

From: Feng Yang
Date: Fri Mar 21 2025 - 00:37:04 EST


On Thu, 20 Mar 2025 09:45:17 -0700 Song Liu <song@xxxxxxxxxx> wrote:
>
> On Wed, Mar 19, 2025 at 8:23 PM Feng Yang <yangfeng59949@xxxxxxx> wrote:
> >
> > From: Feng Yang <yangfeng@xxxxxxxxxx>
> >
> > Most of the judgments also exist in bpf_base_func_deto, remove them.
>
> "Most" of them also exist is not enough. Please make sure that this does
> not introduce any behavior change. For example, we should not remove
> return of bpf_perf_event_read_value_proto.

in trace/bpf_trace.c:
const struct bpf_func_proto *bpf_get_perf_event_read_value_proto(void)
{
return &bpf_perf_event_read_value_proto;
}
in bpf/core.c:
const struct bpf_func_proto * __weak bpf_get_perf_event_read_value_proto(void)
{
return NULL;
}

And weak symbols will be covered
nm vmlinux | grep bpf_get_perf_event_read_value_proto
ffffffff814b90e0 T bpf_get_perf_event_read_value_proto
ffffffff814b90d0 T __pfx_bpf_get_perf_event_read_value_proto

So the return of bpf_perf_event_read_value_proto can be done through the bpf_base_func_proto function.
bpf_base_func_proto
......
case BPF_FUNC_perf_event_read_value:
return bpf_get_perf_event_read_value_proto();

I think this can be removed.

> For future patches, please read Documentation/bpf/bpf_devel_QA.rst
> and follow rules for email subject, etc. For example, this patch should
> have a subject like "[PATCH bpf-next] xxx".

Thank you very much for your suggestion. I will pay attention to it next time.

> Thanks,
> Song