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

Commit 7ebd479a authored by Steve Muckle's avatar Steve Muckle
Browse files

sched: fix misalignment between requested and actual windows



When set_window_start() is first executed sched_clock() has not yet
stabilized. Refresh the sched_init_jiffy and sched_clock_at_init_jiffy
values until it is known that sched_clock has stabilized - this will
be the case by the time a client calls the sched_set_window() API.

Change-Id: Icd057707ff44c3b240e5e7e96891b23c95733daa
Signed-off-by: default avatarSteve Muckle <smuckle@codeaurora.org>
parent efcad24c
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1596,18 +1596,23 @@ static inline void mark_task_starting(struct task_struct *p)
	p->ravg.flags |= PREV_WINDOW_CONTRIB;
}

static int update_alignment;

static inline void set_window_start(struct rq *rq)
{
	int cpu = cpu_of(rq);
	struct rq *sync_rq = cpu_rq(sync_cpu);

	if (cpu == sync_cpu && !update_alignment) {
		sched_init_jiffy = get_jiffies_64();
		sched_clock_at_init_jiffy = sched_clock();
	}

	if (rq->window_start || !sched_enable_hmp)
		return;

	if (cpu == sync_cpu) {
		rq->window_start = sched_clock();
		sched_init_jiffy = get_jiffies_64();
		sched_clock_at_init_jiffy = rq->window_start;
		rq->window_start = sched_clock_at_init_jiffy;
	} else {
		raw_spin_unlock(&rq->lock);
		double_rq_lock(rq, sync_rq);
@@ -1719,6 +1724,8 @@ int sched_set_window(u64 window_start, unsigned int window_size)
		 (window_size * TICK_NSEC <  MIN_SCHED_RAVG_WINDOW))
			return -EINVAL;

	update_alignment = 1;

	local_irq_save(flags);

	now = get_jiffies_64();