Skip to content

Commit d723f36

Browse files
committed
sched_ext: Minor cleanups to scx_task_iter
- Use memset() in scx_task_iter_start() instead of zeroing fields individually. - In scx_task_iter_next(), move __scx_task_iter_maybe_relock() after the batch check which is simpler. - Update comment to reflect that tasks are removed from scx_tasks when dead (commit 7900aa6 ("sched_ext: Fix cgroup exit ordering by moving sched_ext_free() to finish_task_switch()")). No functional changes. Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 023af03 commit d723f36

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

kernel/sched/ext.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,16 @@ struct scx_task_iter {
470470
* RCU read lock or obtaining a reference count.
471471
*
472472
* All tasks which existed when the iteration started are guaranteed to be
473-
* visited as long as they still exist.
473+
* visited as long as they are not dead.
474474
*/
475475
static void scx_task_iter_start(struct scx_task_iter *iter)
476476
{
477+
memset(iter, 0, sizeof(*iter));
478+
477479
spin_lock_irq(&scx_tasks_lock);
478480

479481
iter->cursor = (struct sched_ext_entity){ .flags = SCX_TASK_CURSOR };
480482
list_add(&iter->cursor.tasks_node, &scx_tasks);
481-
iter->locked_task = NULL;
482-
iter->cnt = 0;
483483
iter->list_locked = true;
484484
}
485485

@@ -545,14 +545,13 @@ static struct task_struct *scx_task_iter_next(struct scx_task_iter *iter)
545545
struct list_head *cursor = &iter->cursor.tasks_node;
546546
struct sched_ext_entity *pos;
547547

548-
__scx_task_iter_maybe_relock(iter);
549-
550548
if (!(++iter->cnt % SCX_TASK_ITER_BATCH)) {
551549
scx_task_iter_unlock(iter);
552550
cond_resched();
553-
__scx_task_iter_maybe_relock(iter);
554551
}
555552

553+
__scx_task_iter_maybe_relock(iter);
554+
556555
list_for_each_entry(pos, cursor, tasks_node) {
557556
if (&pos->tasks_node == &scx_tasks)
558557
return NULL;

0 commit comments

Comments
 (0)