Re: [RFC] tick_sched_timer() is not properly aligned, fixed by chance

From: Sebastian Andrzej Siewior
Date: Thu Apr 06 2023 - 11:03:26 EST


On 2023-04-06 13:08:29 [+0200], Thomas Gleixner wrote:
> On Thu, Apr 06 2023 at 12:55, Peter Zijlstra wrote:
> > On Thu, Apr 06, 2023 at 11:57:35AM +0200, Sebastian Andrzej Siewior wrote:
> >
> >> The tick_sched_timer story is that it uses ktime_get() to set the
> >
> > But but but, ktime_get() does not use sched_clock(), it has it's own TSC
> > reader.
>
> Correct and at that point during early boot the clocksource which feeds
> ktime_get() should be jiffies and not some other random clocksource.
>
> Sebastian, can you please evaluate which clocksource is used for
> ktime_get() at the point where the first clock event device is set up?

The first one added is hpet. It points to "jiffies" as name and
jiffies_read() as ->read().

Before the change/ with PeterZ change I get from ktime_get() for
base/nsec something like:
|[ 0.004000] tick_next_period Name: jiffies jiffies_read+0x0/0x10
|[ 0.004000] tick_next_period base/nsec: -401771248 405771248
|[ 0.004000] tick_next_period hpet 4000000

base/nsec is different on each boot but it always ends up with 4000000.
With the optimisation, ktime_get() is:
| [ 1.179079] tick_next_period base/nsec: 647439581 518613145
| [ 1.179646] tick_next_period hpet 1166052726

so something is using it during init. And this is
read_persistent_wall_and_boot_offset()

> Thanks,
>
> tglx
>
Sebastian