Commit a9bcd6af authored by Steve Sistare's avatar Steve Sistare Committed by Cheng Jian
Browse files

sched/fair: Hoist idle_stamp up from idle_balance

hulk inclusion
category: feature
bugzilla: 38261, https://bugzilla.openeuler.org/show_bug.cgi?id=23


CVE: NA

---------------------------

Move the update of idle_stamp from idle_balance to the call site in
pick_next_task_fair, to prepare for a future patch that adds work to
pick_next_task_fair which must be included in the idle_stamp interval.
No functional change.

Signed-off-by: default avatarSteve Sistare <steven.sistare@oracle.com>
Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Reviewed-by: default avatarHanjun Guo <guohanjun@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent f3a5ae44
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -3811,6 +3811,16 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
	WRITE_ONCE(p->se.avg.util_est, ue);
}

static inline void rq_idle_stamp_update(struct rq *rq)
{
	rq->idle_stamp = rq_clock(rq);
}

static inline void rq_idle_stamp_clear(struct rq *rq)
{
	rq->idle_stamp = 0;
}

static void overload_clear(struct rq *rq)
{
	struct sparsemask *overload_cpus;
@@ -3856,6 +3866,8 @@ static inline int idle_balance(struct rq *rq, struct rq_flags *rf)
	return 0;
}

static inline void rq_idle_stamp_update(struct rq *rq) {}
static inline void rq_idle_stamp_clear(struct rq *rq) {}
static inline void overload_clear(struct rq *rq) {}
static inline void overload_set(struct rq *rq) {}

@@ -6907,8 +6919,18 @@ done: __maybe_unused;
	return p;

idle:

	/*
	 * We must set idle_stamp _before_ calling idle_balance(), such that we
	 * measure the duration of idle_balance() as idle time.
	 */
	rq_idle_stamp_update(rq);

	new_tasks = idle_balance(rq, rf);

	if (new_tasks)
		rq_idle_stamp_clear(rq);

	/*
	 * Because idle_balance() releases (and re-acquires) rq->lock, it is
	 * possible for any higher priority task to appear. In that case we
@@ -9693,12 +9715,6 @@ static int idle_balance(struct rq *this_rq, struct rq_flags *rf)
	int pulled_task = 0;
	u64 curr_cost = 0;

	/*
	 * We must set idle_stamp _before_ calling idle_balance(), such that we
	 * measure the duration of idle_balance() as idle time.
	 */
	this_rq->idle_stamp = rq_clock(this_rq);

	/*
	 * Do not pull tasks towards !active CPUs...
	 */
@@ -9790,9 +9806,6 @@ static int idle_balance(struct rq *this_rq, struct rq_flags *rf)
	if (this_rq->nr_running != this_rq->cfs.h_nr_running)
		pulled_task = -1;

	if (pulled_task)
		this_rq->idle_stamp = 0;

	rq_repin_lock(this_rq, rf);

	return pulled_task;