From: Alexander Graf <graf@amazon.com>
To: <x86@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
"Clemens Ladisch" <clemens@ladisch.de>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Borislav Petkov" <bp@alien8.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
nh-open-source@amazon.com,
"Nicolas Saenz Julienne" <nsaenz@amazon.es>,
"Hendrik Borghorst" <hborghor@amazon.de>,
"Filippo Sironi" <sironi@amazon.de>,
"David Woodhouse" <dwmw@amazon.co.uk>,
"Jan Schönherr" <jschoenh@amazon.de>
Subject: [PATCH 0/2] Add HPET NMI Watchdog support
Date: Mon, 2 Feb 2026 17:48:01 +0000 [thread overview]
Message-ID: <20260202174803.66640-1-graf@amazon.com> (raw)
The current NMI watchdog relies on performance counters and consistently
occupies one on each CPU. When running virtual machines, we want to pass
performance counters to virtual machines so they can make use of them.
In addition the host system wants to use performance counters to check
the system to identify when anything looks abnormal, such as split
locks.
That makes PMCs a precious resource. So any PMC we can free up is a PMC
we can use for something useful. That made me look at the NMI watchdog.
The PMC based NMI watchdog implementation does not actually need any
performance counting. It just needs a per-CPU NMI timer source. X86
systems can make anything that emits an interrupt descriptor (IOAPIC,
MSI(-X), etc) become an NMI source. So any time goes. Including the
HPET. And while they can't really operate per-CPU, in almost all cases
you only really want the NMI on *all* CPUs, rather than per-CPU.
So I took a stab at building an HPET based NMI watchdog. In my (QEMU
based) testing, it's fully functional and can successfully detect when
CPUs get stuck. It even survives suspend/resume cycles.
For now, its enablement is a config time option because the hardlockup
framework does not support dynamic switching of multiple detectors.
That's ok for our use case. But maybe something for the interested
reader to tackle eventually :).
You can enable the HPET watchdog by default by setting
CONFIG_HARDLOCKUP_DETECTOR_HPET_DEFAULT=y
or passing "hpet=watchdog" to the kernel command line. When active, it
will emit a kernel log message to indicate it works:
[ 0.179176] hpet: HPET watchdog initialized on timer 0, GSI 2
The HPET can only be in either watchdog or generic mode. I am a bit
worried about IO-APIC pin allocation logic, so I opted to reuse the
generic timer pin. And that means I'm effectively breaking the normal
interrupt delivery path. so the easy way out was to say when watchdog is
active, PIT and HPET are not available as timer sources. Which is ok on
modern systems. There are way too many (unreliable) timer sources on x86
already. Trimming a few surely won't hurt.
I'm open to inputs on how to make the HPET multi-purpose though, in case
anyone feels strongly about it.
Alex
Alexander Graf (2):
x86/ioapic: Add NMI delivery configuration helper
hpet: Add HPET-based NMI watchdog support
.../admin-guide/kernel-parameters.txt | 5 +-
arch/x86/Kconfig | 19 ++
arch/x86/include/asm/io_apic.h | 2 +
arch/x86/kernel/apic/io_apic.c | 32 ++++
arch/x86/kernel/hpet.c | 172 ++++++++++++++++++
arch/x86/kernel/i8253.c | 9 +
drivers/char/hpet.c | 3 +
include/linux/hpet.h | 14 ++
8 files changed, 255 insertions(+), 1 deletion(-)
--
2.47.1
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
next reply other threads:[~2026-02-02 17:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 17:48 Alexander Graf [this message]
2026-02-02 17:48 ` [PATCH 1/2] x86/ioapic: Add NMI delivery configuration helper Alexander Graf
2026-02-03 10:08 ` Thomas Gleixner
2026-02-03 10:44 ` Alexander Graf
2026-02-03 10:45 ` David Woodhouse
2026-02-02 17:48 ` [PATCH 2/2] hpet: Add HPET-based NMI watchdog support Alexander Graf
2026-02-03 10:32 ` Thomas Gleixner
2026-02-03 12:36 ` Alexander Graf
2026-02-03 15:28 ` Thomas Gleixner
2026-02-03 19:44 ` Ricardo Neri
2026-02-03 20:49 ` Thomas Gleixner
2026-02-04 5:05 ` Ricardo Neri
2026-02-03 16:24 ` Sasha Levin
2026-02-03 17:19 ` Alexander Graf
2026-02-03 17:43 ` David Woodhouse
2026-02-03 20:46 ` Thomas Gleixner
2026-02-03 23:13 ` David Woodhouse
2026-02-04 10:34 ` Thomas Gleixner
-- strict thread matches above, loose matches on Subject: below --
2026-02-02 17:43 [PATCH 0/2] Add HPET NMI Watchdog support Alexander Graf
2026-02-02 17:49 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260202174803.66640-1-graf@amazon.com \
--to=graf@amazon.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=clemens@ladisch.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hborghor@amazon.de \
--cc=jschoenh@amazon.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=nsaenz@amazon.es \
--cc=pasha.tatashin@soleen.com \
--cc=pbonzini@redhat.com \
--cc=sironi@amazon.de \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox