[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20200426110018.7bb67f03@gmail.com>
Date: Sun, 26 Apr 2020 11:00:18 +0200
From: Mátyás János <mjanos5@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>,
John Stultz <john.stultz@...aro.org>,
Stephen Boyd <sboyd@...nel.org>, linux-kernel@...r.kernel.org,
trivial@...nel.org
Subject: [PATCH] TIMER Refactoring: avoid unnecessary recalculation of cpu
skew and remove duplication
commit 2a31a3b1db7898cf2360b628fa8717d85aac3e22
Author: Matyas Janos <mjanos5@...il.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@...il.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
Powered by blists - more mailing lists