Tickless Kernels and the NoHz Option

Enhanced PTP User Guide (UG1602)

Document ID
UG1602
Release Date
2022-10-18
Revision
1.0 English

A feature of modern operating systems is that they use a “tickless” kernel which aims to reduce power consumption during kernel idle periods, and to increase performance:

  • Kernel version 2.6 introduced this feature, stopping the regular timer tick on CPU cores which are idle. However, experiments by the engineers who design sfptpd have proven that this “tickless” mode degrades PTP performance, producing less consistent results than when the kernel always receives periodic timer ticks.

    PTP relies on the ability to accurately change the speed of the system clock by very small and precise amounts. The Linux kernel implements this adjustment to system clock rate with integer arithmetic, minimizing the error term to the target clock rate in every timer tick. However, when the timer tick doesn’t run, the error in tracking to the requested clock rate increases, and the system time diverges from the clock rate requested. When the system wakes from idle, the timer tick runs and the kernel corrects for the error term.

  • Kernel version 3.10 introduced a new mode where only the boot CPU requires a tick. experiments by the engineers who design sfptpd have shown this “full tickless” mode does not degrade PTP performance.

Whether the kernel operates in a tickless mode is configured by the nohz and/or nohz_full boot time options, with the majority of Linux distributions defaulting to a tickless kernel. To achieve the highest accuracy with PTP, we suggest that you configure the kernel in one of the following ways:

  • Do not run tickless, and so receive timer ticks even when the system is idle.

    This can be achieved by adding "nohz=off" to the kernel boot parameters in the /boot/grub/grub.conf file.

  • Run in the “full tickless” mode (requires kernel version 3.10 or later).

    This can be achieved by adding "nohz_full=<cpu_list>" to the kernel boot parameters in the /boot/grub/grub.conf file, where <cpu_list> is a list of the CPU cores that are to use this mode (and cannot include the boot CPU).

    Alternatively, you can use the CONFIG_NO_HZ_FULL_ALL=y kernel configuration parameter to enable this mode for all CPUs except the boot CPU.

    You must also ensure that sfptpd runs on a dedicated full tickless CPU, using a CPU-affinitizing tool such as taskset.