From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: kkd@meta.com, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Steven Rostedt <rostedt@goodmis.org>,
Jiri Olsa <olsajiri@gmail.com>,
Juri Lelli <juri.lelli@redhat.com>,
kernel-team@fb.com
Subject: Re: [PATCH bpf-next v1 0/2] Handle possible NULL trusted raw_tp arguments
Date: Fri, 01 Nov 2024 17:21:49 -0700 [thread overview]
Message-ID: <c3f7ee7790c6f53a572ff2857433f534f4972189.camel@gmail.com> (raw)
In-Reply-To: <CAP01T75OUeE8E-Lw9df84dm8ag2YmHW619f1DmPSVZ5_O89+Bg@mail.gmail.com>
On Fri, 2024-11-01 at 14:18 +0100, Kumar Kartikeya Dwivedi wrote:
[...]
> I see that all selftests except one passed. The one that didn't
> appears to have been cancelled after running for an hour, and stalled
> after select_reuseport:OK.
> Looking at the LLVM 18
> (https://github.com/kernel-patches/bpf/actions/runs/11621768944/job/32366412581?pr=7999)
> run instead of LLVM 17
> (https://github.com/kernel-patches/bpf/actions/runs/11621768944/job/32366400714?pr=7999,
> which failed), it seems the next test send_signal_tracepoint.
>
> Is this known to be flaky? I'm guessing not and it is probably caused
> by my patch, but just want to confirm before I begin debugging.
I suspect this is a test send_signal.
It started to hang for me yesterday w/o any apparent reason (on master branch).
I added workaround to avoid stalls, but this does not address the
issue with the test. Workaround follows.
---
diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c
index ee5a221b4103..4af127945417 100644
--- a/tools/testing/selftests/bpf/prog_tests/send_signal.c
+++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c
@@ -18,6 +18,38 @@ static void sigusr1_siginfo_handler(int s, siginfo_t *i, void *v)
static char log_buf[64 * 1024];
+static ssize_t read_with_timeout(int fd, void *buf, size_t count)
+{
+ struct timeval tv = { 1, 0 };
+ fd_set fds;
+ int err;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ err = select(fd + 1, &fds, NULL, NULL, &tv);
+ if (!ASSERT_GE(err, 0, "read select"))
+ return err;
+ if (FD_ISSET(fd, &fds))
+ return read(fd, buf, count);
+ return -EAGAIN;
+}
+
+static ssize_t write_with_timeout(int fd, void *buf, size_t count)
+{
+ struct timeval tv = { 1, 0 };
+ fd_set fds;
+ int err;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ err = select(fd + 1, NULL, &fds, NULL, &tv);
+ if (!ASSERT_GE(err, 0, "write select"))
+ return err;
+ if (FD_ISSET(fd, &fds))
+ return write(fd, buf, count);
+ return -EAGAIN;
+}
+
static void test_send_signal_common(struct perf_event_attr *attr,
bool signal_thread, bool remote)
{
@@ -75,10 +107,10 @@ static void test_send_signal_common(struct perf_event_attr *attr,
}
/* notify parent signal handler is installed */
- ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
+ ASSERT_EQ(write_with_timeout(pipe_c2p[1], buf, 1), 1, "pipe_write");
/* make sure parent enabled bpf program to send_signal */
- ASSERT_EQ(read(pipe_p2c[0], buf, 1), 1, "pipe_read");
+ ASSERT_EQ(read_with_timeout(pipe_p2c[0], buf, 1), 1, "pipe_read");
/* wait a little for signal handler */
for (int i = 0; i < 1000000000 && !sigusr1_received; i++) {
@@ -94,10 +126,10 @@ static void test_send_signal_common(struct perf_event_attr *attr,
buf[0] = sigusr1_received;
ASSERT_EQ(sigusr1_received, 8, "sigusr1_received");
- ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
+ ASSERT_EQ(write_with_timeout(pipe_c2p[1], buf, 1), 1, "pipe_write");
/* wait for parent notification and exit */
- ASSERT_EQ(read(pipe_p2c[0], buf, 1), 1, "pipe_read");
+ ASSERT_EQ(read_with_timeout(pipe_p2c[0], buf, 1), 1, "pipe_read");
/* restore the old priority */
if (!remote)
@@ -158,7 +190,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
}
/* wait until child signal handler installed */
- ASSERT_EQ(read(pipe_c2p[0], buf, 1), 1, "pipe_read");
+ ASSERT_EQ(read_with_timeout(pipe_c2p[0], buf, 1), 1, "pipe_read");
/* trigger the bpf send_signal */
skel->bss->signal_thread = signal_thread;
@@ -172,7 +204,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
}
/* notify child that bpf program can send_signal now */
- ASSERT_EQ(write(pipe_p2c[1], buf, 1), 1, "pipe_write");
+ ASSERT_EQ(write_with_timeout(pipe_p2c[1], buf, 1), 1, "pipe_write");
/* For the remote test, the BPF program is triggered from this
* process but the other process/thread is signaled.
@@ -188,7 +220,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
}
/* wait for result */
- err = read(pipe_c2p[0], buf, 1);
+ err = read_with_timeout(pipe_c2p[0], buf, 1);
if (!ASSERT_GE(err, 0, "reading pipe"))
goto disable_pmu;
if (!ASSERT_GT(err, 0, "reading pipe error: size 0")) {
@@ -199,7 +231,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
ASSERT_EQ(buf[0], 8, "incorrect result");
/* notify child safe to exit */
- ASSERT_EQ(write(pipe_p2c[1], buf, 1), 1, "pipe_write");
+ ASSERT_EQ(write_with_timeout(pipe_p2c[1], buf, 1), 1, "pipe_write");
disable_pmu:
close(pmu_fd);
next prev parent reply other threads:[~2024-11-02 0:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 0:00 [PATCH bpf-next v1 0/2] Handle possible NULL trusted raw_tp arguments Kumar Kartikeya Dwivedi
2024-11-01 0:00 ` [PATCH bpf-next v1 1/2] bpf: Mark raw_tp arguments with PTR_MAYBE_NULL Kumar Kartikeya Dwivedi
2024-11-01 19:16 ` Andrii Nakryiko
2024-11-01 22:55 ` Alexei Starovoitov
2024-11-03 16:16 ` Kumar Kartikeya Dwivedi
2024-11-03 16:40 ` Kumar Kartikeya Dwivedi
2024-11-03 17:00 ` Kumar Kartikeya Dwivedi
2024-11-03 17:37 ` Alexei Starovoitov
2024-11-06 20:17 ` Andrii Nakryiko
2024-11-01 0:00 ` [PATCH bpf-next v1 2/2] selftests/bpf: Add tests for raw_tp null handling Kumar Kartikeya Dwivedi
2024-11-01 19:19 ` Andrii Nakryiko
2024-11-03 15:58 ` Kumar Kartikeya Dwivedi
2024-11-01 13:18 ` [PATCH bpf-next v1 0/2] Handle possible NULL trusted raw_tp arguments Kumar Kartikeya Dwivedi
2024-11-02 0:21 ` Eduard Zingerman [this message]
2024-11-02 0:29 ` Alexei Starovoitov
2024-11-02 0:32 ` Eduard Zingerman
2024-11-08 5:08 ` Eduard Zingerman
2024-11-08 20:13 ` Alexei Starovoitov
2024-11-08 21:57 ` 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=c3f7ee7790c6f53a572ff2857433f534f4972189.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@fb.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=olsajiri@gmail.com \
--cc=rostedt@goodmis.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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