Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Improve comment on idle_sched_class exception in scx_task_iter_next_locked()

scx_task_iter_next_locked() skips tasks whose sched_class is
idle_sched_class. While it has a short comment explaining why it's testing
the sched_class directly isntead of using is_idle_task(), the comment
doesn't sufficiently explain what's going on and why. Improve the comment.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: David Vernet <void@manifault.com>

+23 -2
+23 -2
kernel/sched/ext.c
··· 1252 1252 1253 1253 while ((p = scx_task_iter_next(iter))) { 1254 1254 /* 1255 - * is_idle_task() tests %PF_IDLE which may not be set for CPUs 1256 - * which haven't yet been onlined. Test sched_class directly. 1255 + * scx_task_iter is used to prepare and move tasks into SCX 1256 + * while loading the BPF scheduler and vice-versa while 1257 + * unloading. The init_tasks ("swappers") should be excluded 1258 + * from the iteration because: 1259 + * 1260 + * - It's unsafe to use __setschduler_prio() on an init_task to 1261 + * determine the sched_class to use as it won't preserve its 1262 + * idle_sched_class. 1263 + * 1264 + * - ops.init/exit_task() can easily be confused if called with 1265 + * init_tasks as they, e.g., share PID 0. 1266 + * 1267 + * As init_tasks are never scheduled through SCX, they can be 1268 + * skipped safely. Note that is_idle_task() which tests %PF_IDLE 1269 + * doesn't work here: 1270 + * 1271 + * - %PF_IDLE may not be set for an init_task whose CPU hasn't 1272 + * yet been onlined. 1273 + * 1274 + * - %PF_IDLE can be set on tasks that are not init_tasks. See 1275 + * play_idle_precise() used by CONFIG_IDLE_INJECT. 1276 + * 1277 + * Test for idle_sched_class as only init_tasks are on it. 1257 1278 */ 1258 1279 if (p->sched_class != &idle_sched_class) 1259 1280 break;