File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -642,7 +642,6 @@ asmlinkage __visible void __init start_kernel(void)
642
642
softirq_init ();
643
643
timekeeping_init ();
644
644
time_init ();
645
- sched_clock_init ();
646
645
printk_safe_init ();
647
646
perf_event_init ();
648
647
profile_init ();
@@ -697,6 +696,7 @@ asmlinkage __visible void __init start_kernel(void)
697
696
acpi_early_init ();
698
697
if (late_time_init )
699
698
late_time_init ();
699
+ sched_clock_init ();
700
700
calibrate_delay ();
701
701
pid_idr_init ();
702
702
anon_vma_init ();
Original file line number Diff line number Diff line change @@ -202,7 +202,25 @@ static void __sched_clock_gtod_offset(void)
202
202
203
203
void __init sched_clock_init (void )
204
204
{
205
+ unsigned long flags ;
206
+
207
+ /*
208
+ * Set __gtod_offset such that once we mark sched_clock_running,
209
+ * sched_clock_tick() continues where sched_clock() left off.
210
+ *
211
+ * Even if TSC is buggered, we're still UP at this point so it
212
+ * can't really be out of sync.
213
+ */
214
+ local_irq_save (flags );
215
+ __sched_clock_gtod_offset ();
216
+ local_irq_restore (flags );
217
+
205
218
sched_clock_running = 1 ;
219
+
220
+ /* Now that sched_clock_running is set adjust scd */
221
+ local_irq_save (flags );
222
+ sched_clock_tick ();
223
+ local_irq_restore (flags );
206
224
}
207
225
/*
208
226
* We run this as late_initcall() such that it runs after all built-in drivers,
@@ -356,7 +374,7 @@ u64 sched_clock_cpu(int cpu)
356
374
return sched_clock () + __sched_clock_offset ;
357
375
358
376
if (unlikely (!sched_clock_running ))
359
- return 0ull ;
377
+ return sched_clock () ;
360
378
361
379
preempt_disable_notrace ();
362
380
scd = cpu_sdc (cpu );
You can’t perform that action at this time.
0 commit comments