Skip to content

Commit 57ccf5c

Browse files
committed
sched_ext: Fix enqueue_task_scx() truncation of upper enqueue flags
enqueue_task_scx() takes int enq_flags from the sched_class interface. SCX enqueue flags starting at bit 32 (SCX_ENQ_PREEMPT and above) are silently truncated when passed through activate_task(). extra_enq_flags was added as a workaround - storing high bits in rq->scx.extra_enq_flags and OR-ing them back in enqueue_task_scx(). However, the OR target is still the int parameter, so the high bits are lost anyway. The current impact is limited as the only affected flag is SCX_ENQ_PREEMPT which is informational to the BPF scheduler - its loss means the scheduler doesn't know about preemption but doesn't cause incorrect behavior. Fix by renaming the int parameter to core_enq_flags and introducing a u64 enq_flags local that merges both sources. All downstream functions already take u64 enq_flags. Fixes: f0e1a06 ("sched_ext: Implement BPF extensible scheduler class") Cc: [email protected] # v6.12+ Acked-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 2a0596d commit 57ccf5c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

kernel/sched/ext.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,16 +1470,15 @@ static void clr_task_runnable(struct task_struct *p, bool reset_runnable_at)
14701470
p->scx.flags |= SCX_TASK_RESET_RUNNABLE_AT;
14711471
}
14721472

1473-
static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int enq_flags)
1473+
static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_flags)
14741474
{
14751475
struct scx_sched *sch = scx_root;
14761476
int sticky_cpu = p->scx.sticky_cpu;
1477+
u64 enq_flags = core_enq_flags | rq->scx.extra_enq_flags;
14771478

14781479
if (enq_flags & ENQUEUE_WAKEUP)
14791480
rq->scx.flags |= SCX_RQ_IN_WAKEUP;
14801481

1481-
enq_flags |= rq->scx.extra_enq_flags;
1482-
14831482
if (sticky_cpu >= 0)
14841483
p->scx.sticky_cpu = -1;
14851484

0 commit comments

Comments
 (0)