@@ -2508,6 +2508,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
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 )) {
@@ -2523,7 +2524,6 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
2523
2524
}
2524
2525
2525
2526
if (prev_on_scx ) {
2526
- WARN_ON_ONCE (local && (prev -> scx .flags & SCX_TASK_BAL_KEEP ));
2527
2527
update_curr_scx (rq );
2528
2528
2529
2529
/*
@@ -2538,13 +2538,13 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
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,7 +2604,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
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,8 +2726,6 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
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
/*
@@ -2772,8 +2770,8 @@ static struct task_struct *pick_next_task_scx(struct rq *rq,
2772
2770
* if necessary and keep running @prev. Otherwise, pop the first one
2773
2771
* from the local DSQ.
2774
2772
*/
2775
- if (prev -> scx .flags & SCX_TASK_BAL_KEEP ) {
2776
- prev -> scx . flags &= ~ SCX_TASK_BAL_KEEP ;
2773
+ if (( rq -> scx .flags & SCX_RQ_BAL_KEEP ) &&
2774
+ ! WARN_ON_ONCE ( prev -> sched_class != & ext_sched_class )) {
2777
2775
p = prev ;
2778
2776
if (!p -> scx .slice )
2779
2777
p -> scx .slice = SCX_SLICE_DFL ;
@@ -2841,7 +2839,7 @@ bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
2841
2839
*
2842
2840
* As put_prev_task_scx() hasn't been called on remote CPUs, we can't just look
2843
2841
* at the first task in the local dsq. @rq->curr has to be considered explicitly
2844
- * to mimic %SCX_TASK_BAL_KEEP .
2842
+ * to mimic %SCX_RQ_BAL_KEEP .
2845
2843
*/
2846
2844
static struct task_struct * pick_task_scx (struct rq * rq )
2847
2845
{
@@ -3872,7 +3870,7 @@ bool task_should_scx(struct task_struct *p)
3872
3870
*
3873
3871
* b. ops.dispatch() is ignored.
3874
3872
*
3875
- * c. balance_scx() does not set %SCX_TASK_BAL_KEEP on non-zero slice as slice
3873
+ * c. balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice
3876
3874
* can't be trusted. Whenever a tick triggers, the running task is rotated to
3877
3875
* the tail of the queue with core_sched_at touched.
3878
3876
*
0 commit comments