BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>
Subject: [RFC] bpf: Issue with bpf_fentry_test7 call
Date: Fri, 15 Dec 2023 10:16:27 +0100	[thread overview]
Message-ID: <ZXwZa_eK7bWXjJk7@krava> (raw)

hi,   
The bpf CI is broken due to clang emitting 2 functions for
bpf_fentry_test7:

  # cat available_filter_functions | grep bpf_fentry_test7
  bpf_fentry_test7
  bpf_fentry_test7.specialized.1

The tests attach to 'bpf_fentry_test7' while the function with
'.specialized.1' suffix is executed in bpf_prog_test_run_tracing.

It looks like clang optimalization that comes from passing 0
as argument and returning it directly in bpf_fentry_test7.

I'm not sure there's a way to disable this, so far I came
up with solution below that passes real pointer, but I think
that was not the original intention for the test.

We had issue with this function back in august:
  32337c0a2824 bpf: Prevent inlining of bpf_fentry_test7()

I'm not sure why it started to show now? was clang updated for CI?

I'll try to find out more, but any clang ideas are welcome ;-)

thanks,
jirka


---
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index c9fdcc5cdce1..33208eec9361 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -543,7 +543,7 @@ struct bpf_fentry_test_t {
 int noinline bpf_fentry_test7(struct bpf_fentry_test_t *arg)
 {
 	asm volatile ("");
-	return (long)arg;
+	return 0;
 }
 
 int noinline bpf_fentry_test8(struct bpf_fentry_test_t *arg)
@@ -668,7 +668,7 @@ int bpf_prog_test_run_tracing(struct bpf_prog *prog,
 		    bpf_fentry_test4((void *)7, 8, 9, 10) != 34 ||
 		    bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 ||
 		    bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111 ||
-		    bpf_fentry_test7((struct bpf_fentry_test_t *)0) != 0 ||
+		    bpf_fentry_test7(&arg) != 0 ||
 		    bpf_fentry_test8(&arg) != 0 ||
 		    bpf_fentry_test9(&retval) != 0)
 			goto out;
diff --git a/tools/testing/selftests/bpf/progs/fentry_test.c b/tools/testing/selftests/bpf/progs/fentry_test.c
index 52a550d281d9..95c5c34ccaa8 100644
--- a/tools/testing/selftests/bpf/progs/fentry_test.c
+++ b/tools/testing/selftests/bpf/progs/fentry_test.c
@@ -64,7 +64,7 @@ __u64 test7_result = 0;
 SEC("fentry/bpf_fentry_test7")
 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 {
-	if (!arg)
+	if (arg)
 		test7_result = 1;
 	return 0;
 }
diff --git a/tools/testing/selftests/bpf/progs/fexit_test.c b/tools/testing/selftests/bpf/progs/fexit_test.c
index 8f1ccb7302e1..ffb30236ca02 100644
--- a/tools/testing/selftests/bpf/progs/fexit_test.c
+++ b/tools/testing/selftests/bpf/progs/fexit_test.c
@@ -65,7 +65,7 @@ __u64 test7_result = 0;
 SEC("fexit/bpf_fentry_test7")
 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 {
-	if (!arg)
+	if (arg)
 		test7_result = 1;
 	return 0;
 }

             reply	other threads:[~2023-12-15  9:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15  9:16 Jiri Olsa [this message]
2023-12-15  9:43 ` [RFC] bpf: Issue with bpf_fentry_test7 call Jiri Olsa
2023-12-15 14:24 ` Jiri Olsa
2023-12-15 14:42   ` Yonghong Song
2023-12-15 21:22     ` Andrii Nakryiko
2023-12-15 23:21       ` 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=ZXwZa_eK7bWXjJk7@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.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