From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yucong Sun <fallentree@fb.com>, Yonghong Song <yhs@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andrii@kernel.org>,
Yucong Sun <sunyucong@gmail.com>
Subject: Re: [PATCH bpf-next v6 11/14] selftests/bpf: adding random delay for send_signal test
Date: Fri, 8 Oct 2021 15:27:19 -0700 [thread overview]
Message-ID: <CAEf4Bza-DrWa1Z_Q93egdUHWdcjnWn4jJtCBwZEBx3p1ynC+uA@mail.gmail.com> (raw)
In-Reply-To: <20211006185619.364369-12-fallentree@fb.com>
On Wed, Oct 6, 2021 at 11:56 AM Yucong Sun <fallentree@fb.com> wrote:
>
> From: Yucong Sun <sunyucong@gmail.com>
>
> This patch adds random delay on waiting for the signal to arrive,
> making the test more robust.
>
> Signed-off-by: Yucong Sun <sunyucong@gmail.com>
> ---
> tools/testing/selftests/bpf/prog_tests/send_signal.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c
> index 776916b61c40..6200256243f2 100644
> --- a/tools/testing/selftests/bpf/prog_tests/send_signal.c
> +++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c
> @@ -19,6 +19,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
> int err = -1, pmu_fd = -1;
> char buf[256];
> pid_t pid;
> + int attempts = 100;
>
> if (!ASSERT_OK(pipe(pipe_c2p), "pipe_c2p"))
> return;
> @@ -63,7 +64,10 @@ static void test_send_signal_common(struct perf_event_attr *attr,
> ASSERT_EQ(read(pipe_p2c[0], buf, 1), 1, "pipe_read");
>
> /* wait a little for signal handler */
> - sleep(1);
> + while (attempts > 0 && !sigusr1_received) {
This is not reliable, sigusr1_received has to be volatile or
sig_atomic_t, please fix. I haven't applied this patch yet.
Also, previously we slept for a second, now we can, technically, sleep
only up to 100ms, would that cause any problems in practice? cc
Yonghong
> + attempts--;
> + usleep(500 + rand() % 500);
> + }
>
> buf[0] = sigusr1_received ? '2' : '0';
> ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
> --
> 2.30.2
>
next prev parent reply other threads:[~2021-10-08 22:27 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 18:56 [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 01/14] " Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 02/14] selftests/bpf: Allow some tests to be executed in sequence Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-08 23:06 ` sunyucong
2021-10-09 3:17 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 03/14] selftests/bpf: disable perf rate limiting when running tests Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 04/14] selftests/bpf: add per worker cgroup suffix Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 05/14] selftests/bpf: adding read_perf_max_sample_freq() helper Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:49 ` sunyucong
2022-03-08 20:22 ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 06/14] selftests/bpf: fix race condition in enable_stats Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 07/14] selftests/bpf: make cgroup_v1v2 use its own port Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 08/14] selftests/bpf: adding a namespace reset for tc_redirect Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 23:07 ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 09/14] selftests/bpf: Make uprobe tests use different attach functions Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:46 ` sunyucong
2021-10-09 3:13 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 10/14] selftests/bpf: adding pid filtering for atomics test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 11/14] selftests/bpf: adding random delay for send_signal test Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko [this message]
2021-10-06 18:56 ` [PATCH bpf-next v6 12/14] selftests/bpf: Fix pid check in fexit_sleep test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 13/14] selftests/bpf: increase loop count for perf_branches Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:57 ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 14/14] selfetest/bpf: make some tests serial Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:55 ` sunyucong
2021-10-09 3:14 ` Andrii Nakryiko
2021-10-08 22:26 ` [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Andrii Nakryiko
2021-10-08 22:42 ` Andrii Nakryiko
2021-10-08 23:37 ` Steven Rostedt
2021-10-09 3:20 ` Andrii Nakryiko
2021-10-09 3:28 ` Steven Rostedt
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=CAEf4Bza-DrWa1Z_Q93egdUHWdcjnWn4jJtCBwZEBx3p1ynC+uA@mail.gmail.com \
--to=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=fallentree@fb.com \
--cc=sunyucong@gmail.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).