Add baseline_patch/patches/baseline_recalc_on_switch.patch
This commit is contained in:
commit
f17e6de7c0
1 changed files with 36 additions and 0 deletions
36
baseline_patch/patches/baseline_recalc_on_switch.patch
Normal file
36
baseline_patch/patches/baseline_recalc_on_switch.patch
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue