Skip to contentSkip to conversation

mshv_vtl: Add a per-CPU transition statistics ioctl

PATCH New Naman Jain 1 participant 1 message Dec 3

Subsystems (3)
lore
Share & tools
lore

Naman Jain

author
#0 lore raw

PATCH v3 1/1 mshv_vtl: Add a per-CPU transition statistics ioctl

The VTL driver does not expose per-CPU transition counts or timing. This information is important to track number of VTL transitions based on the use-case, debug issues where a VP gets stuck in VTL2 etc. It is needed in production, where debugfs and tracing are not enabled. Add MSHV_GET_VTL_STATS IOCTL so userspace can query them and print this information periodically or on error handling paths. Report switch counts in each direction, the latest timestamps, and total and maximum interval durations. Include the last observed state so userspace can calculate the age of an unfinished interval. These are elapsed times, not exclusive CPU execution times.

Add MSHV_CAP_VTL_STATS so userspace can detect the ioctl. Include a flags field and reserved space so the interface can be extended later.

Use ioctl number 0x46 and capability 0x5 to avoid numbers already used by out-of-tree OpenHCL interfaces.

While at it, remove the unused num_vtl0_transitions counter. Add documentation in a generic VTL interface file. Documentation for existing ioctls is outside the scope of this patch.

---
Changes since v2:
https://lore.kernel.org/all/[email protected]/
Address Sashiko AI review -
- Use per-CPU sequence counters so readers do not block transition updates.
- Cacheline-align the per-CPU statistics with DEFINE_PER_CPU_SHARED_ALIGNED().
- Remove the contention-related EAGAIN error and update the documentation. Other changes:
- Add MSHV_CAP_VTL_STATS so userspace can detect the ioctl.
- Add a flags field and reserved space so the struct can be extended.
- Rename the count and timestamp fields to state the switch direction.

Changes since v1:
https://lore.kernel.org/all/[email protected]/
Address Hardik's review comments -
- Rename the per-CPU variable to mshv_vtl_cpu_stats.
- Change the ioctl number from 0x41 to 0x46 to avoid existing OpenHCL allocations, and explain the choice in the commit message.

 Documentation/virt/hyperv/index.rst    |   1 +
 Documentation/virt/hyperv/mshv-vtl.rst | 106 +++++++++++++++++++++++++
 drivers/hv/mshv_vtl_main.c             |  77 +++++++++++++++++-
 include/uapi/linux/mshv.h              |  43 ++++++++++
 4 files changed, 225 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/virt/hyperv/mshv-vtl.rst
Documentation/virt/hyperv/index.rst +1 -0
index c84c40fd61c91..9fcff8c0f7db8 100644
@@ -13,3 +13,4 @@ Hyper-V Enlightenments
    vpci
    hibernation
    coco
+   mshv-vtl
Documentation/virt/hyperv/mshv-vtl.rst new file +106 -0

106 lines not on this page · raw message

drivers/hv/mshv_vtl_main.c +75 -2

126 lines not on this page · raw message

include/uapi/linux/mshv.h +43 -0

61 lines not on this page · raw message

base-commit: 799dd936553182df5770dde7f38d94c8337df75a

Signature · 1 line
2.43.0