From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
john fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 1/9] bpf: selftests: Use libbpf 1.0 API mode in bpf constructor
Date: Sun, 3 Apr 2022 18:26:54 -0700 [thread overview]
Message-ID: <CAEf4BzYGOgrbvobqPBW+1Zdb5W7Cj0WUvQNitnrxJNgSOCnzQQ@mail.gmail.com> (raw)
In-Reply-To: <CAEf4BzZ2U=H-FEft3twSV7RCgTHHVJ8Dt6_RuYMdHdtC17WM1A@mail.gmail.com>
On Sun, Apr 3, 2022 at 6:24 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Sun, Apr 3, 2022 at 7:43 AM Yafang Shao <laoar.shao@gmail.com> wrote:
> >
> > In libbpf 1.0 API mode, it will bump rlimit automatically if there's no
> > memcg-basaed accounting, so we can use libbpf 1.0 API mode instead in case
also very eye catching typo: basaed -> based
> > we want to run it in an old kernel.
> >
> > The constructor is renamed to bpf_strict_all_ctor().
> >
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> > ---
> > tools/testing/selftests/bpf/bpf_rlimit.h | 26 +++---------------------
> > 1 file changed, 3 insertions(+), 23 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/bpf_rlimit.h b/tools/testing/selftests/bpf/bpf_rlimit.h
> > index 9dac9b30f8ef..d050f7d0bb5c 100644
> > --- a/tools/testing/selftests/bpf/bpf_rlimit.h
> > +++ b/tools/testing/selftests/bpf/bpf_rlimit.h
> > @@ -1,28 +1,8 @@
> > #include <sys/resource.h>
> > #include <stdio.h>
> >
> > -static __attribute__((constructor)) void bpf_rlimit_ctor(void)
> > +static __attribute__((constructor)) void bpf_strict_all_ctor(void)
>
> well, no, let's get rid of bpf_rlimit.h altogether. There is no need
> for constructor magic when you can have an explicit
> libbpf_set_strict_mode(LIBBPF_STRICT_ALL).
>
> > {
> > - struct rlimit rlim_old, rlim_new = {
> > - .rlim_cur = RLIM_INFINITY,
> > - .rlim_max = RLIM_INFINITY,
> > - };
> > -
> > - getrlimit(RLIMIT_MEMLOCK, &rlim_old);
> > - /* For the sake of running the test cases, we temporarily
> > - * set rlimit to infinity in order for kernel to focus on
> > - * errors from actual test cases and not getting noise
> > - * from hitting memlock limits. The limit is on per-process
> > - * basis and not a global one, hence destructor not really
> > - * needed here.
> > - */
> > - if (setrlimit(RLIMIT_MEMLOCK, &rlim_new) < 0) {
> > - perror("Unable to lift memlock rlimit");
> > - /* Trying out lower limit, but expect potential test
> > - * case failures from this!
> > - */
> > - rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
> > - rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
> > - setrlimit(RLIMIT_MEMLOCK, &rlim_new);
> > - }
> > + /* Use libbpf 1.0 API mode */
> > + libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
> > }
> > --
> > 2.17.1
> >
next prev parent reply other threads:[~2022-04-04 1:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 14:42 [PATCH bpf-next v2 0/9] bpf: RLIMIT_MEMLOCK cleanups Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 1/9] bpf: selftests: Use libbpf 1.0 API mode in bpf constructor Yafang Shao
2022-04-04 1:24 ` Andrii Nakryiko
2022-04-04 1:26 ` Andrii Nakryiko [this message]
2022-04-04 6:45 ` Yafang Shao
2022-04-04 6:44 ` Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 2/9] bpf: selftests: Use bpf strict all ctor in xdping Yafang Shao
2022-04-04 1:26 ` Andrii Nakryiko
2022-04-04 6:46 ` Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 3/9] bpf: selftests: Use bpf strict all ctor in xdpxceiver Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 4/9] bpf: samples: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL in xdpsock_user Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 5/9] bpf: samples: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL in xsk_fwd Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 6/9] bpf: runqslower: Replace RLIMIT_MEMLOCK with LIBBPF_STRICT_ALL Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 7/9] bpf: bpftool: Remove useless return value of libbpf_set_strict_mode Yafang Shao
2022-04-03 14:42 ` [PATCH bpf-next v2 8/9] bpf: bpftool: Set LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK for legacy libbpf Yafang Shao
2022-04-03 14:43 ` [PATCH bpf-next v2 9/9] bpf: bpftool: Remove useless rlimit setting Yafang Shao
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=CAEf4BzYGOgrbvobqPBW+1Zdb5W7Cj0WUvQNitnrxJNgSOCnzQQ@mail.gmail.com \
--to=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).