Re: [RFC PATCH bpf-next 1/6] bpf: Optimize string scan kfuncs

Leon Hwang <[email protected]>
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.bpf,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 31/7/26 07:17, Andrii Nakryiko wrote:
> On Tue, Jul 28, 2026 at 7:58 AM Leon Hwang <[email protected]> wrote:

[...]

>> +
>> +               if (char_at <= zero_at)
>> +                       return pos + char_at;
>> +               return nul_is_match ? pos + zero_at : -ENOENT;
>> +       }), err_out);
> 
> looking at the above code, I'd say it's just not worth it. Too much
> code and complexity, IMO. For the absolute majority of BPF programs
> this small speed up won't matter, while for those BPF programs where
> doing tons of bpf_strstr-like operations is the essence of those
> programs and has a huge impact on the performance, they can basically
> implement and maintain this complexity in their own code base.
> 


Agreed on the complexity concern.

Let's leave the str kfuncs as-is.

Thanks,
Leon

>> +
>> +       return pos == XATTR_SIZE_MAX ? -E2BIG : -ENOENT;
>> +
>> +err_out:
>> +       return -EFAULT;
>> +}
>> +
> 
> [...]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.