TIMER Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
PATCH 1/1 TIMER Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
commit 2a31a3b1db7898cf2360b628fa8717d85aac3e22
Author: Matyas Janos <[email protected]> Date: Tue Oct 18 21:20:31 2016 +0200
Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
Signed-off-by Matyas Janos <[email protected]>
---
kernel/time/timer.c +7 -6
@@ -275,6 +275,7 @@ static unsigned long round_jiffies_common(unsigned long j, int cpu, {int rem;unsigned long original = j; +unsigned long cpu_skew = cpu *3 ;/* * We don't want all cpus firing their timers at once hitting the
@@ -284,7 +285,7 @@ static unsigned long round_jiffies_common(unsigned long j, int cpu,* The skew is done by adding 3*cpunr, then round, then subtract this * extra offset again. */ - j += cpu *3 ; + j += cpu_skew; rem = j %HZ ;
@@ -295,13 +296,13 @@ static unsigned long round_jiffies_common(unsigned long j, int cpu,* as cutoff for this rounding as an extreme upper bound for this. * But never round down if @force_up is set. */ -if (rem <HZ /4 && !force_up)/* round down */ - j = j - rem; -else /* round up */ - j = j - rem +HZ ; + j -= rem;/* round down by default */ + +if (rem >=HZ /4 || force_up) + j +=HZ ;/* round up */ /* now that we have rounded, subtract the extra skew again */ - j -= cpu *3 ; + j -= cpu_skew;/* * Make sure j is still in the future. Otherwise return the