Skip to content

Commit

Permalink
Merge pull request torvalds#43 from sched-ext/kfunc_tracepoints
Browse files Browse the repository at this point in the history
scx: Allow calling some kfuncs from tracepoints
  • Loading branch information
htejun committed Aug 8, 2023
2 parents aeaacb3 + f2625bf commit 36d4880
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kernel/sched/ext.c
Expand Up @@ -4365,17 +4365,25 @@ struct cgroup *scx_bpf_task_cgroup(struct task_struct *p)
}
#endif

BTF_SET8_START(scx_kfunc_ids_any)
BTF_SET8_START(scx_kfunc_ids_ops_only)
BTF_ID_FLAGS(func, scx_bpf_kick_cpu)
BTF_ID_FLAGS(func, scx_bpf_dsq_nr_queued)
BTF_ID_FLAGS(func, scx_bpf_test_and_clear_cpu_idle)
BTF_ID_FLAGS(func, scx_bpf_pick_idle_cpu, KF_RCU)
BTF_ID_FLAGS(func, scx_bpf_pick_any_cpu, KF_RCU)
BTF_ID_FLAGS(func, scx_bpf_destroy_dsq)
BTF_SET8_END(scx_kfunc_ids_ops_only)

static const struct btf_kfunc_id_set scx_kfunc_set_ops_only = {
.owner = THIS_MODULE,
.set = &scx_kfunc_ids_ops_only,
};

BTF_SET8_START(scx_kfunc_ids_any)
BTF_ID_FLAGS(func, scx_bpf_get_idle_cpumask, KF_ACQUIRE)
BTF_ID_FLAGS(func, scx_bpf_get_idle_smtmask, KF_ACQUIRE)
BTF_ID_FLAGS(func, scx_bpf_put_idle_cpumask, KF_RELEASE)
BTF_ID_FLAGS(func, scx_bpf_error_bstr, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, scx_bpf_destroy_dsq)
BTF_ID_FLAGS(func, scx_bpf_task_running, KF_RCU)
BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
#ifdef CONFIG_CGROUP_SCHED
Expand Down Expand Up @@ -4417,6 +4425,10 @@ static int __init register_ext_kfuncs(void)
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_cpu_release)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_ops_only)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&scx_kfunc_set_any)) ||
(ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING,
&scx_kfunc_set_any))) {
pr_err("sched_ext: failed to register kfunc sets (%d)\n", ret);
return ret;
Expand Down

0 comments on commit 36d4880

Please sign in to comment.