Skip to content

KVM: selftests: Test steal-time dirty logging and RISC-V STA transitions

Bingyu Xian kvm kvm-riscv linux-kselftest linux-riscv lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 0 repliesNew

Changes in v2 from the cover letter

- Split the get_run_delay() error-handling fix into a prerequisite patch.
- Move the steal-time accounting dirty-log check into the common per-vCPU test path and drop the added #ifdefs from main(). (Andrew Jones)
- Separate RISC-V SBI STA disable, re-enable of the same area, and direct replacement of an active registration; clarify that the selftest invokes SBI directly rather than running Linux CPU hotplug. (Andrew Jones)
- Drop the MADV_DONTNEED check, which discarded guest page contents rather than modeling migration. (Andrew Jones)
- Clear initialization and transition dirty bits before each accounting check so registration writes cannot mask missing accounting dirty marks.
- Force bounded runnable CPU contention instead of assuming every KVM_RUN advances the sequence counter when run_delay is unchanged.
- Size the RISC-V two-page region using the host page size for 16K/64K host page compatibility, and fix Author/Signed-off-by formatting.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: selftests: Fail explicitly when schedstat cannot be readtools/testing/selftests/kvm/lib/test_util.c+4 -30 replies
2/2KVM: selftests: Test steal-time dirty logging and RISC-V STA transitionstools/testing/selftests/kvm/steal_time.c+206 -270 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] KVM: selftests: Test steal-time dirty logging and RISC-V STA transitions

This series extends the KVM steal_time selftest to cover guest RAM dirty-log tracking for steal-time accounting writes across architectures, and exercises RISC-V SBI STA shared-memory state transitions.

Patch 1 fixes get_run_delay() so that missing or malformed schedstat files fail explicitly instead of dereferencing a null stream or returning a fabricated constant that causes polling loops to spin indefinitely.

Patch 2 enables dirty logging on the shared-area memslot in the common per-vCPU test path, clears initialization dirty bits before checking accounting writes, removes the v1 #ifdefs from main(), and tests three RISC-V SBI STA transitions: disabling an active area, re-enabling the same area (matching the SBI calls used by Linux RISC-V guest CPU hotplug callbacks), and replacing an active registration directly with a new area at the end of a second host page.

Changes in v2:
- Split the get_run_delay() error-handling fix into a prerequisite patch.
- Move the steal-time accounting dirty-log check into the common per-vCPU test path and drop the added #ifdefs from main(). (Andrew Jones)
- Separate RISC-V SBI STA disable, re-enable of the same area, and direct replacement of an active registration; clarify that the selftest invokes SBI directly rather than running Linux CPU hotplug. (Andrew Jones)
- Drop the MADV_DONTNEED check, which discarded guest page contents rather than modeling migration. (Andrew Jones)
- Clear initialization and transition dirty bits before each accounting check so registration writes cannot mask missing accounting dirty marks.
- Force bounded runnable CPU contention instead of assuming every KVM_RUN advances the sequence counter when run_delay is unchanged.
- Size the RISC-V two-page region using the host page size for 16K/64K host page compatibility, and fix Author/Signed-off-by formatting.

v1: https://lore.kernel.org/r/[email protected]/

Validation:
- RISC-V (QEMU TCG + H-ext L1 KVM): all 11 steal_time cases pass; local controls confirm compatibility with skipping zero-increment STA updates and immediate detection when the accounting dirty mark is omitted.
- Separate local 2-vCPU RISC-V Linux L2 guest run under L1 KVM confirms SBI STA detection and 3 CPU offline/online rounds invoking pv_time_cpu_down_prepare() and pv_time_cpu_online().
- x86_64 (host KVM): all 8 steal_time cases pass, plus fault-injection checks for missing and malformed schedstat files.

Note: AI tooling assisted with review analysis, test rework, and local verification; all changes were reviewed and validated by the authors.

Thanks,
Bingyu

Bingyu Xian (2):
KVM: selftests: Fail explicitly when schedstat cannot be read
KVM: selftests: Test steal-time dirty logging and RISC-V STA
transitions

 tools/testing/selftests/kvm/lib/test_util.c |   7 +-
 tools/testing/selftests/kvm/steal_time.c    | 233 +++++++++++++++++---
 2 files changed, 210 insertions(+), 30 deletions(-)

base-commit: 23c62304dde29abe92013d85910d03a77dada35d

Signature · 1 line
2.34.1