From f17e6de7c086b58523c9103db2ece06ed1e3714a Mon Sep 17 00:00:00 2001 From: Mika Date: Wed, 10 Dec 2025 14:36:40 +0000 Subject: [PATCH] Add baseline_patch/patches/baseline_recalc_on_switch.patch --- .../patches/baseline_recalc_on_switch.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 baseline_patch/patches/baseline_recalc_on_switch.patch diff --git a/baseline_patch/patches/baseline_recalc_on_switch.patch b/baseline_patch/patches/baseline_recalc_on_switch.patch new file mode 100644 index 0000000..ac23022 --- /dev/null +++ b/baseline_patch/patches/baseline_recalc_on_switch.patch @@ -0,0 +1,36 @@ +diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c +index 1a2b3c4d5e6f..7f6e5d4c3b2a 100644 +--- a/kernel/time/clocksource.c ++++ b/kernel/time/clocksource.c +@@ + struct clocksource *curr_clocksource; + + static bool baseline_recalc_on_switch(struct clocksource *cs); + + static void clocksource_select(void) + { +@@ +- clock->read(clock); ++ /* ++ * Guarantee a fresh baseline so the first read() after a ++ * clocksource switch does not inherit stale offsets. ++ */ ++ if (clock->rebaseline && baseline_recalc_on_switch(clock)) ++ clock->rebaseline = false; ++ ++ clock->read(clock); + } + + static bool baseline_recalc_on_switch(struct clocksource *cs) + { +- return false; ++ u64 now; ++ ++ if (!cs || !cs->read) ++ return false; ++ ++ now = cs->read(cs); ++ cs->switch_time = now; ++ ++ return true; + }