@@ -2500,7 +2500,7 @@ static void flush_dispatch_buf(struct rq *rq)
2500
2500
dspc -> cursor = 0 ;
2501
2501
}
2502
2502
2503
- static int balance_one (struct rq * rq , struct task_struct * prev , bool local )
2503
+ static int balance_one (struct rq * rq , struct task_struct * prev )
2504
2504
{
2505
2505
struct scx_dsp_ctx * dspc = this_cpu_ptr (scx_dsp_ctx );
2506
2506
bool prev_on_scx = prev -> sched_class == & ext_sched_class ;
@@ -2529,22 +2529,16 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
2529
2529
/*
2530
2530
* If @prev is runnable & has slice left, it has priority and
2531
2531
* fetching more just increases latency for the fetched tasks.
2532
- * Tell pick_next_task_scx () to keep running @prev. If the BPF
2532
+ * Tell pick_task_scx () to keep running @prev. If the BPF
2533
2533
* scheduler wants to handle this explicitly, it should
2534
2534
* implement ->cpu_release().
2535
2535
*
2536
2536
* See scx_ops_disable_workfn() for the explanation on the
2537
2537
* bypassing test.
2538
- *
2539
- * When balancing a remote CPU for core-sched, there won't be a
2540
- * following put_prev_task_scx() call and we don't own
2541
- * %SCX_RQ_BAL_KEEP. Instead, pick_task_scx() will test the same
2542
- * conditions later and pick @rq->curr accordingly.
2543
2538
*/
2544
2539
if ((prev -> scx .flags & SCX_TASK_QUEUED ) &&
2545
2540
prev -> scx .slice && !scx_ops_bypassing ()) {
2546
- if (local )
2547
- rq -> scx .flags |= SCX_RQ_BAL_KEEP ;
2541
+ rq -> scx .flags |= SCX_RQ_BAL_KEEP ;
2548
2542
goto has_tasks ;
2549
2543
}
2550
2544
}
@@ -2603,8 +2597,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev, bool local)
2603
2597
*/
2604
2598
if ((prev -> scx .flags & SCX_TASK_QUEUED ) &&
2605
2599
(!static_branch_unlikely (& scx_ops_enq_last ) || scx_ops_bypassing ())) {
2606
- if (local )
2607
- rq -> scx .flags |= SCX_RQ_BAL_KEEP ;
2600
+ rq -> scx .flags |= SCX_RQ_BAL_KEEP ;
2608
2601
goto has_tasks ;
2609
2602
}
2610
2603
rq -> scx .flags &= ~SCX_RQ_IN_BALANCE ;
@@ -2622,13 +2615,13 @@ static int balance_scx(struct rq *rq, struct task_struct *prev,
2622
2615
2623
2616
rq_unpin_lock (rq , rf );
2624
2617
2625
- ret = balance_one (rq , prev , true );
2618
+ ret = balance_one (rq , prev );
2626
2619
2627
2620
#ifdef CONFIG_SCHED_SMT
2628
2621
/*
2629
2622
* When core-sched is enabled, this ops.balance() call will be followed
2630
- * by put_prev_scx() and pick_task_scx() on this CPU and pick_task_scx()
2631
- * on the SMT siblings. Balance the siblings too.
2623
+ * by pick_task_scx() on this CPU and the SMT siblings. Balance the
2624
+ * siblings too.
2632
2625
*/
2633
2626
if (sched_core_enabled (rq )) {
2634
2627
const struct cpumask * smt_mask = cpu_smt_mask (cpu_of (rq ));
@@ -2640,7 +2633,7 @@ static int balance_scx(struct rq *rq, struct task_struct *prev,
2640
2633
2641
2634
WARN_ON_ONCE (__rq_lockp (rq ) != __rq_lockp (srq ));
2642
2635
update_rq_clock (srq );
2643
- balance_one (srq , sprev , false );
2636
+ balance_one (srq , sprev );
2644
2637
}
2645
2638
}
2646
2639
#endif
@@ -2760,9 +2753,9 @@ static struct task_struct *first_local_task(struct rq *rq)
2760
2753
struct task_struct , scx .dsq_list .node );
2761
2754
}
2762
2755
2763
- static struct task_struct * pick_next_task_scx (struct rq * rq ,
2764
- struct task_struct * prev )
2756
+ static struct task_struct * pick_task_scx (struct rq * rq )
2765
2757
{
2758
+ struct task_struct * prev = rq -> curr ;
2766
2759
struct task_struct * p ;
2767
2760
2768
2761
/*
@@ -2790,8 +2783,6 @@ static struct task_struct *pick_next_task_scx(struct rq *rq,
2790
2783
}
2791
2784
}
2792
2785
2793
- put_prev_set_next_task (rq , prev , p );
2794
-
2795
2786
return p ;
2796
2787
}
2797
2788
@@ -2828,49 +2819,6 @@ bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
2828
2819
else
2829
2820
return time_after64 (a -> scx .core_sched_at , b -> scx .core_sched_at );
2830
2821
}
2831
-
2832
- /**
2833
- * pick_task_scx - Pick a candidate task for core-sched
2834
- * @rq: rq to pick the candidate task from
2835
- *
2836
- * Core-sched calls this function on each SMT sibling to determine the next
2837
- * tasks to run on the SMT siblings. balance_one() has been called on all
2838
- * siblings and put_prev_task_scx() has been called only for the current CPU.
2839
- *
2840
- * As put_prev_task_scx() hasn't been called on remote CPUs, we can't just look
2841
- * at the first task in the local dsq. @rq->curr has to be considered explicitly
2842
- * to mimic %SCX_RQ_BAL_KEEP.
2843
- */
2844
- static struct task_struct * pick_task_scx (struct rq * rq )
2845
- {
2846
- struct task_struct * curr = rq -> curr ;
2847
- struct task_struct * first = first_local_task (rq );
2848
-
2849
- if (curr -> scx .flags & SCX_TASK_QUEUED ) {
2850
- /* is curr the only runnable task? */
2851
- if (!first )
2852
- return curr ;
2853
-
2854
- /*
2855
- * Does curr trump first? We can always go by core_sched_at for
2856
- * this comparison as it represents global FIFO ordering when
2857
- * the default core-sched ordering is used and local-DSQ FIFO
2858
- * ordering otherwise.
2859
- *
2860
- * We can have a task with an earlier timestamp on the DSQ. For
2861
- * example, when a current task is preempted by a sibling
2862
- * picking a different cookie, the task would be requeued at the
2863
- * head of the local DSQ with an earlier timestamp than the
2864
- * core-sched picked next task. Besides, the BPF scheduler may
2865
- * dispatch any tasks to the local DSQ anytime.
2866
- */
2867
- if (curr -> scx .slice && time_before64 (curr -> scx .core_sched_at ,
2868
- first -> scx .core_sched_at ))
2869
- return curr ;
2870
- }
2871
-
2872
- return first ; /* this may be %NULL */
2873
- }
2874
2822
#endif /* CONFIG_SCHED_CORE */
2875
2823
2876
2824
static enum scx_cpu_preempt_reason
@@ -3638,7 +3586,7 @@ DEFINE_SCHED_CLASS(ext) = {
3638
3586
.wakeup_preempt = wakeup_preempt_scx ,
3639
3587
3640
3588
.balance = balance_scx ,
3641
- .pick_next_task = pick_next_task_scx ,
3589
+ .pick_task = pick_task_scx ,
3642
3590
3643
3591
.put_prev_task = put_prev_task_scx ,
3644
3592
.set_next_task = set_next_task_scx ,
@@ -3654,10 +3602,6 @@ DEFINE_SCHED_CLASS(ext) = {
3654
3602
.rq_offline = rq_offline_scx ,
3655
3603
#endif
3656
3604
3657
- #ifdef CONFIG_SCHED_CORE
3658
- .pick_task = pick_task_scx ,
3659
- #endif
3660
-
3661
3605
.task_tick = task_tick_scx ,
3662
3606
3663
3607
.switching_to = switching_to_scx ,
0 commit comments