diff mbox series

[v2,03/25] timekeeping: Avoid duplicate leap state update

Message ID 20241009-devel-anna-maria-b4-timers-ptp-timekeeping-v2-3-554456a44a15@linutronix.de (mailing list archive)
State Not Applicable
Headers show
Series timekeeping: Rework to prepare support of indenpendent PTP clocks | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Anna-Maria Behnsen Oct. 9, 2024, 8:28 a.m. UTC
From: Anna-Maria Behnsen <anna-maria@linutronix.de>

do_adjtimex() invokes tk_update_leap_state() unconditionally even when a
previous invocation of timekeeping_update() already did that update.

Put it into the else path which is invoked when timekeeping_update() is not
called.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 kernel/time/timekeeping.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

John Stultz Oct. 9, 2024, 5:31 p.m. UTC | #1
On Wed, Oct 9, 2024 at 1:29 AM Anna-Maria Behnsen
<anna-maria@linutronix.de> wrote:
>
> From: Anna-Maria Behnsen <anna-maria@linutronix.de>
>
> do_adjtimex() invokes tk_update_leap_state() unconditionally even when a
> previous invocation of timekeeping_update() already did that update.
>
> Put it into the else path which is invoked when timekeeping_update() is not
> called.
>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Could probably use a comment in the code to that effect, but otherwise:

Acked-by: John Stultz <jstultz@google.com>
diff mbox series

Patch

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4e3afe22d28c..c4dd460b6f2b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2596,8 +2596,9 @@  int do_adjtimex(struct __kernel_timex *txc)
 		__timekeeping_set_tai_offset(tk, tai);
 		timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET);
 		clock_set = true;
+	} else {
+		tk_update_leap_state(tk);
 	}
-	tk_update_leap_state(tk);
 
 	write_seqcount_end(&tk_core.seq);
 	raw_spin_unlock_irqrestore(&timekeeper_lock, flags);