From: Mykola Lysenko <mykolal@fb.com>
To: Song Liu <song@kernel.org>
Cc: Mykola Lysenko <mykolal@fb.com>, bpf <bpf@vger.kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH bpf-next] Improve BPF test stability (related to perf events and scheduling)
Date: Tue, 22 Feb 2022 20:00:02 +0000 [thread overview]
Message-ID: <37AA27EB-70A6-484C-9D24-641DFA13D185@fb.com> (raw)
In-Reply-To: <CAPhsuW4Rz_9bzXK-X-i2uc3aeQdCbY+b3QfRFvTN9HrraCs0ZQ@mail.gmail.com>
Thanks for your comments Song!
> On Feb 18, 2022, at 5:47 PM, Song Liu <song@kernel.org> wrote:
>
> On Fri, Feb 18, 2022 at 4:30 PM Mykola Lysenko <mykolal@fb.com> wrote:
>>
>> In send_signal, replace sleep with dummy cpu intensive computation
>> to increase probability of child process being scheduled. Add few
>> more asserts.
>
> How often do we see the test fail because the child process is not
> scheduled?
I just ran this test, non-modified, 100 times in a loop and got 94 failures. However, it is on my setup when using qemu for testing.
>
> [...]
>
>> static void sigusr1_handler(int signum)
>> {
>> - sigusr1_received++;
>> + sigusr1_received = 1;
>> }
>>
>> static void test_send_signal_common(struct perf_event_attr *attr,
>> @@ -42,7 +43,9 @@ static void test_send_signal_common(struct perf_event_attr *attr,
>> int old_prio;
>>
>> /* install signal handler and notify parent */
>> + errno = 0;
>> signal(SIGUSR1, sigusr1_handler);
>> + ASSERT_OK(errno, "signal");
>>
>> close(pipe_c2p[0]); /* close read */
>> close(pipe_p2c[1]); /* close write */
>> @@ -63,9 +66,12 @@ 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);
>> + for (int i = 0; i < 1000000000; i++)
>> + volatile_variable++;
>>
>> buf[0] = sigusr1_received ? '2' : '0';
>
> ^^^^ this "? :" seems useless as we assert sigusr1_received == 1. Let's fix it.
In this branch (true for "pid == 0” condition), we execute in the child process. Just asserting here would not fail the test unfortunately. Child process will die (after exit(0)) and test will succeed. However, you then may ask why do we need assert at all. It is useful if we want to debug what happens in the child process. Right now, child process does not print anything and I will fix it in the second version of this patch by substituting exit(0) with return;
>
>> + ASSERT_EQ(sigusr1_received, 1, "sigusr1_received");
>> +
>> ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
>>
>> /* wait for parent notification and exit */
>> @@ -110,9 +116,9 @@ static void test_send_signal_common(struct perf_event_attr *attr,
>> ASSERT_EQ(read(pipe_c2p[0], buf, 1), 1, "pipe_read");
>>
>> /* trigger the bpf send_signal */
>> + skel->bss->signal_thread = signal_thread;
>> skel->bss->pid = pid;
>> skel->bss->sig = SIGUSR1;
>> - skel->bss->signal_thread = signal_thread;
>
> Does the order matter here?
Unfortunately, yes. The bpf logic will start executing after sig or pid became non-zero (see /d/u/m/l/t/t/s/b/p/test_send_signal_kern.c, line 13). I am trying to remove ambiguity here with this small change. Although, pid and sig still may conflict. Let me think if it will be better to fix the bpf code itself.
next prev parent reply other threads:[~2022-02-22 20:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 0:30 [PATCH bpf-next] Improve BPF test stability (related to perf events and scheduling) Mykola Lysenko
2022-02-19 1:47 ` Song Liu
2022-02-22 20:00 ` Mykola Lysenko [this message]
2022-02-20 4:39 ` Andrii Nakryiko
2022-02-22 20:35 ` Mykola Lysenko
2022-02-23 3:13 ` Andrii Nakryiko
2022-02-23 4:32 ` Yonghong Song
2022-02-24 0:52 ` Mykola Lysenko
2022-03-01 3:45 ` Mykola Lysenko
2022-03-02 4:53 ` 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=37AA27EB-70A6-484C-9D24-641DFA13D185@fb.com \
--to=mykolal@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=song@kernel.org \
--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