Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1d1be8a authored by Xunlei Pang's avatar Xunlei Pang Committed by Ingo Molnar
Browse files

sched/fair: Advance global expiration when period timer is restarted



When period gets restarted after some idle time, start_cfs_bandwidth()
doesn't update the expiration information, expire_cfs_rq_runtime() will
see cfs_rq->runtime_expires smaller than rq clock and go to the clock
drift logic, wasting needless CPU cycles on the scheduler hot path.

Update the global expiration in start_cfs_bandwidth() to avoid frequent
expire_cfs_rq_runtime() calls once a new period begins.

Signed-off-by: default avatarXunlei Pang <xlpang@linux.alibaba.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarBen Segall <bsegall@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180620101834.24455-2-xlpang@linux.alibaba.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 512ac999
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -5204,14 +5204,19 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq)


void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
{
{
	u64 overrun;

	lockdep_assert_held(&cfs_b->lock);
	lockdep_assert_held(&cfs_b->lock);


	if (!cfs_b->period_active) {
	if (cfs_b->period_active)
		return;

	cfs_b->period_active = 1;
	cfs_b->period_active = 1;
		hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period);
	overrun = hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period);
	cfs_b->runtime_expires += (overrun + 1) * ktime_to_ns(cfs_b->period);
	cfs_b->expires_seq++;
	hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED);
	hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED);
}
}
}


static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
{
{