bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yonghong Song <yhs@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 2/2] tools/bpf: add a selftest for bpf_send_signal_thread()
Date: Mon, 13 Jan 2020 17:19:33 -0800	[thread overview]
Message-ID: <CAEf4Bzagfmx1H3DgQ9ZjxKwbGdRGHAy7=qHt5S0Pqf0vV7PB4w@mail.gmail.com> (raw)
In-Reply-To: <20200110011559.1949913-1-yhs@fb.com>

On Thu, Jan 9, 2020 at 5:16 PM Yonghong Song <yhs@fb.com> wrote:
>
> The test_progs send_signal() is amended to test
> bpf_send_signal_thread() as well.
>
>   $ ./test_progs -n 40
>   #40/1 send_signal_tracepoint:OK
>   #40/2 send_signal_perf:OK
>   #40/3 send_signal_nmi:OK
>   #40/4 send_signal_tracepoint_thread:OK
>   #40/5 send_signal_perf_thread:OK
>   #40/6 send_signal_nmi_thread:OK
>   #40 send_signal:OK
>   Summary: 1/6 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>  tools/include/uapi/linux/bpf.h                | 18 +++++++++--

maybe do tools/uapi header sync in a first patch, along the original change?

>  .../selftests/bpf/prog_tests/send_signal.c    | 30 ++++++++++++-------
>  .../bpf/progs/test_send_signal_kern.c         |  9 ++++--
>  3 files changed, 42 insertions(+), 15 deletions(-)
>

[...]

> diff --git a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
> index 0e6be01157e6..4a722024c32b 100644
> --- a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
> +++ b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
> @@ -23,6 +23,7 @@ int bpf_send_signal_test(void *ctx)
>  {
>         __u64 *info_val, *status_val;
>         __u32 key = 0, pid, sig;
> +       int use_signal_thread;
>         int ret;
>
>         status_val = bpf_map_lookup_elem(&status_map, &key);
> @@ -33,11 +34,15 @@ int bpf_send_signal_test(void *ctx)
>         if (!info_val || *info_val == 0)
>                 return 0;
>
> -       sig = *info_val >> 32;
> +       use_signal_thread = *info_val >> 48;
> +       sig = *info_val >> 32 & 0xFFFF;
>         pid = *info_val & 0xffffFFFF;

Would you mind rewriting this test w/ BPF skeleton and global data? It
would make it cleaner without all this masking stuff?

>
>         if ((bpf_get_current_pid_tgid() >> 32) == pid) {
> -               ret = bpf_send_signal(sig);
> +               if (use_signal_thread)
> +                       ret = bpf_send_signal_thread(sig);
> +               else
> +                       ret = bpf_send_signal(sig);
>                 if (ret == 0)
>                         *status_val = 1;
>         }
> --
> 2.17.1
>

  reply	other threads:[~2020-01-14  1:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  1:15 [PATCH bpf-next 0/2] bpf: add bpf_send_signal_thread() helper Yonghong Song
2020-01-10  1:15 ` [PATCH bpf-next 1/2] " Yonghong Song
2020-01-14  0:58   ` Andrii Nakryiko
2020-01-14  1:15     ` Yonghong Song
2020-01-10  1:15 ` [PATCH bpf-next 2/2] tools/bpf: add a selftest for bpf_send_signal_thread() Yonghong Song
2020-01-14  1:19   ` Andrii Nakryiko [this message]
2020-01-14  1:22     ` Yonghong Song

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='CAEf4Bzagfmx1H3DgQ9ZjxKwbGdRGHAy7=qHt5S0Pqf0vV7PB4w@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@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).