Detect stalls on guest vCPUS
Subsystems (2)
v6 cover Detect stalls on guest vCPUS
This adds a mechanism to detect stalls on the guest vCPUS by creating a per CPU hrtimer which periodically 'pets' the host backend driver. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular /dev/watchdogN node. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU basis.
This device driver acts as a soft lockup detector by relying on the host backend driver to measure the elapesed time between subsequent 'pet' events. If the elapsed time doesn't match an expected value, the backend driver decides that the guest vCPU is locked and resets the guest. The host backend driver takes into account the time that the guest is not running. The communication with the backend driver is done through MMIO and the register layout of the virtual watchdog is described as part of the backend driver changes.
The host backend driver is implemented as part of:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817
Changelog v6:
- fix issues reported by lkp@intel robot
Changelog v5:
- fix dt warnings
- rename %s/watchdog/stall_detector/g
- rename the config from Kconfig VM_WATCHDOG -> VCPU_STALL_DETECTOR
Changelog v4:
- rename the source from vm-wdt.c -> vm-watchdog.c
- convert all the error logging calls from pr_* to dev_* calls
- rename the DTS node "clock" to "clock-frequency"
Changelog v3:
- cosmetic fixes, remove pr_info and version information
- improve description in the commit messag
- improve description in the Kconfig help section
Sebastian Ene (2):
dt-bindings: vcpu_stall_detector: Add qemu,vcpu-stall-detector
compatible
misc: Add a mechanism to detect stalls on guest vCPUs
.../bindings/misc/vcpu_stall_detector.yaml | 49 ++++ drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/vcpu_stall_detector.c | 222 ++++++++++++++++++ 4 files changed, 284 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml create mode 100644 drivers/misc/vcpu_stall_detector.c
Signature · 1 line
2.36.1.476.g0c4daa206d-goog
PATCH v6 1/2 dt-bindings: vcpu_stall_detector: Add qemu,vcpu-stall-detector compatible
The VCPU stall detection mechanism allows to configure the expiration duration and the internal counter clock frequency measured in Hz. Add these properties in the schema.
While this is a memory mapped virtual device, it is expected to be loaded when the DT contains the compatible: "qemu,vcpu-stall-detector" node. In a protected VM we trust the generated DT nodes and we don't rely on the host to present the hardware peripherals.
--- .../bindings/misc/vcpu_stall_detector.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +49 -0
@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/vcpu_stall_detector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: VCPU stall detector + +description: | + This binding describes a CPU stall detector mechanism for virtual cpus + which is accessed through MMIO. + +maintainers: + - Sebastian Ene <[email protected]> + +properties: + compatible: + enum: + - qemu,vcpu-stall-detector + + clock-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The internal clock of the stall detector peripheral measure in Hz used + to decrement its internal counter register on each tick. + Defaults to 10 if unset. + + timeout-sec: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The stall detector expiration timeout measured in seconds. + Defaults to 8 if unset. Please note that it also takes into account the + time spent while the VCPU is not running. + +required: + - compatible + +additionalProperties: false + +examples: + - | + vmwdt@9030000 { + compatible = "qemu,vcpu-stall-detector"; + clock-frequency = <10>; + timeout-sec = <8>; + reg = <0x0 0x9030000 0x0 0x10000>; + }; + +...
Signature · 1 line
2.36.1.476.g0c4daa206d-goog
Rob Herring
maintainerRe: [PATCH v6 1/2] dt-bindings: vcpu_stall_detector: Add qemu,vcpu-stall-detector compatible
Quoted 9 lines · Sebastian Ene
The VCPU stall detection mechanism allows to configure the expiration duration and the internal counter clock frequency measured in Hz. Add these properties in the schema.
While this is a memory mapped virtual device, it is expected to be loaded when the DT contains the compatible: "qemu,vcpu-stall-detector" node. In a protected VM we trust the generated DT nodes and we don't rely on the host to present the hardware peripherals.
Quoted 6 lines
Signed-off-by Sebastian Ene <[email protected]>--- .../bindings/misc/vcpu_stall_detector.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml: properties:timeout-sec: '$ref' should not be valid under {'const': '$ref'}
hint: Standard unit suffix properties don't need a type $ref
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml: ignoring, error in schema: properties: timeout-sec Documentation/devicetree/bindings/misc/vcpu_stall_detector.example.dtb:0:0: /example-0/vmwdt@9030000: failed to match any schema with compatible: ['qemu,vcpu-stall-detector']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Rob Herring
maintainerRe: [PATCH v6 1/2] dt-bindings: vcpu_stall_detector: Add qemu,vcpu-stall-detector compatible
In reply to Sebastian EneQuoted 4 lines · Sebastian Ene
The VCPU stall detection mechanism allows to configure the expiration duration and the internal counter clock frequency measured in Hz. Add these properties in the schema.
Quoted 8 lines
While this is a memory mapped virtual device, it is expected to be loaded when the DT contains the compatible: "qemu,vcpu-stall-detector" node. In a protected VM we trust the generated DT nodes and we don't rely on the host to present the hardware peripherals.
Signed-off-by Sebastian Ene <[email protected]>--- .../bindings/misc/vcpu_stall_detector.yaml | 49 +++++++++++++++++++
qemu,vcpu-stall-detector.yaml
Quoted 9 lines
1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/vcpu_stall_detector.yamlDocumentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +0
-0
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml line 9
Quoted 9 lines
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +9
-0@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/vcpu_stall_detector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: VCPU stall detector + +description: |
Don't need '|' if no formatting.
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml line 10
Quoted 1 line
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +1
-0+ This binding describes a CPU stall detector mechanism for virtual cpus
s/cpus/CPUs/
Quoted 6 lines
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +6
-0+ which is accessed through MMIO. + +maintainers: + - Sebastian Ene <[email protected]> + +properties:
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml line 26
Quoted 10 lines
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +10
-0+ compatible: + enum: + - qemu,vcpu-stall-detector + + clock-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The internal clock of the stall detector peripheral measure in Hz used + to decrement its internal counter register on each tick. + Defaults to 10 if unset.
default: 10
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml line 33
Quoted 7 lines
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +7
-0+ + timeout-sec: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The stall detector expiration timeout measured in seconds. + Defaults to 8 if unset. Please note that it also takes into account the + time spent while the VCPU is not running.
default: 8
Quoted 20 lines
Documentation/devicetree/bindings/misc/vcpu_stall_detector.yaml new file +16
-0+ +required: + - compatible + +additionalProperties: false + +examples: + - | + vmwdt@9030000 { + compatible = "qemu,vcpu-stall-detector"; + clock-frequency = <10>; + timeout-sec = <8>; + reg = <0x0 0x9030000 0x0 0x10000>; + }; + +...Signature · 1 line
2.36.1.476.g0c4daa206d-goog
PATCH v6 2/2 misc: Add a mechanism to detect stalls on guest vCPUs
In reply to Sebastian EneThis driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular /dev/watchdogN node. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.
This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the /proc/{}/task/{}/stat entries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817
--- drivers/misc/Kconfig | 12 ++ drivers/misc/Makefile | 1 + drivers/misc/vcpu_stall_detector.c | 222 +++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 drivers/misc/vcpu_stall_detector.c
drivers/misc/Kconfig +12 -0
@@ -483,6 +483,18 @@ config OPEN_DICE If unsure, say N. +config VCPU_STALL_DETECTOR + tristate "VCPU stall detector" + select LOCKUP_DETECTOR + help + Detect CPU locks on the virtual machine. This driver relies on the + hrtimers which are CPU-binded to do the 'pet' operation. When a vCPU + has to do a 'pet', it exits the guest through MMIO write and the + backend driver takes into account the lost ticks for this particular + CPU. + To compile this driver as a module, choose M here: the + module will be called vcpu_stall_detector. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -60,3 +60,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o obj-$(CONFIG_OPEN_DICE) += open-dice.o +obj-$(CONFIG_VCPU_STALL_DETECTOR) += vcpu_stall_detector.o
drivers/misc/vcpu_stall_detector.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
2.36.1.476.g0c4daa206d-goog
Greg Kroah-Hartman
maintainerRe: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Quoted 6 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.
Quoted 8 lines
This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817Reported-by kernel test robot <[email protected]>
The robot reported stalls on vcpus?
I think you need to fix this up...
greg k-h
Re: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817
Quoted 4 lines
Quoted 1 line
Reported-by kernel test robot <[email protected]>The robot reported stalls on vcpus?
I have seen this a number of times when people fix issues reported by the robot in their submissions, just because the robot asks them to do so. This should really be part of the change log, such as
v17: Fixed the following issues issues reported by the kernel test robot:
...
Guenter
Re: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Quoted 15 lines · Guenter Roeck
Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Reported-by kernel test robot <[email protected]>The robot reported stalls on vcpus?
Hi,
Quoted 8 lines
I have seen this a number of times when people fix issues reported by the robot in their submissions, just because the robot asks them to do so. This should really be part of the change log, such as
v17: Fixed the following issues issues reported by the kernel test robot:
...
I will add this in the changelog for v7.
Quoted 1 line
Guenter
Thanks,
Seb
Re: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
In reply to Greg Kroah-HartmanQuoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.
Quoted 9 lines
Quoted 8 lines
This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817Reported-by kernel test robot <[email protected]>
Hi,
Quoted 3 lines
The robot reported stalls on vcpus?
I think you need to fix this up...
The robot reported some issues on v5 and after fixing them it recommended to add this tag.
Quoted 2 lines
greg k-h
Thanks,
Seb
Re: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Quoted 18 lines · Sebastian Ene
Quoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.Quoted 9 lines
Quoted 8 lines
This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817Reported-by kernel test robot <[email protected]>
Quoted 9 lines
Hi,
Quoted 3 lines
The robot reported stalls on vcpus?
I think you need to fix this up...
The robot reported some issues on v5 and after fixing them it recommended to add this tag.
Only that doesn't make sense for patch sets which are still being worked on. If you want to credit the robot, mention it in the change log.
Guenter
Greg Kroah-Hartman
maintainerRe: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
In reply to Sebastian EneQuoted 29 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817Reported-by kernel test robot <[email protected]>Signed-off-by Sebastian Ene <[email protected]>--- drivers/misc/Kconfig | 12 ++ drivers/misc/Makefile | 1 + drivers/misc/vcpu_stall_detector.c | 222 +++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 drivers/misc/vcpu_stall_detector.cdrivers/misc/Kconfig +0
-0@@ -483,6 +483,18 @@ config OPEN_DICE If unsure, say N.
drivers/misc/Kconfig config OPEN_DICE · line 494
Quoted 10 lines
drivers/misc/Kconfig +9
-0+config VCPU_STALL_DETECTOR + tristate "VCPU stall detector" + select LOCKUP_DETECTOR + help + Detect CPU locks on the virtual machine. This driver relies on the + hrtimers which are CPU-binded to do the 'pet' operation. When a vCPU + has to do a 'pet', it exits the guest through MMIO write and the + backend driver takes into account the lost ticks for this particular + CPU.
which virtual machine framework is this for? kvm? xen? hyperv? vmware? something else?
Specifics please...
thanks,
greg k-h
Re: [PATCH v6 2/2] misc: Add a mechanism to detect stalls on guest vCPUs
Quoted 31 lines · Greg Kroah-Hartman
Quoted 30 lines · Sebastian Ene
This driver creates per-cpu hrtimers which are required to do the periodic 'pet' operation. On a conventional watchdog-core driver, the userspace is responsible for delivering the 'pet' events by writing to the particular
/dev/watchdogNnode. In this case we require a strong thread affinity to be able to account for lost time on a per vCPU.This part of the driver is the 'frontend' which is reponsible for delivering the periodic 'pet' events, configuring the virtual peripheral and listening for cpu hotplug events. The other part of the driver handles the peripheral emulation and this part accounts for lost time by looking at the
/proc/{}/task/{}/statentries and is located here:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548817Reported-by kernel test robot <[email protected]>Signed-off-by Sebastian Ene <[email protected]>--- drivers/misc/Kconfig | 12 ++ drivers/misc/Makefile | 1 + drivers/misc/vcpu_stall_detector.c | 222 +++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 drivers/misc/vcpu_stall_detector.cdrivers/misc/Kconfig +0
-0@@ -483,6 +483,18 @@ config OPEN_DICE If unsure, say N.
Quoted 9 lines
drivers/misc/Kconfig config OPEN_DICE · line 494
Quoted 9 lines
drivers/misc/Kconfig +9
-0+config VCPU_STALL_DETECTOR + tristate "VCPU stall detector" + select LOCKUP_DETECTOR + help + Detect CPU locks on the virtual machine. This driver relies on the + hrtimers which are CPU-binded to do the 'pet' operation. When a vCPU + has to do a 'pet', it exits the guest through MMIO write and the + backend driver takes into account the lost ticks for this particular + CPU.
Hi,
Quoted 7 lines
which virtual machine framework is this for? kvm? xen? hyperv? vmware? something else?
Specifics please...
thanks,
I will improve my description, thanks for taking a look.
Quoted 2 lines
greg k-h
Seb