bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH v4 bpf-next 5/5] selftests/bpf: Add sleepable tests
Date: Mon, 29 Jun 2020 20:34:54 -0700	[thread overview]
Message-ID: <CAEf4BzZqWTdSOnko1g9HKiqzbD8_xL+4tN8znoaNO6suq_LbAQ@mail.gmail.com> (raw)
In-Reply-To: <20200630030653.fkgp43sz5gqi426y@ast-mbp.dhcp.thefacebook.com>

On Mon, Jun 29, 2020 at 8:06 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Mon, Jun 29, 2020 at 06:25:38PM -0700, Andrii Nakryiko wrote:
> >
> > > +
> > > +SEC("fentry.s/__x64_sys_setdomainname")
> > > +int BPF_PROG(test_sys_setdomainname, struct pt_regs *regs)
> > > +{
> > > +       int buf = 0;
> > > +       long ret;
> > > +
> > > +       ret = bpf_copy_from_user(&buf, sizeof(buf), (void *)regs->di);
> > > +       if (regs->si == -2 && ret == 0 && buf == 1234)
> > > +               copy_test++;
> > > +       if (regs->si == -3 && ret == -EFAULT)
> > > +               copy_test++;
> > > +       if (regs->si == -4 && ret == -EFAULT)
> > > +               copy_test++;
> >
> > regs->si and regs->di won't compile on non-x86 arches, better to use
> > PT_REGS_PARM1() and PT_REGS_PARM2() from bpf_tracing.h.
>
> the test is x86 only due to:
> +SEC("fentry.s/__x64_sys_setdomainname")

Right, but here I'm talking about compilation error because pt_regs
don't have si, di fields on other arches. __x64 just won't attach in
runtime, which is not a big deal if you are ignoring this particular
test.

>
> I guess we can move samples/bpf/trace_common.h into libbpf as well
> to clean the whole thing up. Something for later patches.

trace_common.h works only for the latest kernels. Before some version
(don't remember which version precisely), __x64 shouldn't be added.
Which makes this header not a good candidate for inclusion to libbpf.
BCC does this dynamically in runtime based on kallsyms, which I'm not
a big fan of doing as well. So let's punt trace_common.h for better
times :)

      reply	other threads:[~2020-06-30  3:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  0:34 [PATCH v4 bpf-next 0/5] bpf: Introduce minimal support for sleepable progs Alexei Starovoitov
2020-06-30  0:34 ` [PATCH v4 bpf-next 1/5] bpf: Remove redundant synchronize_rcu Alexei Starovoitov
2020-06-30  0:58   ` Andrii Nakryiko
2020-06-30  1:08     ` Andrii Nakryiko
2020-06-30  2:56       ` Alexei Starovoitov
2020-06-30  3:31         ` Andrii Nakryiko
2020-06-30  0:34 ` [PATCH v4 bpf-next 2/5] bpf: Introduce sleepable BPF programs Alexei Starovoitov
2020-06-30  1:15   ` Andrii Nakryiko
2020-06-30  3:03     ` Alexei Starovoitov
2020-06-30  0:34 ` [PATCH v4 bpf-next 3/5] bpf: Add bpf_copy_from_user() helper Alexei Starovoitov
2020-06-30  1:18   ` Andrii Nakryiko
2020-06-30  0:34 ` [PATCH v4 bpf-next 4/5] libbpf: support sleepable progs Alexei Starovoitov
2020-06-30  0:34 ` [PATCH v4 bpf-next 5/5] selftests/bpf: Add sleepable tests Alexei Starovoitov
2020-06-30  1:25   ` Andrii Nakryiko
2020-06-30  3:06     ` Alexei Starovoitov
2020-06-30  3:34       ` Andrii Nakryiko [this message]

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=CAEf4BzZqWTdSOnko1g9HKiqzbD8_xL+4tN8znoaNO6suq_LbAQ@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.org \
    /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).