@@ -5765,6 +5765,7 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq)
57655765 struct cfs_bandwidth * cfs_b = tg_cfs_bandwidth (cfs_rq -> tg );
57665766 struct sched_entity * se ;
57675767 long task_delta , idle_task_delta , dequeue = 1 ;
5768+ long rq_h_nr_running = rq -> cfs .h_nr_running ;
57685769
57695770 raw_spin_lock (& cfs_b -> lock );
57705771 /* This will start the period timer if necessary */
@@ -5837,6 +5838,9 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq)
58375838 sub_nr_running (rq , task_delta );
58385839
58395840done :
5841+ /* Stop the fair server if throttling resulted in no runnable tasks */
5842+ if (rq_h_nr_running && !rq -> cfs .h_nr_running )
5843+ dl_server_stop (& rq -> fair_server );
58405844 /*
58415845 * Note: distribution will already see us throttled via the
58425846 * throttled-list. rq->lock protects completion.
@@ -5854,6 +5858,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
58545858 struct cfs_bandwidth * cfs_b = tg_cfs_bandwidth (cfs_rq -> tg );
58555859 struct sched_entity * se ;
58565860 long task_delta , idle_task_delta ;
5861+ long rq_h_nr_running = rq -> cfs .h_nr_running ;
58575862
58585863 se = cfs_rq -> tg -> se [cpu_of (rq )];
58595864
@@ -5929,6 +5934,10 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
59295934unthrottle_throttle :
59305935 assert_list_leaf_cfs_rq (rq );
59315936
5937+ /* Start the fair server if un-throttling resulted in new runnable tasks */
5938+ if (!rq_h_nr_running && rq -> cfs .h_nr_running )
5939+ dl_server_start (& rq -> fair_server );
5940+
59325941 /* Determine whether we need to wake up potentially idle CPU: */
59335942 if (rq -> curr == rq -> idle && rq -> cfs .nr_running )
59345943 resched_curr (rq );
@@ -6759,6 +6768,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
67596768 */
67606769 util_est_enqueue (& rq -> cfs , p );
67616770
6771+ if (!throttled_hierarchy (task_cfs_rq (p )) && !rq -> cfs .h_nr_running )
6772+ dl_server_start (& rq -> fair_server );
6773+
67626774 /*
67636775 * If in_iowait is set, the code below may not trigger any cpufreq
67646776 * utilization updates, so do it here explicitly with the IOWAIT flag
@@ -6903,6 +6915,9 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
69036915 rq -> next_balance = jiffies ;
69046916
69056917dequeue_throttle :
6918+ if (!throttled_hierarchy (task_cfs_rq (p )) && !rq -> cfs .h_nr_running )
6919+ dl_server_stop (& rq -> fair_server );
6920+
69066921 util_est_update (& rq -> cfs , p , task_sleep );
69076922 hrtick_update (rq );
69086923}
@@ -8602,6 +8617,25 @@ static struct task_struct *__pick_next_task_fair(struct rq *rq)
86028617 return pick_next_task_fair (rq , NULL , NULL );
86038618}
86048619
8620+ static bool fair_server_has_tasks (struct sched_dl_entity * dl_se )
8621+ {
8622+ return !!dl_se -> rq -> cfs .nr_running ;
8623+ }
8624+
8625+ static struct task_struct * fair_server_pick (struct sched_dl_entity * dl_se )
8626+ {
8627+ return pick_next_task_fair (dl_se -> rq , NULL , NULL );
8628+ }
8629+
8630+ void fair_server_init (struct rq * rq )
8631+ {
8632+ struct sched_dl_entity * dl_se = & rq -> fair_server ;
8633+
8634+ init_dl_entity (dl_se );
8635+
8636+ dl_server_init (dl_se , rq , fair_server_has_tasks , fair_server_pick );
8637+ }
8638+
86058639/*
86068640 * Account for a descheduled task:
86078641 */
0 commit comments