Skip to content

Commit 6f34d8d

Browse files
committed
sched_ext: Use shorter slice while bypassing
While bypassing, tasks are scheduled in FIFO order which favors tasks that hog CPUs. This can slow down e.g. unloading of the BPF scheduler. While bypassing, guaranteeing timely forward progress is the main goal. There's no point in giving long slices. Shorten the time slice used while bypassing from 20ms to 5ms. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent b7b3b2d commit 6f34d8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/sched/ext.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define SCX_OP_IDX(op) (offsetof(struct sched_ext_ops, op) / sizeof(void (*)(void)))
1010

1111
enum scx_consts {
12+
SCX_SLICE_BYPASS = SCX_SLICE_DFL / 4,
1213
SCX_DSP_DFL_MAX_BATCH = 32,
1314
SCX_DSP_MAX_LOOPS = 32,
1415
SCX_WATCHDOG_MAX_TIMEOUT = 30 * HZ,
@@ -1944,6 +1945,7 @@ static bool scx_rq_online(struct rq *rq)
19441945
static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
19451946
int sticky_cpu)
19461947
{
1948+
bool bypassing = scx_rq_bypassing(rq);
19471949
struct task_struct **ddsp_taskp;
19481950
unsigned long qseq;
19491951

@@ -1961,7 +1963,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
19611963
if (!scx_rq_online(rq))
19621964
goto local;
19631965

1964-
if (scx_rq_bypassing(rq))
1966+
if (bypassing)
19651967
goto global;
19661968

19671969
if (p->scx.ddsp_dsq_id != SCX_DSQ_INVALID)
@@ -2016,7 +2018,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
20162018

20172019
global:
20182020
touch_core_sched(rq, p); /* see the comment in local: */
2019-
p->scx.slice = SCX_SLICE_DFL;
2021+
p->scx.slice = bypassing ? SCX_SLICE_BYPASS : SCX_SLICE_DFL;
20202022
dispatch_enqueue(find_global_dsq(p), p, enq_flags);
20212023
}
20222024

0 commit comments

Comments
 (0)