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: Replace SCX_TASK_BAL_KEEP with SCX_RQ_BAL_KEEP

SCX_TASK_BAL_KEEP is used by balance_one() to tell pick_next_task_scx() to
keep running the current task. It's not really a task property. Replace it
with SCX_RQ_BAL_KEEP which resides in rq->scx.flags and is a better fit for
the usage. Also, the existing clearing rule is unnecessarily strict and
makes it difficult to use with core-sched. Just clear it on entry to
balance_one().

Signed-off-by: Tejun Heo <tj@kernel.org>

+10 -12
-1
include/linux/sched/ext.h
··· 71 71 /* scx_entity.flags */ 72 72 enum scx_ent_flags { 73 73 SCX_TASK_QUEUED = 1 << 0, /* on ext runqueue */ 74 - SCX_TASK_BAL_KEEP = 1 << 1, /* balance decided to keep current */ 75 74 SCX_TASK_RESET_RUNNABLE_AT = 1 << 2, /* runnable_at should be reset */ 76 75 SCX_TASK_DEQD_FOR_SLEEP = 1 << 3, /* last dequeue was for SLEEP */ 77 76
+9 -11
kernel/sched/ext.c
··· 2508 2508 2509 2509 lockdep_assert_rq_held(rq); 2510 2510 rq->scx.flags |= SCX_RQ_IN_BALANCE; 2511 + rq->scx.flags &= ~SCX_RQ_BAL_KEEP; 2511 2512 2512 2513 if (static_branch_unlikely(&scx_ops_cpu_preempt) && 2513 2514 unlikely(rq->scx.cpu_released)) { ··· 2524 2523 } 2525 2524 2526 2525 if (prev_on_scx) { 2527 - WARN_ON_ONCE(local && (prev->scx.flags & SCX_TASK_BAL_KEEP)); 2528 2526 update_curr_scx(rq); 2529 2527 2530 2528 /* ··· 2538 2538 * 2539 2539 * When balancing a remote CPU for core-sched, there won't be a 2540 2540 * following put_prev_task_scx() call and we don't own 2541 - * %SCX_TASK_BAL_KEEP. Instead, pick_task_scx() will test the 2542 - * same conditions later and pick @rq->curr accordingly. 2541 + * %SCX_RQ_BAL_KEEP. Instead, pick_task_scx() will test the same 2542 + * conditions later and pick @rq->curr accordingly. 2543 2543 */ 2544 2544 if ((prev->scx.flags & SCX_TASK_QUEUED) && 2545 2545 prev->scx.slice && !scx_ops_bypassing()) { 2546 2546 if (local) 2547 - prev->scx.flags |= SCX_TASK_BAL_KEEP; 2547 + rq->scx.flags |= SCX_RQ_BAL_KEEP; 2548 2548 goto has_tasks; 2549 2549 } 2550 2550 } ··· 2604 2604 if ((prev->scx.flags & SCX_TASK_QUEUED) && 2605 2605 (!static_branch_unlikely(&scx_ops_enq_last) || scx_ops_bypassing())) { 2606 2606 if (local) 2607 - prev->scx.flags |= SCX_TASK_BAL_KEEP; 2607 + rq->scx.flags |= SCX_RQ_BAL_KEEP; 2608 2608 goto has_tasks; 2609 2609 } 2610 2610 rq->scx.flags &= ~SCX_RQ_IN_BALANCE; ··· 2726 2726 SCX_CALL_OP_TASK(SCX_KF_REST, stopping, p, true); 2727 2727 2728 2728 if (p->scx.flags & SCX_TASK_QUEUED) { 2729 - p->scx.flags &= ~SCX_TASK_BAL_KEEP; 2730 - 2731 2729 set_task_runnable(rq, p); 2732 2730 2733 2731 /* ··· 2770 2772 * if necessary and keep running @prev. Otherwise, pop the first one 2771 2773 * from the local DSQ. 2772 2774 */ 2773 - if (prev->scx.flags & SCX_TASK_BAL_KEEP) { 2774 - prev->scx.flags &= ~SCX_TASK_BAL_KEEP; 2775 + if ((rq->scx.flags & SCX_RQ_BAL_KEEP) && 2776 + !WARN_ON_ONCE(prev->sched_class != &ext_sched_class)) { 2775 2777 p = prev; 2776 2778 if (!p->scx.slice) 2777 2779 p->scx.slice = SCX_SLICE_DFL; ··· 2839 2841 * 2840 2842 * As put_prev_task_scx() hasn't been called on remote CPUs, we can't just look 2841 2843 * at the first task in the local dsq. @rq->curr has to be considered explicitly 2842 - * to mimic %SCX_TASK_BAL_KEEP. 2844 + * to mimic %SCX_RQ_BAL_KEEP. 2843 2845 */ 2844 2846 static struct task_struct *pick_task_scx(struct rq *rq) 2845 2847 { ··· 3870 3872 * 3871 3873 * b. ops.dispatch() is ignored. 3872 3874 * 3873 - * c. balance_scx() does not set %SCX_TASK_BAL_KEEP on non-zero slice as slice 3875 + * c. balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice 3874 3876 * can't be trusted. Whenever a tick triggers, the running task is rotated to 3875 3877 * the tail of the queue with core_sched_at touched. 3876 3878 *
+1
kernel/sched/sched.h
··· 737 737 */ 738 738 SCX_RQ_ONLINE = 1 << 0, 739 739 SCX_RQ_CAN_STOP_TICK = 1 << 1, 740 + SCX_RQ_BAL_KEEP = 1 << 2, /* balance decided to keep current */ 740 741 741 742 SCX_RQ_IN_WAKEUP = 1 << 16, 742 743 SCX_RQ_IN_BALANCE = 1 << 17,