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: Prasad Sodagudi <psodagud@codeaurora.org>
This commit is contained in:
parent
c4051c3364
commit
8f2c04f1d8
3 changed files with 6 additions and 0 deletions
|
@ -51,6 +51,7 @@
|
|||
#include <linux/timer.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
|
@ -178,6 +179,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1182,6 +1184,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);
|
||||
|
|
|
@ -163,3 +163,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
|
||||
|
|
|
@ -957,6 +957,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1310,6 +1311,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);
|
||||
|
|
Loading…
Reference in a new issue