The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Hoyeon Lee <hoyeon.lee@suse.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	 bpf <bpf@vger.kernel.org>, 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>,
	KP Singh	 <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Hao Luo	 <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	 "open list:KERNEL SELFTEST FRAMEWORK"	
	<linux-kselftest@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [bpf-next] selftests/bpf: refactor snprintf_btf test to use bpf_strncmp
Date: Wed, 05 Nov 2025 14:52:18 -0800	[thread overview]
Message-ID: <b3f13550169288578796548f12619e5e972c0636.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQK7Qa5v=fkQtnx_A2OiXDDrWZAYY6qGi8ruVn_dOXmrUw@mail.gmail.com>

On Wed, 2025-11-05 at 14:45 -0800, Alexei Starovoitov wrote:
> On Wed, Nov 5, 2025 at 12:14 PM Hoyeon Lee <hoyeon.lee@suse.com> wrote:
> > 
> > The netif_receive_skb BPF program used in snprintf_btf test still uses
> > a custom __strncmp. This is unnecessary as the bpf_strncmp helper is
> > available and provides the same functionality.
> > 
> > This commit refactors the test to use the bpf_strncmp helper, removing
> > the redundant custom implementation.
> > 
> > Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
> > ---
> >  .../selftests/bpf/progs/netif_receive_skb.c       | 15 +--------------
> >  1 file changed, 1 insertion(+), 14 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/bpf/progs/netif_receive_skb.c b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> > index 9e067dcbf607..186b8c82b9e6 100644
> > --- a/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> > +++ b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> > @@ -31,19 +31,6 @@ struct {
> >         __type(value, char[STRSIZE]);
> >  } strdata SEC(".maps");
> > 
> > -static int __strncmp(const void *m1, const void *m2, size_t len)
> > -{
> > -       const unsigned char *s1 = m1;
> > -       const unsigned char *s2 = m2;
> > -       int i, delta = 0;
> > -
> > -       for (i = 0; i < len; i++) {
> > -               delta = s1[i] - s2[i];
> > -               if (delta || s1[i] == 0 || s2[i] == 0)
> > -                       break;
> > -       }
> > -       return delta;
> > -}
> > 
> >  #if __has_builtin(__builtin_btf_type_id)
> >  #define        TEST_BTF(_str, _type, _flags, _expected, ...)                   \
> > @@ -69,7 +56,7 @@ static int __strncmp(const void *m1, const void *m2, size_t len)
> >                                        &_ptr, sizeof(_ptr), _hflags);   \
> >                 if (ret)                                                \
> >                         break;                                          \
> > -               _cmp = __strncmp(_str, _expectedval, EXPECTED_STRSIZE); \
> > +               _cmp = bpf_strncmp(_str, EXPECTED_STRSIZE, _expectedval); \
> 
> Though it's equivalent, the point of the test is to be heavy
> for the verifier with open coded __strncmp().
> 
> pw-bot: cr

I double checked that before acking, the test was added as a part of [1].
So it seems to be focused on bpf_snprintf_btf(), not on scalability.
And it's not that heavy in terms of instructions budget:

File                     Program                  Verdict  Insns  States
-----------------------  -----------------------  -------  -----  ------
netif_receive_skb.bpf.o  trace_netif_receive_skb  success  18152     629


[1] https://lore.kernel.org/bpf/1601292670-1616-5-git-send-email-alan.maguire@oracle.com/

  reply	other threads:[~2025-11-05 22:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 20:14 [bpf-next] selftests/bpf: refactor snprintf_btf test to use bpf_strncmp Hoyeon Lee
2025-11-05 22:22 ` Eduard Zingerman
2025-11-05 22:45 ` Alexei Starovoitov
2025-11-05 22:52   ` Eduard Zingerman [this message]
2025-11-05 23:33     ` Alexei Starovoitov
2025-11-05 23:37       ` Eduard Zingerman
2025-11-05 23:43         ` Alexei Starovoitov
2025-11-06  3:26           ` Hoyeon Lee

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=b3f13550169288578796548f12619e5e972c0636.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=hoyeon.lee@suse.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --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