* [PATCH] TIMER Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
@ 2020-04-26 9:00 Mátyás János
0 siblings, 0 replies; only message in thread
From: Mátyás János @ 2020-04-26 9:00 UTC (permalink / raw)
To: Thomas Gleixner, John Stultz, Stephen Boyd, linux-kernel, trivial
commit 2a31a3b1db7898cf2360b628fa8717d85aac3e22
Author: Matyas Janos <mjanos5@gmail.com>
Date: Tue Oct 18 21:20:31 2016 +0200
Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
Signed-off-by: Matyas Janos <mjanos5@gmail.com>
---
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index a5221abb4594..f6de4d68e652 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-26 9:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 9:00 [PATCH] TIMER Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication Mátyás János
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).