Skip to contentSkip to conversation

bpf: Make session kfuncs global

PATCH In review Jiri Olsa 4 participants 7 messages May 31, 2024

Subsystems (5)
BPF Tracing BPF core BPF tracing +1 more subsystems
lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 bpf: Make session kfuncs global

The bpf_session_cookie is unavailable for !CONFIG_FPROBE as reported by Sebastian [1].

Instead of adding more ifdefs, making the session kfuncs globally available as suggested by Alexei. It's still allowed only for session programs, but it won't fail the build.

[1] https://lore.kernel.org/bpf/[email protected]/T/#m71c6d5ec71db2967288cb79acedc15cc5dbfeec5

Fixes 5c919acef8514 ("bpf: Add support for kprobe session cookie")
---
 kernel/trace/bpf_trace.c | 2 --
 1 file changed, 2 deletions(-)
kernel/trace/bpf_trace.c +0 -2
index f5154c051d2c..cc90d56732eb 100644
@@ -3519,7 +3519,6 @@ static u64 bpf_uprobe_multi_entry_ip(struct bpf_run_ctx *ctx)
 }
 #endif /* CONFIG_UPROBES */
 
-#ifdef CONFIG_FPROBE
 __bpf_kfunc_start_defs();
 
 __bpf_kfunc bool bpf_session_is_return(void)
@@ -3568,4 +3567,3 @@ static int __init bpf_kprobe_multi_kfuncs_init(void)
 }
 
 late_initcall(bpf_kprobe_multi_kfuncs_init);
-#endif
Signature · 1 line
2.45.1
#1 lore raw
Quoted 6 lines · Jiri Olsa

The bpf_session_cookie is unavailable for !CONFIG_FPROBE as reported by Sebastian [1].

Instead of adding more ifdefs, making the session kfuncs globally available as suggested by Alexei. It's still allowed only for session programs, but it won't fail the build.

but this relies on CONFIG_UPROBE_EVENTS=y
What about CONFIG_UPROBE_EVENTS=n?

Sebastian

#2 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Jiri Olsa

The bpf_session_cookie is unavailable for !CONFIG_FPROBE as reported by Sebastian [1].

Instead of adding more ifdefs, making the session kfuncs globally available as suggested by Alexei. It's still allowed only for session programs, but it won't fail the build.

but this relies on CONFIG_UPROBE_EVENTS=y
What about CONFIG_UPROBE_EVENTS=n?

hum, I can't see that.. also I tested it with CONFIG_UPROBE_EVENTS=n, the CONFIG_UPROBES ifdef is ended right above this code..

jirka

Quoted 2 lines

Sebastian

#3 lore raw
Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Jiri Olsa

The bpf_session_cookie is unavailable for !CONFIG_FPROBE as reported by Sebastian [1].

Instead of adding more ifdefs, making the session kfuncs globally available as suggested by Alexei. It's still allowed only for session programs, but it won't fail the build.

Quoted 5 lines
Quoted 2 lines

but this relies on CONFIG_UPROBE_EVENTS=y
What about CONFIG_UPROBE_EVENTS=n?

hum, I can't see that.. also I tested it with CONFIG_UPROBE_EVENTS=n, the CONFIG_UPROBES ifdef is ended right above this code..

Your patch + v6.10-rc1 + https://breakpoint.cc/config-2024-03-31.xz

Quoted 1 line

jirka

Sebastian

#4 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Jiri Olsa

The bpf_session_cookie is unavailable for !CONFIG_FPROBE as reported by Sebastian [1].

Instead of adding more ifdefs, making the session kfuncs globally available as suggested by Alexei. It's still allowed only for session programs, but it won't fail the build.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

but this relies on CONFIG_UPROBE_EVENTS=y
What about CONFIG_UPROBE_EVENTS=n?

hum, I can't see that.. also I tested it with CONFIG_UPROBE_EVENTS=n, the CONFIG_UPROBES ifdef is ended right above this code..

Your patch + v6.10-rc1 + https://breakpoint.cc/config-2024-03-31.xz

ah there's also CONFIG_KPROBE=n

kernel/trace/bpf_trace.c is enabled with CONFIG_BPF_EVENTS, which has:

depends on BPF_SYSCALL
depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS

so I think we chould combine both like below

jirka

---

kernel/bpf/verifier.c +4 -0
index 77da1f438bec..cb202a289cf6 100644
@@ -11124,7 +11124,11 @@ BTF_ID(func, bpf_iter_css_task_new)
 #else
 BTF_ID_UNUSED
 #endif
+#ifdef CONFIG_BPF_EVENTS
 BTF_ID(func, bpf_session_cookie)
+#else
+BTF_ID_UNUSED
+#endif
 
 static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)
 {
kernel/trace/bpf_trace.c +0 -2
index f5154c051d2c..cc90d56732eb 100644
@@ -3519,7 +3519,6 @@ static u64 bpf_uprobe_multi_entry_ip(struct bpf_run_ctx *ctx)
 }
 #endif /* CONFIG_UPROBES */
 
-#ifdef CONFIG_FPROBE
 __bpf_kfunc_start_defs();
 
 __bpf_kfunc bool bpf_session_is_return(void)
@@ -3568,4 +3567,3 @@ static int __init bpf_kprobe_multi_kfuncs_init(void)
 }
 
 late_initcall(bpf_kprobe_multi_kfuncs_init);
-#endif
#5 lore raw
Quoted 9 lines · Jiri Olsa

ah there's also CONFIG_KPROBE=n

kernel/trace/bpf_trace.c is enabled with CONFIG_BPF_EVENTS, which has:

depends on BPF_SYSCALL
depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS

so I think we chould combine both like below

Yes, this would work.

Quoted 1 line

jirka

Sebastian

#6 lore raw
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Jiri Olsa

ah there's also CONFIG_KPROBE=n

kernel/trace/bpf_trace.c is enabled with CONFIG_BPF_EVENTS, which has:

Quoted 6 lines
Quoted 4 lines

depends on BPF_SYSCALL
depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS

so I think we chould combine both like below

Yes, this would work.

Makes sense to me as well. Pls respin.