Skip to content

Commit 5ba553e

Browse files
author
Peter Zijlstra
committed
sched/fair: Expose newidle_balance()
For pick_next_task_fair() it is the newidle balance that requires dropping the rq->lock; provided we do put_prev_task() early, we can also detect the condition for doing newidle early. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Aaron Lu <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: [email protected] Cc: Phil Auld <[email protected]> Cc: Julien Desfossez <[email protected]> Cc: Nishanth Aravamudan <[email protected]> Link: https://lkml.kernel.org/r/9e3eb1859b946f03d7e500453a885725b68957ba.1559129225.git.vpillai@digitalocean.com
1 parent 03b7fad commit 5ba553e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

kernel/sched/fair.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,8 +3690,6 @@ static inline unsigned long cfs_rq_load_avg(struct cfs_rq *cfs_rq)
36903690
return cfs_rq->avg.load_avg;
36913691
}
36923692

3693-
static int idle_balance(struct rq *this_rq, struct rq_flags *rf);
3694-
36953693
static inline unsigned long task_util(struct task_struct *p)
36963694
{
36973695
return READ_ONCE(p->se.avg.util_avg);
@@ -6878,11 +6876,10 @@ done: __maybe_unused;
68786876
return p;
68796877

68806878
idle:
6881-
update_misfit_status(NULL, rq);
6882-
new_tasks = idle_balance(rq, rf);
6879+
new_tasks = newidle_balance(rq, rf);
68836880

68846881
/*
6885-
* Because idle_balance() releases (and re-acquires) rq->lock, it is
6882+
* Because newidle_balance() releases (and re-acquires) rq->lock, it is
68866883
* possible for any higher priority task to appear. In that case we
68876884
* must re-start the pick_next_entity() loop.
68886885
*/
@@ -9045,10 +9042,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
90459042
ld_moved = 0;
90469043

90479044
/*
9048-
* idle_balance() disregards balance intervals, so we could repeatedly
9049-
* reach this code, which would lead to balance_interval skyrocketting
9050-
* in a short amount of time. Skip the balance_interval increase logic
9051-
* to avoid that.
9045+
* newidle_balance() disregards balance intervals, so we could
9046+
* repeatedly reach this code, which would lead to balance_interval
9047+
* skyrocketting in a short amount of time. Skip the balance_interval
9048+
* increase logic to avoid that.
90529049
*/
90539050
if (env.idle == CPU_NEWLY_IDLE)
90549051
goto out;
@@ -9758,14 +9755,15 @@ static inline void nohz_newidle_balance(struct rq *this_rq) { }
97589755
* idle_balance is called by schedule() if this_cpu is about to become
97599756
* idle. Attempts to pull tasks from other CPUs.
97609757
*/
9761-
static int idle_balance(struct rq *this_rq, struct rq_flags *rf)
9758+
int newidle_balance(struct rq *this_rq, struct rq_flags *rf)
97629759
{
97639760
unsigned long next_balance = jiffies + HZ;
97649761
int this_cpu = this_rq->cpu;
97659762
struct sched_domain *sd;
97669763
int pulled_task = 0;
97679764
u64 curr_cost = 0;
97689765

9766+
update_misfit_status(NULL, this_rq);
97699767
/*
97709768
* We must set idle_stamp _before_ calling idle_balance(), such that we
97719769
* measure the duration of idle_balance() as idle time.

kernel/sched/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,10 +1445,14 @@ static inline void unregister_sched_domain_sysctl(void)
14451445
}
14461446
#endif
14471447

1448+
extern int newidle_balance(struct rq *this_rq, struct rq_flags *rf);
1449+
14481450
#else
14491451

14501452
static inline void sched_ttwu_pending(void) { }
14511453

1454+
static inline int newidle_balance(struct rq *this_rq, struct rq_flags *rf) { return 0; }
1455+
14521456
#endif /* CONFIG_SMP */
14531457

14541458
#include "stats.h"

0 commit comments

Comments
 (0)