Skip to content

Commit 450bc73

Browse files
rgushchinKernel Patches Daemon
authored andcommitted
bpf: allow calling bpf_out_of_memory() from a PSI tracepoint
Allow calling bpf_out_of_memory() from a PSI tracepoint to enable PSI-based OOM killer policies. Signed-off-by: Roman Gushchin <[email protected]>
1 parent f5e3c1a commit 450bc73

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mm/oom_kill.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,13 @@ BTF_KFUNCS_START(bpf_declare_oom_kfuncs)
14211421
BTF_ID_FLAGS(func, bpf_out_of_memory, KF_SLEEPABLE)
14221422
BTF_KFUNCS_END(bpf_declare_oom_kfuncs)
14231423

1424+
BTF_ID_LIST(bpf_oom_trace_ids)
1425+
#ifdef CONFIG_PSI
1426+
BTF_ID(typedef, btf_trace_psi_avgs_work)
1427+
#else
1428+
BTF_ID_UNUSED
1429+
#endif
1430+
14241431
static int bpf_declare_oom_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
14251432
{
14261433
if (!btf_id_set8_contains(&bpf_declare_oom_kfuncs, kfunc_id))
@@ -1430,7 +1437,8 @@ static int bpf_declare_oom_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_i
14301437
prog->aux->attach_btf_id == bpf_oom_ops_ids[0])
14311438
return -EACCES;
14321439

1433-
if (prog->type == BPF_PROG_TYPE_TRACING)
1440+
if (prog->type == BPF_PROG_TYPE_TRACING &&
1441+
prog->aux->attach_btf_id != bpf_oom_trace_ids[0])
14341442
return -EACCES;
14351443

14361444
return 0;

0 commit comments

Comments
 (0)