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

Commit a84e7ded authored by Prasad Sodagudi's avatar Prasad Sodagudi Committed by Gerrit - the friendly Code Review server
Browse files

kernel: time: Add delay after cpu_relax() in tight loops



Tight loops of spin_lock_irqsave() and spin_unlock_irqrestore()
in timer and hrtimer are causing scheduling delays. Add delay of
few nano seconds after cpu_relax in the timer/hrtimer tight loops.

Change-Id: Iaa0ab92da93f7b245b1d922b6edca2bebdc0fbce
Signed-off-by: default avatarPrasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: default avatarChetan C R <cravin@codeaurora.org>
parent 1e353927
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include <linux/sched/deadline.h>
#include <linux/timer.h>
#include <linux/freezer.h>
#include <linux/delay.h>

#include <asm/uaccess.h>

@@ -149,6 +150,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
			raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
		}
		cpu_relax();
		ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS);
	}
}

@@ -1043,6 +1045,7 @@ int hrtimer_cancel(struct hrtimer *timer)
		if (ret >= 0)
			return ret;
		cpu_relax();
		ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS);
	}
}
EXPORT_SYMBOL_GPL(hrtimer_cancel);
+1 −0
Original line number Diff line number Diff line
@@ -165,3 +165,4 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);

extern u64 get_next_timer_interrupt(unsigned long basej, u64 basem);
void timer_clear_idle(void);
#define TIMER_LOCK_TIGHT_LOOP_DELAY_NS	350
+2 −0
Original line number Diff line number Diff line
@@ -942,6 +942,7 @@ static struct timer_base *lock_timer_base(struct timer_list *timer,
			spin_unlock_irqrestore(&base->lock, *flags);
		}
		cpu_relax();
		ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS);
	}
}

@@ -1264,6 +1265,7 @@ int del_timer_sync(struct timer_list *timer)
		if (ret >= 0)
			return ret;
		cpu_relax();
		ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS);
	}
}
EXPORT_SYMBOL(del_timer_sync);