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

Commit 79447cdf authored by Prasad Sodagudi's avatar Prasad Sodagudi
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>
parent bd8b86b1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include <linux/timer.h>
#include <linux/freezer.h>
#include <linux/compat.h>
#include <linux/delay.h>

#include <linux/uaccess.h>

@@ -152,6 +153,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);
	}
}

@@ -1067,6 +1069,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
@@ -164,3 +164,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
@@ -944,6 +944,7 @@ static struct timer_base *lock_timer_base(struct timer_list *timer,
			raw_spin_unlock_irqrestore(&base->lock, *flags);
		}
		cpu_relax();
		ndelay(TIMER_LOCK_TIGHT_LOOP_DELAY_NS);
	}
}

@@ -1266,6 +1267,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);