sched_ext: Remove unnecessary cpu_relax()
PATCH 1/1 sched_ext: Remove unnecessary cpu_relax()
As described in commit b07996c7abac ("sched_ext: Don't hold scx_tasks_lock for too long"), we're doing a cond_resched() every 32 calls to scx_task_iter_next() to avoid RCU and other stalls. That commit also added a cpu_relax() to the codepath where we drop and reacquire the lock, but as Waiman described in [0], cpu_relax() should only be necessary in busy loops to avoid pounding on a cacheline (or to allow a hypertwin to more fully utilize a core).
Let's remove the unnecessary cpu_relax().
[0]: https://lore.kernel.org/all/[email protected]/
--- kernel/sched/ext.c | 1 - 1 file changed, 1 deletion(-)
kernel/sched/ext.c +0 -1
@@ -1374,7 +1374,6 @@ static struct task_struct *scx_task_iter_next(struct scx_task_iter *iter)if (!(++iter->cnt %SCX_OPS_TASK_ITER_BATCH )) {scx_task_iter_unlock (iter); -cpu_relax ();cond_resched ();scx_task_iter_relock (iter); }
Signature · 1 line
2.46.1
Tejun Heo
AppliedQuoted 8 lines · David Vernet
As described in commit
b07996c7abac("sched_ext: Don't holdscx_tasks_lockfor too long"), we're doing acond_resched()every 32 calls toscx_task_iter_next()to avoid RCU and other stalls. That commit also added acpu_relax()to the codepath where we drop and reacquire the lock, but as Waiman described in [0],cpu_relax()should only be necessary in busy loops to avoid pounding on a cacheline (or to allow a hypertwin to more fully utilize a core).
Quoted 6 lines
Let's remove the unnecessary
cpu_relax().[0]: https://lore.kernel.org/all/[email protected]/
Cc Waiman Long <[email protected]>Signed-off-by David Vernet <[email protected]>
Applied to sched_ext/for-6.12-fixes.
Thanks.
Signature · 1 line
tejun