Performing verification:

First, reproducing on older kernel:

$ uname -rv
4.4.0-190-generic #220-Ubuntu SMP Fri Aug 28 23:02:15 UTC 2020
$ grep "clocksource" /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="clocksource=tsc"
$ cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-4.4.0-190-generic 
root=UUID=f6c72a0a-003a-4b81-9550-ba49a547e32d ro clocksource=tsc
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
kvm-clock

kvm-clock is the default, even though we explicitly asked for tsc. We
can reproduce.

Now, I enabled -proposed and installed 4.4.0-191-generic:

$ uname -rv
4.4.0-191-generic #221-Ubuntu SMP Fri Sep 18 13:34:04 UTC 2020
$ grep "clocksource" /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="clocksource=tsc"
$ cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-4.4.0-191-generic 
root=UUID=f6c72a0a-003a-4b81-9550-ba49a547e32d ro clocksource=tsc
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
$ dmesg | grep defer
[    0.870439] clocksource: Override clocksource tsc is not currently HRT 
compatible - deferring

We have our requested clocksource, tsc, and we did not need to force
override the reliability checks from the watchdog.

The kernel in -proposed, 4.4.0-191-generic, fixes the problem, and I am
happy to mark the bug verified.

** Tags removed: verification-needed-xenial
** Tags added: verification-done-xenial

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1894591

Title:
  clock: overriding the clocksource should select the requested
  clocksource

Status in linux package in Ubuntu:
  Fix Released
Status in linux source package in Xenial:
  Fix Committed

Bug description:
  BugLink: https://bugs.launchpad.net/bugs/1894591

  [Impact]

  The default clocksource for a KVM VM is kvm-clock, and I happen to
  need tsc.

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  kvm-clock

  If I edit /etc/default/grub and append "clocksource=tsc" to
  GRUB_CMDLINE_LINUX_DEFAULT and reboot, I find the clocksource is still
  kvm-clock.

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  kvm-clock

  I can work around this by telling the kernel that the tsc clocksource
  is reliable, before the watchdog has a chance to see for itself that
  it is reliable:

  GRUB_CMDLINE_LINUX_DEFAULT="clocksource=tsc tsc=reliable"

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  tsc

  If I override the clocksource, the kernel should respect my wishes and
  I should receive the requested clocksource.

  [Fix]

  The fix landed in Linux 4.9 in the below commit:

  commit 36374583f9084cdab4b5dcf5521a3ce55bebb9fa
  Author: Kyle Walker <kwal...@redhat.com>
  Date:   Sat Aug 6 12:07:30 2016 -0400
  Subject: clocksource: Defer override invalidation unless clock is unstable
  Link: 
https://github.com/torvalds/linux/commit/36374583f9084cdab4b5dcf5521a3ce55bebb9fa

  The commit ensures the override doesn't get cleared before the
  watchdog has had an opportunity to check if the clocksource is stable
  or not. However, if the clocksource is known to be unstable at this
  point in time, it will clear the override and return to the default.

  This is a clean cherry-pick to the Xenial 4.4 kernel.

  [Testcase]

  Start up a KVM VM, possibly enable invtsc on the QEMU command line.

  The default clocksource will be kvm-clock:

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  kvm-clock

  If you set the kernel command line to:

  GRUB_CMDLINE_LINUX_DEFAULT="clocksource=tsc"

  If you reboot, you will see the incorrect option of kvm-clock:

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  kvm-clock

  There is a test kernel available in the below ppa, with the commit
  applied:

  https://launchpad.net/~mruffell/+archive/ubuntu/sf291501-test

  If you install the test kernel, and leave the kernel command line as:

  GRUB_CMDLINE_LINUX_DEFAULT="clocksource=tsc"

  You will get the requested clocksource:

  $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  tsc

  You will also get the following in dmesg:

  $ dmesg | grep defer
  [    1.002599] clocksource: Override clocksource tsc is not currently HRT 
compatible - deferring

  [Regression Potential]

  This commit changes how the kernel treats clocksource overrides. If
  any users have an override set, but the kernel is clearing the
  override and returning to the default, when they install a patched
  kernel, they will change over to their requested override, which may
  come as a surprise.

  If there is a regression, it will only affect systems who have
  clocksource overrides in place, and in the worst case, will revert the
  system to its default clocksource if the selected clocksource override
  is found to be unstable.

  The commit is well tested, and should not cause any regressions.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1894591/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to