bpf: Make session kfuncs global
Subsystems (5)
Jiri Olsa
reviewerPATCH 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
--- kernel/trace/bpf_trace.c | 2 -- 1 file changed, 2 deletions(-)
kernel/trace/bpf_trace.c +0 -2
@@ -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
Quoted 6 lines · Jiri Olsa
The
bpf_session_cookieis 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
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Jiri Olsa
The
bpf_session_cookieis 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 aboutCONFIG_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
Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Jiri Olsa
The
bpf_session_cookieis 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 aboutCONFIG_UPROBE_EVENTS=n?hum, I can't see that.. also I tested it with
CONFIG_UPROBE_EVENTS=n, theCONFIG_UPROBESifdef is ended right above this code..
Your patch + v6.10-rc1 + https://breakpoint.cc/config-2024-03-31.xz
Quoted 1 line
jirka
Sebastian
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_cookieis 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 aboutCONFIG_UPROBE_EVENTS=n?hum, I can't see that.. also I tested it with
CONFIG_UPROBE_EVENTS=n, theCONFIG_UPROBESifdef 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
@@ -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
@@ -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
Sebastian Andrzej Siewior
Tested-byQuoted 9 lines · Jiri Olsa
ah there's also
CONFIG_KPROBE=n
kernel/trace/bpf_trace.cis enabled withCONFIG_BPF_EVENTS, which has:depends on
BPF_SYSCALL
depends on (KPROBE_EVENTS||UPROBE_EVENTS) &&PERF_EVENTSso I think we chould combine both like below
Yes, this would work.
Quoted 1 line
jirka
Sebastian
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Jiri Olsa
ah there's also
CONFIG_KPROBE=n
kernel/trace/bpf_trace.cis enabled withCONFIG_BPF_EVENTS, which has:
Quoted 6 lines
Quoted 4 lines
depends on
BPF_SYSCALL
depends on (KPROBE_EVENTS||UPROBE_EVENTS) &&PERF_EVENTSso I think we chould combine both like below
Yes, this would work.
Makes sense to me as well. Pls respin.