bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org,  Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	 Emil Tsalapatis <emil@etsalapatis.com>,
	 Barret Rhoden <brho@google.com>,
	 kkd@meta.com, kernel-team@meta.com
Subject: Re: [RFC PATCH bpf-next/net v1 12/13] bpftool: Add support for dumping streams
Date: Tue, 22 Apr 2025 13:30:18 -0700	[thread overview]
Message-ID: <m2wmbcq6qt.fsf@gmail.com> (raw)
In-Reply-To: <20250414161443.1146103-13-memxor@gmail.com> (Kumar Kartikeya Dwivedi's message of "Mon, 14 Apr 2025 09:14:42 -0700")


When I add a test as at the bottom of the email I get the following output:

    test_stream_cond_break:PASS:load 0 nsec
    test_stream_cond_break:PASS:run_opts 0 nsec
    test_stream_cond_break:PASS:info_by_fd 0 nsec
    ERROR: Timeout detected for may_goto instruction
    CPU: 6 UID: 0 PID: 206 Comm: test_progs
    Call trace:
     bpf_prog_stderr_dump_stack+0xde/0x160
     bpf_check_timed_may_goto+0x5d/0x90
     arch_bpf_timed_may_goto+0x21/0x40
     bpf_prog_34056decf3b2fb2f_long_loop+0x49/0x57: [stream_cond_break.c:8]
     bpf_prog_run_pin_on_cpu+0x5f/0x110
     bpf_prog_test_run_syscall+0x205/0x320
     bpf_prog_test_run+0x234/0x2a0
     __sys_bpf+0x2d7/0x570
     __x64_sys_bpf+0x7c/0x90
     do_syscall_64+0x79/0x120
     entry_SYSCALL_64_after_hwframe+0x76/0x7e
    
    prog_dump_stream: ret==-22
    test_stream_cond_break:FAIL:./tools/sbin/bpftool prog dump stderr id 8
     unexpected error: 59904 (errno 95)

Am I doing something wrong or EINVAL should not be returned from
prog_dump_stream in this case?

---

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index d0800fec9c3d..64386737a364 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -747,6 +747,7 @@ prog_dump_stream(struct bpf_prog_info *info, enum dump_mode mode, const char *fi
 		ret = -EINVAL;
 end:
 	stream_bpf__destroy(skel);
+	fprintf(stderr, "prog_dump_stream: ret==%d\n", ret);
 	return ret;
 }
 
diff --git a/tools/testing/selftests/bpf/prog_tests/stream_cond_break.c b/tools/testing/selftests/bpf/prog_tests/stream_cond_break.c
new file mode 100644
index 000000000000..7a29a45b0a04
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/stream_cond_break.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
+#include <test_progs.h>
+#include "stream_cond_break.skel.h"
+
+static char log_buf[16 * 1024];
+
+void test_stream_cond_break(void)
+{
+	LIBBPF_OPTS(bpf_object_open_opts, opts, .kernel_log_buf = log_buf,
+						.kernel_log_size = sizeof(log_buf),
+						.kernel_log_level = 1 | 2 | 4);
+	LIBBPF_OPTS(bpf_test_run_opts, run_opts);
+	struct stream_cond_break *skel = NULL;
+	struct bpf_prog_info prog_info;
+	__u32 prog_info_len;
+	int ret, fd;
+
+	skel = stream_cond_break__open_opts(&opts);
+	if (!ASSERT_OK_PTR(skel, "open_opts"))
+		goto out;
+	ret = stream_cond_break__load(skel);
+	if (env.verbosity >= VERBOSE_VERY) {
+		fprintf(stderr, "---- program load log ----\n");
+		fprintf(stderr, "%s", log_buf);
+		fprintf(stderr, "--------- end log --------\n");
+	}
+	if (!ASSERT_OK(ret, "load"))
+		return;
+	fd = bpf_program__fd(skel->progs.long_loop);
+	ret = bpf_prog_test_run_opts(fd, &run_opts);
+	if (!ASSERT_EQ(ret, 0, "run_opts"))
+		goto out;
+	memset(&prog_info, 0, sizeof(prog_info));
+	prog_info_len = sizeof(prog_info);
+	ret = bpf_prog_get_info_by_fd(fd, &prog_info, &prog_info_len);
+	if (!ASSERT_OK(ret, "info_by_fd"))
+		goto out;
+	SYS(out, "./tools/sbin/bpftool prog dump stderr id %i\n", prog_info.id);
+out:
+	stream_cond_break__destroy(skel);
+}
diff --git a/tools/testing/selftests/bpf/progs/stream_cond_break.c b/tools/testing/selftests/bpf/progs/stream_cond_break.c
new file mode 100644
index 000000000000..47c2e5f1b8fd
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/stream_cond_break.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "bpf_experimental.h"
+
+SEC("syscall")
+int long_loop(const void *ctx)
+{
+	for (;;)
+		cond_break;
+	return 0;
+}
+
+char _license[] SEC("license") = "GPL";

  reply	other threads:[~2025-04-22 20:30 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 16:14 [RFC PATCH bpf-next/net v1 00/13] BPF Standard Streams Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 01/13] bpf: Tie dynptrs to referenced source objects Kumar Kartikeya Dwivedi
2025-04-14 19:58   ` Amery Hung
2025-04-17 19:53     ` Kumar Kartikeya Dwivedi
2025-04-16  5:52   ` Eduard Zingerman
2025-04-17 19:52     ` Kumar Kartikeya Dwivedi
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 19:51     ` Kumar Kartikeya Dwivedi
2025-04-22 21:09       ` Andrii Nakryiko
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 02/13] bpf: Compare dynptr_id in regsafe Kumar Kartikeya Dwivedi
2025-04-16  7:58   ` Eduard Zingerman
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 19:54     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 03/13] selftests/bpf: Convert dynptr_fail to use vmlinux.h Kumar Kartikeya Dwivedi
2025-04-16  8:41   ` Eduard Zingerman
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 04/13] selftests/bpf: Add tests for dynptr source object interaction Kumar Kartikeya Dwivedi
2025-04-16  8:40   ` Eduard Zingerman
2025-04-17 20:09     ` Kumar Kartikeya Dwivedi
2025-04-17 20:44       ` Eduard Zingerman
2025-04-17 21:10         ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 05/13] locking/local_lock, mm: Replace localtry_ helpers with local_trylock_t type Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 06/13] bpf: Introduce bpf_dynptr_from_mem_slice Kumar Kartikeya Dwivedi
2025-04-16 17:36   ` Eduard Zingerman
2025-04-17 20:07     ` Kumar Kartikeya Dwivedi
2025-04-16 21:04   ` Andrii Nakryiko
2025-04-17 20:07     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 07/13] bpf: Introduce per-prog stdout/stderr streams Kumar Kartikeya Dwivedi
2025-04-16 21:49   ` Eduard Zingerman
2025-04-17 20:06     ` Kumar Kartikeya Dwivedi
2025-04-22  1:42       ` Alexei Starovoitov
2025-04-22  2:30         ` Kumar Kartikeya Dwivedi
2025-04-22 17:44           ` Alexei Starovoitov
2025-04-22 22:09       ` Eduard Zingerman
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 08/13] bpf: Add dump_stack() analogue to print to BPF stderr Kumar Kartikeya Dwivedi
2025-04-22 21:07   ` Eduard Zingerman
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 09/13] bpf: Report may_goto timeout " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 10/13] bpf: Report rqspinlock deadlocks/timeout " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 11/13] bpf: Report arena faults " Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 12/13] bpftool: Add support for dumping streams Kumar Kartikeya Dwivedi
2025-04-22 20:30   ` Eduard Zingerman [this message]
2025-04-22 22:10   ` Quentin Monnet
2025-05-07 17:13     ` Kumar Kartikeya Dwivedi
2025-04-14 16:14 ` [RFC PATCH bpf-next/net v1 13/13] selftests/bpf: Add tests for prog streams Kumar Kartikeya Dwivedi
2025-04-22 19:12   ` Eduard Zingerman

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=m2wmbcq6qt.fsf@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brho@google.com \
    --cc=daniel@iogearbox.net \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.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).