[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94849d3f-81f0-703d-f5ce-87581cbbbc75@huawei.com>
Date: Mon, 8 Nov 2021 22:08:59 +0800
From: Hou Tao <houtao1@...wei.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>,
Andrii Nakryiko <andrii.nakryiko@...il.com>
CC: Martin KaFai Lau <kafai@...com>, Yonghong Song <yhs@...com>,
Song Liu <songliubraving@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [RFC PATCH bpf-next 1/2] bpf: add bpf_strncmp helper
Hi,
On 11/7/2021 4:32 AM, Alexei Starovoitov wrote:
> On Sat, Nov 6, 2021 at 1:07 PM Andrii Nakryiko
> <andrii.nakryiko@...il.com> wrote:
snip
>>> I was thinking whether the proto could be:
>>> long bpf_strncmp(const char *s1, u32 s1_sz, const char *s2)
>>> but I think your version is better though having const string as 1st arg
>>> is a bit odd in normal C.
>> Why do you think it's better? This is equivalent to `123 == x` if it
>> was integer comparison, so it feels like bpf_strncmp(s, sz, "blah") is
>> indeed more natural. No big deal, just curious what's better about it.
> Only that helper implementation has two less register moves.
> which makes it 51%/49% win for me.
> .
I agree with Andrii that bpf_strncmp(s, sz, "blah") is more nature. I can run
some simple benchmarks to show whether or not the difference matters.
Regards,
Tao.
Powered by blists - more mailing lists