mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
sched_ext: Add the @sch parameter to scx_dsq_insert_preamble/commit()
In preparation for multiple scheduler support, add the @sch parameter to scx_dsq_insert_preamble/commit() and update the callers to read $scx_root and pass it in. The passed in @sch parameter is not used yet. Reviewed-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
956f2b11a8
commit
4d9553fee3
|
|
@ -5240,7 +5240,8 @@ void __init init_sched_ext_class(void)
|
|||
/********************************************************************************
|
||||
* Helpers that can be called from the BPF scheduler.
|
||||
*/
|
||||
static bool scx_dsq_insert_preamble(struct task_struct *p, u64 enq_flags)
|
||||
static bool scx_dsq_insert_preamble(struct scx_sched *sch, struct task_struct *p,
|
||||
u64 enq_flags)
|
||||
{
|
||||
if (!scx_kf_allowed(SCX_KF_ENQUEUE | SCX_KF_DISPATCH))
|
||||
return false;
|
||||
|
|
@ -5260,8 +5261,8 @@ static bool scx_dsq_insert_preamble(struct task_struct *p, u64 enq_flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void scx_dsq_insert_commit(struct task_struct *p, u64 dsq_id,
|
||||
u64 enq_flags)
|
||||
static void scx_dsq_insert_commit(struct scx_sched *sch, struct task_struct *p,
|
||||
u64 dsq_id, u64 enq_flags)
|
||||
{
|
||||
struct scx_dsp_ctx *dspc = this_cpu_ptr(scx_dsp_ctx);
|
||||
struct task_struct *ddsp_task;
|
||||
|
|
@ -5325,7 +5326,14 @@ __bpf_kfunc_start_defs();
|
|||
__bpf_kfunc void scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice,
|
||||
u64 enq_flags)
|
||||
{
|
||||
if (!scx_dsq_insert_preamble(p, enq_flags))
|
||||
struct scx_sched *sch;
|
||||
|
||||
guard(rcu)();
|
||||
sch = rcu_dereference(scx_root);
|
||||
if (unlikely(!sch))
|
||||
return;
|
||||
|
||||
if (!scx_dsq_insert_preamble(sch, p, enq_flags))
|
||||
return;
|
||||
|
||||
if (slice)
|
||||
|
|
@ -5333,7 +5341,7 @@ __bpf_kfunc void scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice
|
|||
else
|
||||
p->scx.slice = p->scx.slice ?: 1;
|
||||
|
||||
scx_dsq_insert_commit(p, dsq_id, enq_flags);
|
||||
scx_dsq_insert_commit(sch, p, dsq_id, enq_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -5360,7 +5368,14 @@ __bpf_kfunc void scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice
|
|||
__bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
|
||||
u64 slice, u64 vtime, u64 enq_flags)
|
||||
{
|
||||
if (!scx_dsq_insert_preamble(p, enq_flags))
|
||||
struct scx_sched *sch;
|
||||
|
||||
guard(rcu)();
|
||||
sch = rcu_dereference(scx_root);
|
||||
if (unlikely(!sch))
|
||||
return;
|
||||
|
||||
if (!scx_dsq_insert_preamble(sch, p, enq_flags))
|
||||
return;
|
||||
|
||||
if (slice)
|
||||
|
|
@ -5370,7 +5385,7 @@ __bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
|
|||
|
||||
p->scx.dsq_vtime = vtime;
|
||||
|
||||
scx_dsq_insert_commit(p, dsq_id, enq_flags | SCX_ENQ_DSQ_PRIQ);
|
||||
scx_dsq_insert_commit(sch, p, dsq_id, enq_flags | SCX_ENQ_DSQ_PRIQ);
|
||||
}
|
||||
|
||||
__bpf_kfunc_end_defs();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user