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

Commit 74b84e8a authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Gerrit - the friendly Code Review server
Browse files

sched/walt: Avoid taking rq lock for every IRQ update



sched_account_irqtime() is called for every IRQ/SoftIRQ update.
The rq->lock is needed only in idle context in which case
update_task_ravg() is called. For IRQ load updates, rq->lock
is not needed, since these are tracked per-cpu and migrations
are not applicable for irqload. By not taking rq lock for
every interrupt, we don't delay the irq exit path under heavy
rq lock contention. For example, this CPU is loaded with thousands
of tasks and rq->lock is acquired during load balance.

Change-Id: Iebba1a84408509ce93b3a8a0dcc1a9ea1f1bc930
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent a428455e
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -424,22 +424,27 @@ void sched_account_irqtime(int cpu, struct task_struct *curr,
				 u64 delta, u64 wallclock)
{
	struct rq *rq = cpu_rq(cpu);
	unsigned long flags, nr_windows;
	unsigned long nr_windows;
	u64 cur_jiffies_ts;

	raw_spin_lock_irqsave(&rq->lock, flags);

	/*
	 * cputime (wallclock) uses sched_clock so use the same here for
	 * consistency.
	 * We called with interrupts disabled. Take the rq lock only
	 * if we are in idle context in which case update_task_ravg()
	 * call is needed.
	 */
	if (is_idle_task(curr)) {
		raw_spin_lock(&rq->lock);
		/*
		 * cputime (wallclock) uses sched_clock so use the same here
		 * for consistency.
		 */
		delta += sched_clock() - wallclock;
	cur_jiffies_ts = get_jiffies_64();

	if (is_idle_task(curr))
		update_task_ravg(curr, rq, IRQ_UPDATE, sched_ktime_clock(),
				 delta);
		raw_spin_unlock(&rq->lock);
	}

	cur_jiffies_ts = get_jiffies_64();
	nr_windows = cur_jiffies_ts - rq->irqload_ts;

	if (nr_windows) {
@@ -457,7 +462,6 @@ void sched_account_irqtime(int cpu, struct task_struct *curr,

	rq->cur_irqload += delta;
	rq->irqload_ts = cur_jiffies_ts;
	raw_spin_unlock_irqrestore(&rq->lock, flags);
}

/*