From: Jiri Olsa <olsajiri@gmail.com>
To: Dmitrii Dolgov <9erthalion6@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, dan.carpenter@linaro.org,
olsajiri@gmail.com
Subject: Re: [PATCH bpf-next v4 2/3] selftests/bpf: Add test for recursive attachment of tracing progs
Date: Thu, 30 Nov 2023 15:47:19 +0100 [thread overview]
Message-ID: <ZWigd7sMA2nVM0rf@krava> (raw)
In-Reply-To: <20231129195240.19091-3-9erthalion6@gmail.com>
On Wed, Nov 29, 2023 at 08:52:37PM +0100, Dmitrii Dolgov wrote:
SNIP
> +void test_recursive_fentry_attach(void)
> +{
> + struct fentry_recursive_target *target_skel = NULL;
> + struct fentry_recursive *tracing_chain[ATTACH_DEPTH + 1] = {};
> + struct bpf_program *prog;
> + int prev_fd, err;
> +
> + target_skel = fentry_recursive_target__open_and_load();
> + if (!ASSERT_OK_PTR(target_skel, "fentry_recursive_target__open_and_load"))
> + goto close_prog;
> +
> + /* This is going to be the start of the chain */
> + tracing_chain[0] = fentry_recursive__open();
> + if (!ASSERT_OK_PTR(tracing_chain[0], "fentry_recursive__open"))
> + goto close_prog;
> +
> + prog = tracing_chain[0]->progs.recursive_attach;
> + prev_fd = bpf_program__fd(target_skel->progs.test1);
> + err = bpf_program__set_attach_target(prog, prev_fd, "test1");
> + if (!ASSERT_OK(err, "bpf_program__set_attach_target"))
> + goto close_prog;
> +
> + err = fentry_recursive__load(tracing_chain[0]);
> + if (!ASSERT_OK(err, "fentry_recursive__load"))
> + goto close_prog;
should you call fentry_recursive__attach in here as well?
> +
> + /* Create an attachment chain to exhaust the limit */
> + for (int i = 1; i < ATTACH_DEPTH; i++) {
> + tracing_chain[i] = fentry_recursive__open();
> + if (!ASSERT_OK_PTR(tracing_chain[i], "fentry_recursive__open"))
> + goto close_prog;
> +
> + prog = tracing_chain[i]->progs.recursive_attach;
> + prev_fd = bpf_program__fd(tracing_chain[i-1]->progs.recursive_attach);
or maybe better brach here for (i == 0) and call
bpf_program__set_attach_target(prog, prev_fd, "test1");
> + err = bpf_program__set_attach_target(prog, prev_fd, "recursive_attach");
> + if (!ASSERT_OK(err, "bpf_program__set_attach_target"))
> + goto close_prog;
> +
> + err = fentry_recursive__load(tracing_chain[i]);
> + if (!ASSERT_OK(err, "fentry_recursive__load"))
> + goto close_prog;
> +
> + err = fentry_recursive__attach(tracing_chain[i]);
> + if (!ASSERT_OK(err, "fentry_recursive__attach"))
> + goto close_prog;
> + }
> +
> + /* The next attachment would fail */
> + tracing_chain[ATTACH_DEPTH] = fentry_recursive__open();
> + if (!ASSERT_OK_PTR(tracing_chain[ATTACH_DEPTH], "last fentry_recursive__open"))
> + goto close_prog;
> +
> + prog = tracing_chain[ATTACH_DEPTH]->progs.recursive_attach;
> + prev_fd = bpf_program__fd(tracing_chain[ATTACH_DEPTH - 1]->progs.recursive_attach);
> + err = bpf_program__set_attach_target(prog, prev_fd, "recursive_attach");
> + if (!ASSERT_OK(err, "last bpf_program__set_attach_target"))
> + goto close_prog;
> +
> + err = fentry_recursive__load(tracing_chain[ATTACH_DEPTH]);
> + if (!ASSERT_ERR(err, "last fentry_recursive__load"))
> + goto close_prog;
> +
> +close_prog:
> + fentry_recursive_target__destroy(target_skel);
> + for (int i = 1; i < ATTACH_DEPTH + 1; i++) {
i = 0 ?
jirka
> + if (tracing_chain[i])
> + fentry_recursive__destroy(tracing_chain[i]);
> + }
> +}
SNIP
next prev parent reply other threads:[~2023-11-30 14:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 19:52 [PATCH bpf-next v4 0/3] Relax tracing prog recursive attach rules Dmitrii Dolgov
2023-11-29 19:52 ` [PATCH bpf-next v4 1/3] bpf: " Dmitrii Dolgov
2023-11-29 23:58 ` Song Liu
2023-11-30 10:08 ` Dmitry Dolgov
2023-11-30 20:19 ` Song Liu
2023-11-30 20:41 ` Dmitry Dolgov
2023-12-01 9:55 ` Artem Savkov
2023-12-01 14:29 ` Dmitry Dolgov
2023-11-30 14:30 ` Jiri Olsa
2023-11-30 18:57 ` Dmitry Dolgov
2023-11-30 22:34 ` Jiri Olsa
2023-11-29 19:52 ` [PATCH bpf-next v4 2/3] selftests/bpf: Add test for recursive attachment of tracing progs Dmitrii Dolgov
2023-11-30 14:47 ` Jiri Olsa [this message]
2023-11-29 19:52 ` [PATCH bpf-next v4 3/3] bpf, selftest/bpf: Fix re-attachment branch in bpf_tracing_prog_attach Dmitrii Dolgov
2023-11-30 15:14 ` Jiri Olsa
2023-11-30 22:30 ` Jiri Olsa
2023-12-01 14:21 ` Dmitry Dolgov
2023-12-01 14:52 ` Jiri Olsa
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=ZWigd7sMA2nVM0rf@krava \
--to=olsajiri@gmail.com \
--cc=9erthalion6@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=daniel@iogearbox.net \
--cc=martin.lau@linux.dev \
--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