Skip to contentSkip to conversation

x86: add HPET counter tests

PATCH Superseded Igor Mammedov 1 participant 3 messages Jul 18, 2025 KVM

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover x86: add HPET counter tests

Changelog:
v3:
* fix test running long time due to control thread also running read test and stalling starting other threads
* improve latency accuracy
* increase max number of vcpus to 448
(that's what I had in hands for testing)

previous rev:
'[PATCH v2] x86: add HPET counter read micro benchmark and enable/disable torture tests'
https://www.spinics.net/lists/kvm/msg383777.html

Igor Mammedov (2):
x86: bump number of max cpus to 448
x86: add HPET counter read micro benchmark and enable/disable torture
tests

 lib/x86/smp.h        |  2 +-
 x86/Makefile.common  |  2 +
 x86/hpet_read_test.c | 96 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 x86/hpet_read_test.c
Signature · 1 line
2.47.1
#1 lore raw

PATCH v3 1/2 x86: bump number of max cpus to 448

---
 lib/x86/smp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/x86/smp.h +1 -1
index bbe90daa..0f62cf2e 100644
@@ -1,7 +1,7 @@
 #ifndef _X86_SMP_H_
 #define _X86_SMP_H_
 
-#define MAX_TEST_CPUS (255)
+#define MAX_TEST_CPUS (448)
 
 /*
  * Allocate 12KiB of data for per-CPU usage.  One page for per-CPU data, and
Signature · 1 line
2.47.1
#2 lore raw

PATCH v3 2/2 x86: add HPET counter read micro benchmark and enable/disable torture tests

In reply to Igor Mammedov

test is to be used for benchmarking/validating HPET main counter reading

how to run:
QEMU=/foo/qemu-system-x86_64 x86/run x86/hpet_read_test.flat -smp X
where X is max number of logical CPUs on host

it will 1st execute concurrent read benchmark
and after that it will run torture test enabling/disabling HPET counter, while running readers in parallel. Goal is to verify counter that always goes up.

---
v3:
* measure lat inside threads so that, threads startup time wouldn't throw off results
* fix BSP iterrupting itself by running read test and stalling other cpus as result. (fix it by exiting read test earlier if it's running on BSP)
v2:
* fix broken timer going backwards check
* report # of fails
* warn if number of vcpus is not sufficient for torture test and skip it
* style fixups

---
 x86/Makefile.common  |  2 +
 x86/hpet_read_test.c | 96 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 x86/hpet_read_test.c
x86/Makefile.common +2 -0
index 5663a65d..ef0e09a6 100644
@@ -101,6 +101,8 @@ tests-common += $(TEST_DIR)/realmode.$(exe) \
 realmode_bits := $(if $(call cc-option,-m16,""),16,32)
 endif
 
+tests-common += $(TEST_DIR)/hpet_read_test.$(exe)
+
 test_cases: $(tests-common) $(tests)
 
 $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
x86/hpet_read_test.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.47.1