Skip to contentSkip to conversation

/proc/stat idle time exceeds wall clock since v7.2

REGRESSION Ahmed Shaltout 2 participants 6 messages Sep 19 – Sep 30

lore
Share & tools
lore
#0 lore raw

Hello,

Since moving from 7.1.8 to 7.2.5 (openSUSE MicroOS kernel-default), the idle time reported in /proc/stat exceeds the wall-clock time the CPUs have been up for. Idle alone accrues ~103% of the ceiling, and user+nice+system+idle+iowait +irq+softirq+steal sums to ~108% of it.

This breaks the common 100 - rate(idle) derivation of CPU utilisation, which goes negative on an idle-but-working machine. node_exporter, and anything built on it, is affected.

#regzbot introduced: v7.1..v7.2

Reproducer
==========

No tooling needed; /proc/uptime shows it directly, since its second field is idle time and cannot legitimately exceed uptime x nr_cpus:

  read -r up idle < /proc/uptime && awk -v u="$up" -v i="$idle" -v c="$(nproc)" \
    'BEGIN{printf "idle %.2f%% of ceiling\n", 100*i/(u*c)}'

7.2.5: idle 103.10% of ceiling
7.1.8: idle 89.13% of ceiling

A 60-second delta over the per-CPU lines of /proc/stat, on 7.2.5, 8 CPUs, ceiling 480.04 CPU-seconds:

user 9.95 2.07%
nice 0.00 0.00%
system 6.56 1.37%
idle 495.44 103.21%
iowait 2.40 0.50%
irq 0.00 0.00%
softirq 2.83 0.59%
steal 0.00 0.00%

BUSY 21.74 4.53%
IDLE 495.44 103.21%
TOTAL 517.18 107.74% excess 37.14 CPU-seconds

The busy modes are consistent with the machine's actual load; the entire excess is in the idle column. The same measurement on 7.1.8 gives 478.49 / 480.07 = 0.9967.

/proc/stat and /proc/uptime agree with each other exactly on both kernels (stat_idle / uptime_idle = 1.0000), so proc_stat(5)'s equality clause holds. What is violated is wall clock alone. That appears to place the problem in the counter both files read rather than in the /proc plumbing.

Environment
===========

AMD EPYC-Rome, KVM guest (Hetzner Cloud), 8 vCPUs
clocksource: kvm-clock
CONFIG_HZ=1000, CONFIG_HZ_1000=y
CONFIG_NO_HZ_COMMON=y, CONFIG_NO_HZ_FULL=y, CONFIG_NO_HZ=y CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, CONFIG_VIRT_CPU_ACCOUNTING=y CONFIG_SCHED_HRTICK=y
CONFIG_TICK_CPU_ACCOUNTING, CONFIG_IRQ_TIME_ACCOUNTING and CONFIG_PARAVIRT_TIME_ACCOUNTING are all unset
no nohz_full= on the command line; /sys/devices/system/cpu/nohz_full is empty cmdline is otherwise identical between the two kernels (psi=1, selinux=1)

The kernel configuration above is byte-identical between 7.1.8 and 7.2.5 for every option listed.

Already ruled out
=================

- Userspace: the raw /proc/stat and /proc/uptime numbers show it; no exporter involved.
- Clocksource: kvm-clock on both.
- NTP: offset 0, sync_status 1.
- nohz_full: compiled in but not enabled; the cpumask is empty on both.
- Possible-vs-online CPU miscount: possible == online == nproc == 8. The measurement above uses the per-CPU cpuN lines only, and the aggregate- versus-per-CPU deltas were 14, 7 and 18 jiffies.
- Since-boot accumulation: the figures are deltas over a fresh 60s window.
- Steal deferral: kcpustat_idle_stop() defers steal subtraction by one window by design, but steal is 0.00 here and that deviation is bounded and self-cancelling in any case.

Suspected origin
================

This is a distro-kernel comparison, not a mainline bisect -- I have not bisected and cannot currently do so on these machines, so please treat the attribution below as a guess rather than a finding.

The only v7.2 change I can find touching this path is the tick/nohz series merged as timers-nohz-2026-06-13 ("tick/sched: Refactor idle cputime accounting"). The behaviour matches the version boundary exactly: absent in 7.1.8, present in 7.2.5. I note the series was motivated by idle going *backwards*, i.e. the opposite direction from what I am seeing, so this may well be an unrelated interaction.

I also checked whether this might be an intended change in what /proc/stat promises, and could not find evidence that it is: Documentation/filesystems/ proc.rst is unchanged between v7.1 and v7.2, the series touches no Documentation/ file, and proc_stat(5) carries no "since Linux 7.2" note. If the semantics did change deliberately, a pointer to where that is recorded would be welcome and I will adjust our side instead.

Happy to test patches or gather more data -- these are long-running machines and the effect is present continuously, so it is easy to measure.

Thanks,
Shaltout,

#1 lore raw

Hi Ahmed,

Quoted 16 lines · Ahmed Shaltout

Hello,

Since moving from 7.1.8 to 7.2.5 (openSUSE MicroOS kernel-default), the idle time reported in /proc/stat exceeds the wall-clock time the CPUs have been up for. Idle alone accrues ~103% of the ceiling, and user+nice+system+idle+iowait +irq+softirq+steal sums to ~108% of it.

This breaks the common 100 - rate(idle) derivation of CPU utilisation, which goes negative on an idle-but-working machine. node_exporter, and anything built on it, is affected.

#regzbot introduced: v7.1..v7.2

Reproducer
==========

Quoted 8 lines

No tooling needed; /proc/uptime shows it directly, since its second field is idle time and cannot legitimately exceed uptime x nr_cpus:

  read -r up idle < /proc/uptime && awk -v u="$up" -v i="$idle" -v c="$(nproc)" \
    'BEGIN{printf "idle %.2f%% of ceiling\n", 100*i/(u*c)}'

7.2.5: idle 103.10% of ceiling
7.1.8: idle 89.13% of ceiling

I can't manage to reproduce that, neither on latest mainline nor on 7.2.7

Can you share your whole .config file?

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#2 lore raw

Hi Frederic,

Quoted 3 lines · Frederic Weisbecker

I can't manage to reproduce that, neither on latest mainline nor on 7.2.7

Can you share your whole .config file?

Attached: config-7.2.5-1-default, taken from /boot/config-$(uname -r) on an affected node. It is the stock openSUSE Tumbleweed/MicroOS package kernel-default-7.2.5-1.1.x86_64, unmodified, no custom build. It differs from
config/x86_64/default in openSUSE:Factory/kernel-source at the 7.2.5 source revision only in toolchain-detection and build-metadata lines (CC/AS/LD version, LOCALVERSION, MODULE_SIG_KEY, CC_HAS_*), no functional option:
https://api.opensuse.org/public/source/openSUSE:Factory/kernel-source/config.tar.bz2?rev=4dabae0b715184e35b05b9a168bde6b7

The unaffected control box runs kernel-default-7.1.8-1.1.x86_64 from the same
distribution, also stock, same VM type, same command line. Between the two configs the only change among the scheduler, tick, accounting, preemption and
RCU options is CONFIG_SCHED_CACHE=y appearing in 7.2.5.

Environment, in case it is what your test box does not share:

- Every node is a KVM guest (Hetzner Cloud, QEMU, "AMD EPYC-Rome
Processor",
8 vCPUs, one with 4), clocksource kvm-clock.
- No steal-time accounting at all: there is no kvm-stealtime line in the boot log and the steal column has read exactly 0 on every node for the 75 hours since boot, so the hypervisor does not seem to expose the MSR.
- CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, CONFIG_CONTEXT_TRACKING_IDLE=y and CONFIG_NO_HZ_FULL=y are built in (SUSE default) with nohz_full= empty, so the CPUs run idle dynticks, not full.
- CONFIG_HZ=1000, CONFIG_PREEMPT_DYNAMIC=y, psi=1 on the command line:

    BOOT_IMAGE=/boot/vmlinuz-7.2.5-1-default root=UUID=... rd.timeout=60
    rd.retry=45 quiet systemd.show_status=yes console=ttyS0,115200
    console=tty0 ignition.platform.id=openstack security=selinux selinux=1
    psi=1

It is fleet-wide, not one box. /proc/uptime idle as a percentage of uptime x nr_cpus, read today on all eight nodes:

node kernel cpus uptime idle
cp-fsn1 7.2.5-1-default 8 75.0h 102.64%
cp-nbg1-pps 7.2.5-1-default 8 74.5h 102.03%
cp-nbg1-waa 7.2.5-1-default 8 74.2h 103.30%
cp-hel1 7.2.5-1-default 8 75.2h 97.59%
cp-hel1-b 7.2.5-1-default 8 75.2h 101.20%
worker-fsn1 7.2.5-1-default 8 74.0h 100.27%
monitoring 7.2.5-1-default 4 73.8h 102.75%
staging 7.1.8-1-default 8 852.4h 89.15%

cp-hel1 is the busiest node and stays under 100 only because real work displaces it; the excess is an offset on idle, not a constant.

A 60 s delta over the per-CPU cpuN lines of /proc/stat on cp-nbg1-waa (8 cores, 480.06 CPU-second ceiling):

user 10.84 nice 0.00 system 6.60 iowait 2.33 irq 0.00 softirq 2.65 steal
0.00
busy 22.42 = 4.67% of ceiling
idle 493.64 = 102.83% of ceiling
sum 516.06 = 107.50% of ceiling (excess 36.00, all of it in idle)

/proc/uptime's idle field moves with /proc/stat exactly (stat_idle / uptime_idle = 1.0000 on both kernels), so the two files agree with each other and only wall clock is exceeded. On 7.1.8 the modes sum to 0.992-0.997 of the ceiling over the same kind of window.

What did you reproduce on: bare metal or a KVM guest, and with TICK_CPU_ACCOUNTING or VIRT_CPU_ACCOUNTING_GEN? I only have the version bisection (7.1.8 good, 7.2.5 bad, same config family), not a commit. If it helps I can boot kernel-vanilla and a 7.2.7 build on a throwaway VM of the same type, or run any diagnostic you want on an affected node.

Thanks,
Ahmed

Quoted 45 lines · Frederic Weisbecker

Hi Ahmed,

Quoted 3 lines · Ahmed Shaltout

Hello,

Since moving from 7.1.8 to 7.2.5 (openSUSE MicroOS kernel-default), the

idle

Quoted 1 line

time reported in /proc/stat exceeds the wall-clock time the CPUs have

been up

Quoted 1 line

for. Idle alone accrues ~103% of the ceiling, and

user+nice+system+idle+iowait

Quoted 3 lines

+irq+softirq+steal sums to ~108% of it.

This breaks the common 100 - rate(idle) derivation of CPU utilisation,

which

Quoted 1 line

goes negative on an idle-but-working machine. node_exporter, and

anything built

Quoted 8 lines

on it, is affected.

#regzbot introduced: v7.1..v7.2

Reproducer
==========

No tooling needed; /proc/uptime shows it directly, since its second

field is

Quoted 3 lines

idle time and cannot legitimately exceed uptime x nr_cpus:

  read -r up idle < /proc/uptime && awk -v u="$up" -v i="$idle" -v

c="$(nproc)" \

Quoted 4 lines
    'BEGIN{printf "idle %.2f%% of ceiling\n", 100*i/(u*c)}'

7.2.5: idle 103.10% of ceiling
7.1.8: idle 89.13% of ceiling

I can't manage to reproduce that, neither on latest mainline nor on 7.2.7

Can you share your whole .config file?

Thanks.

--
Frederic Weisbecker
SUSE Labs

#3 lore raw
Quoted 7 lines · Ahmed Shaltout

Hi Frederic,

Quoted 3 lines · Frederic Weisbecker

I can't manage to reproduce that, neither on latest mainline nor on 7.2.7

Can you share your whole .config file?

Quoted 8 lines

Attached: config-7.2.5-1-default, taken from /boot/config-$(uname -r) on an affected node. It is the stock openSUSE Tumbleweed/MicroOS package kernel-default-7.2.5-1.1.x86_64, unmodified, no custom build. It differs from
config/x86_64/default in openSUSE:Factory/kernel-source at the 7.2.5 source revision only in toolchain-detection and build-metadata lines (CC/AS/LD version, LOCALVERSION, MODULE_SIG_KEY, CC_HAS_*), no functional option:
https://api.opensuse.org/public/source/openSUSE:Factory/kernel-source/config.tar.bz2?rev=4dabae0b715184e35b05b9a168bde6b7

I fear I still can't reproduce with the config in attachment.

Quoted 20 lines

The unaffected control box runs kernel-default-7.1.8-1.1.x86_64 from the same
distribution, also stock, same VM type, same command line. Between the two configs the only change among the scheduler, tick, accounting, preemption and
RCU options is CONFIG_SCHED_CACHE=y appearing in 7.2.5.

Environment, in case it is what your test box does not share:

- Every node is a KVM guest (Hetzner Cloud, QEMU, "AMD EPYC-Rome
Processor",
8 vCPUs, one with 4), clocksource kvm-clock.
- No steal-time accounting at all: there is no kvm-stealtime line in the boot log and the steal column has read exactly 0 on every node for the 75 hours since boot, so the hypervisor does not seem to expose the MSR.
- CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, CONFIG_CONTEXT_TRACKING_IDLE=y and CONFIG_NO_HZ_FULL=y are built in (SUSE default) with nohz_full= empty, so the CPUs run idle dynticks, not full.
- CONFIG_HZ=1000, CONFIG_PREEMPT_DYNAMIC=y, psi=1 on the command line:

Quoted 4 lines
    BOOT_IMAGE=/boot/vmlinuz-7.2.5-1-default root=UUID=... rd.timeout=60
    rd.retry=45 quiet systemd.show_status=yes console=ttyS0,115200
    console=tty0 ignition.platform.id=openstack security=selinux selinux=1
    psi=1

I ran on KVM too, overcommiting the vcpus like you did (16 vCPUs on 8 CPUs) and still nothing wrong.

I'm wondering if this is specific to opensuse somehow. Can you try to build the latest upstream kernel?

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#4 lore raw

Hi Frederic,

Quoted 1 line · Frederic Weisbecker

I ran on KVM too, overcommiting the vcpus like you did (16 vCPUs on 8

CPUs)

Quoted 5 lines

and still nothing wrong.

I'm wondering if this is specific to opensuse somehow. Can you try to

build

Quoted 1 line

the latest upstream kernel?

I will, but first one difference that may explain why your guest stays

clean, and a hypothesis that fits our numbers.

Attached again is the 7.2.5 config, plus the 7.1.8 config from the control

box. Both are the stock openSUSE kernel-default files from /boot, unmodified.

Among the scheduler, tick, idle, accounting, preemption and RCU options they

differ only in CONFIG_SCHED_CACHE=y (7.2.5). All seven affected nodes run a

byte-identical config. None of the openSUSE-specific patches on top of

upstream stable touch tick, cputime, nohz, cpuidle or /proc. Going by their

names, they cover lockdown/secure boot, kABI, a few drivers and packaging.

1. There is no cpuidle driver on these guests

---------------------------------------------

On every node, affected or not:

/sys/devices/system/cpu/cpuidle/current_driver none

/sys/devices/system/cpu/cpuidle/current_governor menu

/sys/devices/system/cpu/cpu0/cpuidle/ no state* entries

So cpuidle_idle_call() takes the cpuidle_not_available() branch and calls

idle_call_stop_or_retain_tick(got_tick). On the first pass through the idle

loop the tick is retained, and it is stopped only after a tick has fired in

idle. What does your guest report there? If a driver's governor stops the

tick at idle entry, that could be the difference.

2. Hypothesis: the tick after a dyntick-idle window re-counts part of it

------------------------------------------------------------------------

This comes from reading v7.2, not from a test. Take the case with no cpuidle

driver:

- The retained idle tick is charged to CPUTIME_IDLE by

    account_process_tick(), since kcpustat_idle_dyntick() is still false.

    Its irq exit sets ts->idle_entrytime. The window then opens there via

    kcpustat_dyntick_start(ts->idle_entrytime), so the start is seamless.

- On wakeup, tick_nohz_idle_exit() closes the window at "now"

(kcpustat_dyntick_stop). tick_nohz_restart() re-arms the tick at the

next jiffy boundary. That first tick charges a full TICK_NSEC, although

the part of that jiffy before "now" is already in the window.

- The over-count is the wakeup's phase within its jiffy, once per

window. Up to v7.1, /proc/stat read get_cpu_idle_time_us() for online

CPUs and ignored tick-charged idle, so the two never met in one counter.

- When a governor stops the tick at idle entry instead, the window starts

mid-jiffy. The fragment between the last tick and idle entry is then

never charged, which would roughly offset the end seam on average. That

might be why your guest looks right.

I have not verified this on a patched kernel, so please treat it as a lead

only.

3. Measurements, 60 s windows taken today on each node

-------------------------------------------------------

These are the per-CPU cpuN lines of /proc/stat against /proc/uptime's first

field, and .idle_sleeps from /proc/timer_list over the same window.

"sum/wall" is all eight modes divided by uptime x nr_cpus.

node cpus kernel sum/wall excess ms/s/cpu sleeps/s/cpu
ms/sleep

cp-fsn1 8 7.2.5 1.100 100 351 0.285

cp-nbg1-pps 8 7.2.5 1.080 80 268 0.299

cp-nbg1-waa 8 7.2.5 1.072 74 245 0.301

cp-hel1 8 7.2.5 1.081 83 278 0.297

cp-hel1-b 8 7.2.5 1.076 76 255 0.298

worker-fsn1 8 7.2.5 1.063 58 200 0.292

monitoring 4 7.2.5 1.093 95 282 0.338

staging 8 7.1.8 0.985 -14 263 -

- Across nodes the excess tracks the tick-stop rate at about 0.3 ms per

.idle_sleeps event. Within one node it does not: a CPU with twice the

sleeps shows the same excess. .idle_sleeps is incremented on every

__tick_nohz_idle_stop_tick() call, including re-stops after an IRQ inside

an already-stopped idle period. So it overstates the number of windows on

IRQ-heavy CPUs. These guests stop the tick 200-350 times/s per CPU. A

near-idle test guest would show much less.

- /proc/stat idle and /proc/uptime idle still agree to within 0.02 s on

every node, over the same window.

- The seven affected nodes were on older kernels on the same VMs until

19 Sept: five on 7.1.8 and two on 7.0.12. Their daily all-mode sum read

0.979-0.993 of wall clock. Since rebooting into 7.2.5 it reads 1.04-1.10.

4. Corrections to my previous mail

----------------------------------

- Not every node is AMD EPYC-Rome. cp-hel1 reports "Intel Xeon Processor

(Skylake, IBRS, no TSX)" and shows the same excess (1.081), so it is not

vendor-specific. All nodes are the same Hetzner cx43 VM type, except the

4-vCPU one (cx33).

- cp-hel1 is tainted W, from a boot-time "CPA detected W^X violation"

warning in __change_page_attr. The other six are untainted and show the

same excess.

- I wrote that 7.1.8 sums to 0.992-0.997 of the ceiling. Over the last

three days it is 0.983-0.985, so 7.1.8 slightly under-counts rather than

matching wall clock exactly.

If the cpuidle difference does not let you reproduce it, I will boot

openSUSE's kernel-vanilla (Kernel:HEAD, currently 7.3-rc5, no distro patches)

on a VM of the same type, with 7.2.5 and 7.1.8 on the same VM as controls,

and send the three results.

Thanks,

Ahmed

Quoted 66 lines · Frederic Weisbecker
Quoted 4 lines · Ahmed Shaltout

Hi Frederic,

Quoted 1 line · Frederic Weisbecker

I can't manage to reproduce that, neither on latest mainline nor on

7.2.7

Quoted 4 lines
Quoted 2 lines

Can you share your whole .config file?

Attached: config-7.2.5-1-default, taken from /boot/config-$(uname -r) on

an

Quoted 4 lines

affected node. It is the stock openSUSE Tumbleweed/MicroOS package kernel-default-7.2.5-1.1.x86_64, unmodified, no custom build. It differs from
config/x86_64/default in openSUSE:Factory/kernel-source at the 7.2.5

source

Quoted 3 lines

revision only in toolchain-detection and build-metadata lines (CC/AS/LD version, LOCALVERSION, MODULE_SIG_KEY, CC_HAS_*), no functional option:

https://api.opensuse.org/public/source/openSUSE:Factory/kernel-source/config.tar.bz2?rev=4dabae0b715184e35b05b9a168bde6b7

I fear I still can't reproduce with the config in attachment.

Quoted 4 lines

The unaffected control box runs kernel-default-7.1.8-1.1.x86_64 from the same
distribution, also stock, same VM type, same command line. Between the

two

Quoted 10 lines

configs the only change among the scheduler, tick, accounting, preemption and
RCU options is CONFIG_SCHED_CACHE=y appearing in 7.2.5.

Environment, in case it is what your test box does not share:

- Every node is a KVM guest (Hetzner Cloud, QEMU, "AMD EPYC-Rome
Processor",
8 vCPUs, one with 4), clocksource kvm-clock.
- No steal-time accounting at all: there is no kvm-stealtime line in

the

Quoted 1 line

boot log and the steal column has read exactly 0 on every node for

the

Quoted 1 line

75 hours since boot, so the hypervisor does not seem to expose the

MSR.

Quoted 2 lines

- CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, CONFIG_CONTEXT_TRACKING_IDLE=y and CONFIG_NO_HZ_FULL=y are built in (SUSE default) with nohz_full=

empty,

Quoted 5 lines

so the CPUs run idle dynticks, not full.
- CONFIG_HZ=1000, CONFIG_PREEMPT_DYNAMIC=y, psi=1 on the command line:

    BOOT_IMAGE=/boot/vmlinuz-7.2.5-1-default root=UUID=... rd.timeout=60
    rd.retry=45 quiet systemd.show_status=yes console=ttyS0,115200
    console=tty0 ignition.platform.id=openstack security=selinux

selinux=1

Quoted 1 line
    psi=1

I ran on KVM too, overcommiting the vcpus like you did (16 vCPUs on 8 CPUs) and still nothing wrong.

I'm wondering if this is specific to opensuse somehow. Can you try to build the latest upstream kernel?

Thanks.

--
Frederic Weisbecker
SUSE Labs

#5 lore raw
Quoted 56 lines · Ahmed Shaltout

Hi Frederic,

Quoted 1 line · Frederic Weisbecker

I ran on KVM too, overcommiting the vcpus like you did (16 vCPUs on 8

CPUs)

Quoted 5 lines

and still nothing wrong.

I'm wondering if this is specific to opensuse somehow. Can you try to

build

Quoted 1 line

the latest upstream kernel?

I will, but first one difference that may explain why your guest stays

clean, and a hypothesis that fits our numbers.

Attached again is the 7.2.5 config, plus the 7.1.8 config from the control

box. Both are the stock openSUSE kernel-default files from /boot, unmodified.

Among the scheduler, tick, idle, accounting, preemption and RCU options they

differ only in CONFIG_SCHED_CACHE=y (7.2.5). All seven affected nodes run a

byte-identical config. None of the openSUSE-specific patches on top of

upstream stable touch tick, cputime, nohz, cpuidle or /proc. Going by their

names, they cover lockdown/secure boot, kABI, a few drivers and packaging.

1. There is no cpuidle driver on these guests

---------------------------------------------

On every node, affected or not:

/sys/devices/system/cpu/cpuidle/current_driver none

/sys/devices/system/cpu/cpuidle/current_governor menu

/sys/devices/system/cpu/cpu0/cpuidle/ no state* entries

So cpuidle_idle_call() takes the cpuidle_not_available() branch and calls

Quoted 7 lines

idle_call_stop_or_retain_tick(got_tick). On the first pass through the idle

loop the tick is retained, and it is stopped only after a tick has fired in

idle. What does your guest report there? If a driver's governor stops the

tick at idle entry, that could be the difference.

I have the same cpuidle configuration: menu with no drivers.

Quoted 35 lines

2. Hypothesis: the tick after a dyntick-idle window re-counts part of it

------------------------------------------------------------------------

This comes from reading v7.2, not from a test. Take the case with no cpuidle

driver:

- The retained idle tick is charged to CPUTIME_IDLE by

    account_process_tick(), since kcpustat_idle_dyntick() is still false.

    Its irq exit sets ts->idle_entrytime. The window then opens there via

    kcpustat_dyntick_start(ts->idle_entrytime), so the start is seamless.

- On wakeup, tick_nohz_idle_exit() closes the window at "now"

(kcpustat_dyntick_stop). tick_nohz_restart() re-arms the tick at the

next jiffy boundary. That first tick charges a full TICK_NSEC, although

the part of that jiffy before "now" is already in the window.

- The over-count is the wakeup's phase within its jiffy, once per

window. Up to v7.1, /proc/stat read get_cpu_idle_time_us() for online

CPUs and ignored tick-charged idle, so the two never met in one counter.

Quoted 7 lines

- When a governor stops the tick at idle entry instead, the window starts

mid-jiffy. The fragment between the last tick and idle entry is then

never charged, which would roughly offset the end seam on average. That

might be why your guest looks right.

IIRC it seldom stops the tick at idle entry because it needs to wait for one jiffy if this is a not short period.

Quoted 3 lines

I have not verified this on a patched kernel, so please treat it as a lead

only.

Ok it's possible but why then do you reliably observe an excess when I never do?

Quoted 87 lines

3. Measurements, 60 s windows taken today on each node

-------------------------------------------------------

These are the per-CPU cpuN lines of /proc/stat against /proc/uptime's first

field, and .idle_sleeps from /proc/timer_list over the same window.

"sum/wall" is all eight modes divided by uptime x nr_cpus.

node cpus kernel sum/wall excess ms/s/cpu sleeps/s/cpu
ms/sleep

cp-fsn1 8 7.2.5 1.100 100 351 0.285

cp-nbg1-pps 8 7.2.5 1.080 80 268 0.299

cp-nbg1-waa 8 7.2.5 1.072 74 245 0.301

cp-hel1 8 7.2.5 1.081 83 278 0.297

cp-hel1-b 8 7.2.5 1.076 76 255 0.298

worker-fsn1 8 7.2.5 1.063 58 200 0.292

monitoring 4 7.2.5 1.093 95 282 0.338

staging 8 7.1.8 0.985 -14 263 -

- Across nodes the excess tracks the tick-stop rate at about 0.3 ms per

.idle_sleeps event. Within one node it does not: a CPU with twice the

sleeps shows the same excess. .idle_sleeps is incremented on every

__tick_nohz_idle_stop_tick() call, including re-stops after an IRQ inside

an already-stopped idle period. So it overstates the number of windows on

IRQ-heavy CPUs. These guests stop the tick 200-350 times/s per CPU. A

near-idle test guest would show much less.

- /proc/stat idle and /proc/uptime idle still agree to within 0.02 s on

every node, over the same window.

- The seven affected nodes were on older kernels on the same VMs until

19 Sept: five on 7.1.8 and two on 7.0.12. Their daily all-mode sum read

0.979-0.993 of wall clock. Since rebooting into 7.2.5 it reads 1.04-1.10.

4. Corrections to my previous mail

----------------------------------

- Not every node is AMD EPYC-Rome. cp-hel1 reports "Intel Xeon Processor

(Skylake, IBRS, no TSX)" and shows the same excess (1.081), so it is not

vendor-specific. All nodes are the same Hetzner cx43 VM type, except the

4-vCPU one (cx33).

- cp-hel1 is tainted W, from a boot-time "CPA detected W^X violation"

warning in __change_page_attr. The other six are untainted and show the

same excess.

- I wrote that 7.1.8 sums to 0.992-0.997 of the ceiling. Over the last

three days it is 0.983-0.985, so 7.1.8 slightly under-counts rather than

matching wall clock exactly.

Quoted 8 lines

If the cpuidle difference does not let you reproduce it, I will boot

openSUSE's kernel-vanilla (Kernel:HEAD, currently 7.3-rc5, no distro patches)

on a VM of the same type, with 7.2.5 and 7.1.8 on the same VM as controls,

and send the three results.

Yes please! Thanks a lot!

Signature · 2 lines
Frederic Weisbecker
SUSE Labs