Re: [PATCH 02/13] sched_ext: Make slice values tunable and use shorter slice in bypass mode

From: Dan Schatzberg

Date: Tue Nov 11 2025 - 09:57:49 EST


On Sun, Nov 09, 2025 at 08:31:01AM -1000, Tejun Heo wrote:
> @@ -919,7 +948,7 @@ static void dsq_mod_nr(struct scx_dispatch_q *dsq, s32 delta)
>
> static void refill_task_slice_dfl(struct scx_sched *sch, struct task_struct *p)
> {
> - p->scx.slice = SCX_SLICE_DFL;
> + p->scx.slice = scx_slice_dfl;

Do you need to use READ_ONCE here given that this can be modified concurrently?

> __scx_add_event(sch, SCX_EV_REFILL_SLICE_DFL, 1);
> }
>
> @@ -2892,7 +2921,7 @@ void init_scx_entity(struct sched_ext_entity *scx)
> INIT_LIST_HEAD(&scx->runnable_node);
> scx->runnable_at = jiffies;
> scx->ddsp_dsq_id = SCX_DSQ_INVALID;
> - scx->slice = SCX_SLICE_DFL;
> + scx->slice = scx_slice_dfl;
> }
>
> void scx_pre_fork(struct task_struct *p)
> @@ -3770,6 +3799,7 @@ static void scx_bypass(bool bypass)
> WARN_ON_ONCE(scx_bypass_depth <= 0);
> if (scx_bypass_depth != 1)
> goto unlock;
> + scx_slice_dfl = scx_slice_bypass_us * NSEC_PER_USEC;

Similarly WRITE_ONCE here

> bypass_timestamp = ktime_get_ns();
> if (sch)
> scx_add_event(sch, SCX_EV_BYPASS_ACTIVATE, 1);
> @@ -3778,6 +3808,7 @@ static void scx_bypass(bool bypass)
> WARN_ON_ONCE(scx_bypass_depth < 0);
> if (scx_bypass_depth != 0)
> goto unlock;
> + scx_slice_dfl = scx_slice_dfl_us * NSEC_PER_USEC;

And here

> if (sch)
> scx_add_event(sch, SCX_EV_BYPASS_DURATION,
> ktime_get_ns() - bypass_timestamp);
> @@ -4776,7 +4807,7 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link)
> queue_flags |= DEQUEUE_CLASS;
>
> scoped_guard (sched_change, p, queue_flags) {
> - p->scx.slice = SCX_SLICE_DFL;
> + p->scx.slice = scx_slice_dfl;

And here
> p->sched_class = new_class;
> }
> }
> --
> 2.51.1
>