From: "Mátyás János" <mjanos5@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>,
John Stultz <john.stultz@linaro.org>,
Stephen Boyd <sboyd@kernel.org>,
linux-kernel@vger.kernel.org, trivial@kernel.org
Subject: [PATCH] TIMER Refactoring: avoid unnecessary recalculation of cpu skew and remove duplication
Date: Sun, 26 Apr 2020 11:00:18 +0200 [thread overview]
Message-ID: <20200426110018.7bb67f03@gmail.com> (raw)
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
reply other threads:[~2020-04-26 9:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200426110018.7bb67f03@gmail.com \
--to=mjanos5@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=trivial@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome