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: Use SCX_TASK_READY test instead of tryget_task_struct() during class switch

ddf7233fcab6 ("sched/ext: Fix invalid task state transitions on class
switch") added tryget_task_struct() test during scx_enable()'s class
switching loop. The reason for the addition was to avoid enabling tasks which
skipped prep in the previous loop due to being dead.

While tryget_task_struct() does work for this purpose as tasks that fail
tryget always will fail it, it's a bit roundabout. A more direct way is
testing whether the task is in READY state. Switch to testing SCX_TASK_READY
directly.

Cc: Andrea Righi <arighi@nvidia.com>
Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Tejun Heo b7d4b28d dcb938c4

+1 -3
+1 -3
kernel/sched/ext.c
··· 4753 4753 const struct sched_class *new_class = 4754 4754 __setscheduler_class(p->policy, p->prio); 4755 4755 4756 - if (!tryget_task_struct(p)) 4756 + if (scx_get_task_state(p) != SCX_TASK_READY) 4757 4757 continue; 4758 4758 4759 4759 if (old_class != new_class) ··· 4763 4763 p->scx.slice = SCX_SLICE_DFL; 4764 4764 p->sched_class = new_class; 4765 4765 } 4766 - 4767 - put_task_struct(p); 4768 4766 } 4769 4767 scx_task_iter_stop(&sti); 4770 4768 percpu_up_write(&scx_fork_rwsem);