Re: [PATCH v6 01/51] x86/apic: Provide helpers to set local APIC timer frequency in hz and khz

David Woodhouse <[email protected]>
Newsgroups dev.linux.lists.linux-coco,dev.linux.lists.virtualization,org.kernel.vger.kvm,org.kernel.vger.linux-hyperv,org.kernel.vger.linux-kernel,org.xenproject.lists.xen-devel
Message-ID <[email protected]>
On Thu, 2026-08-06 at 16:35 -0700, Sean Christopherson wrote:
> Add and use APIs to set the local APIC timer period (given a frequency)
> instead of open coding the subtle HZ math in all external callers, and
> make lapic_timer_period local to apic.c.  Provide APIs to specify the
> frequency in both hertz and kilohertz so that Hyper-V and VMware code
> aren't forced to lose precision.
>
> Opportunistically take the frequency as a u64 to harden against the
> possibility that the frequency (in Khz) is greater than 4294967, i.e. if
> the APIC timer runs at ~4.29 GHz.  As pointed out by Sashiko,
> 4294968 * 1000 == 0x1_000002c0, and thus a Khz period of 4294968 would
> silently overflow the 32-bit unsigned integer used by most callers.
>
> Print out who set the period to maintain equivalent Hyper-V and VMware
> functionality, and in general to make it easier to triage/debug issues.
>
> Cc: Michael Kelley <[email protected]>
> Signed-off-by: Sean Christopherson <[email protected]>

Reviewed-by: David Woodhouse <[email protected]>
smime.p7s (application/pkcs7-signature, 6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.