Skip to content

Commit f5717c9

Browse files
kchuyizhouhtejun
authored andcommitted
sched_ext: Use SCX_CALL_OP_TASK in task_tick_scx
Now when we use scx_bpf_task_cgroup() in ops.tick() to get the cgroup of the current task, the following error will occur: scx_foo[3795244] triggered exit kind 1024: runtime error (called on a task not being operated on) The reason is that we are using SCX_CALL_OP() instead of SCX_CALL_OP_TASK() when calling ops.tick(), which triggers the error during the subsequent scx_kf_allowed_on_arg_tasks() check. SCX_CALL_OP_TASK() was first introduced in commit 3645402 ("sched_ext: Track tasks that are subjects of the in-flight SCX operation") to ensure task's rq lock is held when accessing task's sched_group. Since ops.tick() is marked as SCX_KF_TERMINAL and task_tick_scx() is protected by the rq lock, we can use SCX_CALL_OP_TASK() to avoid the above issue. Similarly, the same changes should be made for ops.disable() and ops.exit_task(), as they are also protected by task_rq_lock() and it's safe to access the task's task_group. Fixes: 3645402 ("sched_ext: Track tasks that are subjects of the in-flight SCX operation") Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 2e2006c commit f5717c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/sched/ext.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,7 +3899,7 @@ static void task_tick_scx(struct rq *rq, struct task_struct *curr, int queued)
38993899
curr->scx.slice = 0;
39003900
touch_core_sched(rq, curr);
39013901
} else if (SCX_HAS_OP(tick)) {
3902-
SCX_CALL_OP(SCX_KF_REST, tick, curr);
3902+
SCX_CALL_OP_TASK(SCX_KF_REST, tick, curr);
39033903
}
39043904

39053905
if (!curr->scx.slice)
@@ -4046,7 +4046,7 @@ static void scx_ops_disable_task(struct task_struct *p)
40464046
WARN_ON_ONCE(scx_get_task_state(p) != SCX_TASK_ENABLED);
40474047

40484048
if (SCX_HAS_OP(disable))
4049-
SCX_CALL_OP(SCX_KF_REST, disable, p);
4049+
SCX_CALL_OP_TASK(SCX_KF_REST, disable, p);
40504050
scx_set_task_state(p, SCX_TASK_READY);
40514051
}
40524052

@@ -4075,7 +4075,7 @@ static void scx_ops_exit_task(struct task_struct *p)
40754075
}
40764076

40774077
if (SCX_HAS_OP(exit_task))
4078-
SCX_CALL_OP(SCX_KF_REST, exit_task, p, &args);
4078+
SCX_CALL_OP_TASK(SCX_KF_REST, exit_task, p, &args);
40794079
scx_set_task_state(p, SCX_TASK_NONE);
40804080
}
40814081

0 commit comments

Comments
 (0)