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

Commit a14e0110 authored by Steve Muckle's avatar Steve Muckle
Browse files

sched: refresh sched_clock() after acquiring rq lock in irq path



The wallclock time passed to sched_account_irqtime() may be stale
after we wait to acquire the runqueue lock. This could cause problems
in update_task_ravg because a different CPU may have advanced
this CPU's window_start based on a more up-to-date wallclock value,
triggering a BUG_ON(window_start > wallclock).

Change-Id: I316af62d1716e9b59c4a2898a2d9b44d6c7a75d8
Signed-off-by: default avatarSteve Muckle <smuckle@codeaurora.org>
parent 5fdc1d3a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1832,14 +1832,16 @@ void sched_account_irqtime(int cpu, struct task_struct *curr,
{
	struct rq *rq = cpu_rq(cpu);
	unsigned long flags, nr_windows;
	u64 cur_jiffies_ts;
	u64 cur_jiffies_ts, now;

	raw_spin_lock_irqsave(&rq->lock, flags);

	now = sched_clock();
	delta += (now - wallclock);
	cur_jiffies_ts = get_jiffies_64();

	if (is_idle_task(curr))
		update_task_ravg(curr, rq, IRQ_UPDATE, wallclock, delta);
		update_task_ravg(curr, rq, IRQ_UPDATE, now, delta);

	nr_windows = cur_jiffies_ts - rq->irqload_ts;