From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
John Stultz <jstultz@google.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] timekeeping: Provide timekeeping_restore_shadow()
Date: Fri, 25 Oct 2024 18:01:20 -0000 [thread overview]
Message-ID: <172987928047.1442.163274573376384169.tip-bot2@tip-bot2> (raw)
In-Reply-To: =?utf-8?q?=3C20241009-devel-anna-maria-b4-timers-ptp-timekeepin?= =?utf-8?q?g-v2-15-554456a44a15=40linutronix=2Ede=3E?=
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 97e53792538dd8993172e231f09dadee57f66d69
Gitweb: https://git.kernel.org/tip/97e53792538dd8993172e231f09dadee57f66d69
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 09 Oct 2024 10:29:08 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 25 Oct 2024 19:49:14 +02:00
timekeeping: Provide timekeeping_restore_shadow()
Functions which operate on the real timekeeper, e.g. do_settimeofday(),
have error conditions. If they are hit a full timekeeping update is still
required because the already committed operations modified the timekeeper.
When switching these functions to operate on the shadow timekeeper then the
full update can be avoided in the error case, but the modified shadow
timekeeper has to be restored.
Provide a helper function for that.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20241009-devel-anna-maria-b4-timers-ptp-timekeeping-v2-15-554456a44a15@linutronix.de
---
kernel/time/timekeeping.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c30b187..ed0e328 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -774,6 +774,15 @@ static inline void tk_update_ktime_data(struct timekeeper *tk)
tk->tkr_raw.base = ns_to_ktime(tk->raw_sec * NSEC_PER_SEC);
}
+/*
+ * Restore the shadow timekeeper from the real timekeeper.
+ */
+static void timekeeping_restore_shadow(struct tk_data *tkd)
+{
+ lockdep_assert_held(&tkd->lock);
+ memcpy(&tkd->shadow_timekeeper, &tkd->timekeeper, sizeof(tkd->timekeeper));
+}
+
static void timekeeping_update(struct tk_data *tkd, struct timekeeper *tk, unsigned int action)
{
lockdep_assert_held(&tkd->lock);
@@ -801,7 +810,7 @@ static void timekeeping_update(struct tk_data *tkd, struct timekeeper *tk, unsig
* timekeeper structure on the next update with stale data
*/
if (action & TK_MIRROR)
- memcpy(&tkd->shadow_timekeeper, tk, sizeof(*tk));
+ timekeeping_restore_shadow(tkd);
}
static void timekeeping_update_from_shadow(struct tk_data *tkd, unsigned int action)
next reply other threads:[~2024-10-25 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 18:01 tip-bot2 for Thomas Gleixner [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-10-25 14:53 tip-bot2 for Thomas Gleixner
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=172987928047.1442.163274573376384169.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@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
all inboxes | Powered by JetHome®