You are not logged in.

#1 2021-09-16 21:45:38

darsonis
Member
Registered: 2021-09-16
Posts: 7

Weird TSC clocksource behavior on reboot (not observed on shutdown)

Hello to the arch-linux community !

I have an odd behaviour of my TSC-clocksource & I'd like to ask for
some comments (or possibly a solution) on this situation.
I'm currently running arch linux kernel 5.14.5-arch1-1.

I'm on a thinkpad T14s AMD Gen1, bios version 1.32 (which states in its release notes that
a TSC-cycle issue has been fixed).

When I shutdown the machine using e.g.

shutdown now

and boot it via manual button press
tsc seems to work:

output of

 
sudo dmesg | grep tsc
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 1697.000 MHz processor
[    0.165957] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x18761557fca, max_idle_ns: 440795262603 ns
[    0.369635] clocksource: Switched to clocksource tsc-early
[    1.525978] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x18761557fca, max_idle_ns: 440795262603 ns
[    1.526054] clocksource: Switched to clocksource tsc 

output of

 
cat /sys/devices/system/clocksource/clocksource0/current_clocksource`:
tsc

however, once I reboot the machine using e.g. `reboot` via cmdline
i get the following behaviour.

 
sudo dmesg | grep tsc
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 1696.656 MHz processor
[    0.166461] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x1874d03af40, max_idle_ns: 440795221980 ns
[    0.377550] clocksource: Switched to clocksource tsc-early
[    1.404575] tsc: Refined TSC clocksource calibration: 1699.686 MHz
[    1.404596] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x187ffe91441, max_idle_ns: 440795214783 ns
[    1.404692] clocksource: Switched to clocksource tsc
[    2.173197] clocksource: timekeeping watchdog on CPU3: Marking clocksource 'tsc' as unstable because the skew is too large:
[    2.173209] clocksource:                       'tsc' cs_nsec: 502589882 cs_now: 470df11ab cs_last: 43df45343 mask: ffffffffffffffff
[    2.173212] clocksource:                       'tsc' is current clocksource.
[    2.173224] tsc: Marking TSC unstable due to clocksource watchdog
[    2.173598] TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
[    2.174045] clocksource: Checking clocksource tsc synchronization from CPU 10 to CPUs 0,5-6,9,12.


cat /sys/devices/system/clocksource/clocksource0/current_clocksource
hpet

once I shutdown the machine and manually booting it, tsc works again.

A few sidenotes: apparently after rebooting the machine using `reboot` and adding `tsc=nowatchdog` kernel parameter, tsc seems to work on a reboot aswell.

and according to this discussion
-> https://forums.lenovo.com/t5/Other-Linu … 905?page=2

a user described similar behaviour however the other way around (TSC bug arising using a system shutdown)

Moreover can someone explain to me the difference between tsc & hpet as clocksource and why one would be prefered over the other ?

Greetings !

Last edited by darsonis (2021-09-16 21:49:36)

Offline

#2 2021-11-27 23:35:29

hxss
Member
Registered: 2017-10-17
Posts: 34

Re: Weird TSC clocksource behavior on reboot (not observed on shutdown)

I have similar warnings after reboot.

2021-11-28T02:29:07+0300 hp kernel: clocksource: timekeeping watchdog on CPU3: Marking clocksource 'tsc' as unstable because the skew is too large:
2021-11-28T02:29:07+0300 hp kernel: clocksource:                       'hpet' wd_nsec: 507501092 wd_now: 1baff6a wd_last: 14c1eae mask: ffffffff
2021-11-28T02:29:07+0300 hp kernel: clocksource:                       'tsc' cs_nsec: 506649399 cs_now: 329793bc1 cs_last: 2f01b810e mask: ffffffffffffffff
2021-11-28T02:29:07+0300 hp kernel: clocksource:                       'tsc' is current clocksource.
2021-11-28T02:29:07+0300 hp kernel: TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
2021-11-28T02:29:07+0300 hp kernel: clocksource: Checking clocksource tsc synchronization from CPU 8 to CPUs 0,6-7,9-11,15.
Kernel: x86_64 Linux 5.15.5-arch1-1
CPU: AMD Ryzen 7 5800U with Radeon Graphics @ 16x 1.9GHz

Offline

#3 2022-05-10 00:48:36

Neven
Member
Registered: 2014-05-02
Posts: 75

Re: Weird TSC clocksource behavior on reboot (not observed on shutdown)

darsonis wrote:

Moreover can someone explain to me the difference between tsc & hpet as clocksource and why one would be prefered over the other ?

When TSC is the clocksource, userspace can use the vDSO instead of syscalling into the kernel to read time (clock_gettime). So TSC is faster.

For more, see:

https://unix.stackexchange.com/question … using-hpet
https://stackoverflow.com/questions/685 … ent-kernel
https://www.brendangregg.com/blog/2021- … -time.html

Offline

#4 2022-05-10 00:50:26

Neven
Member
Registered: 2014-05-02
Posts: 75

Re: Weird TSC clocksource behavior on reboot (not observed on shutdown)

I have the same problem as the two prior posters, and it's interesting that:

1. we all have AMD CPUs
2. it seems CPU3 is always the core "at fault", judging by the kernel log samples

Offline

#5 2022-06-02 22:23:37

kormpu
Member
Registered: 2020-08-18
Posts: 30

Re: Weird TSC clocksource behavior on reboot (not observed on shutdown)

I'm having the same messages as well. Are you any of you also getting this?

mtrr: your CPUs had inconsistent variable MTRR settings

Offline

Board footer

Powered by FluxBB