vfio/pci: Log/indicate devices being bound & unbound.
Subsystems (2)
PATCH 1/1 vfio/pci: Log/indicate devices being bound & unbound.
Most of my thinking/motivation for this is in the patch notes. The change itself is straightforward, we would like to have some record of when a device is bound or unbound in order to trace back to the time when it happened.
Example from dmesg on 6.6.1 kernel:
[ 9.935877] vfio-pci 0000:63:00.0: binding to vfio control [ 9.936890] vfio-pci 0000:e1:00.0: binding to vfio control [ 9.937616] vfio-pci 0000:63:00.1: binding to vfio control [ 9.938201] vfio-pci 0000:e1:00.1: binding to vfio control
Matthew W Carlis (1):
vfio/pci: Log/indicate devices being bound & unbound.
drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)
base-commit: ceb6a6f023fd3e8b07761ed900352ef574010bcb
Signature · 1 line
2.17.1
PATCH 1/1 vfio/pci: Log/indicate devices being bound & unbound.
We often would like to know when a device is unbound or bound to vfio. Since I have a belief that such events should be infrequent & in low volume; after this change the driver will log when it decides to bind and unbind a device.
vfio-pci doesn't log when it binds to a device or is unbound from a device. There may be logging from vfio when a device is opened or closed by some user process which is good, but even when the device is never opened vfio may have taken some action as a result of binding. One such example might be putting it into D3 low power state.
Additionally, the lifecycle of some applications that use vfio-pci may be infrequent or defered for a significant time. We have found that some third party tools or perhaps ignorant super-users may choose to bind or unbind devices with a fairly inexplicit policy leaving applictions that might have wanted to use a device confused about its absence from vfio.
--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/vfio/pci/vfio_pci_core.c +4 -0
@@ -2265,6 +2265,8 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) ret =vfio_register_group_dev (&vdev->vdev);if (ret) goto out_power; + +pci_info (pdev,"binding to vfio control\n" );return 0 ; out_power:
@@ -2291,6 +2293,8 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev)pm_runtime_get_noresume (&vdev->pdev->dev);pm_runtime_forbid (&vdev->pdev->dev); + +pci_info (vdev->pdev,"unbinding from vfio control\n" ); }EXPORT_SYMBOL_GPL (vfio_pci_core_unregister_device);
Signature · 1 line
2.17.1
Quoted 38 lines · On Sat, 23 Dec 2023 15:16:12 -0700 Matthew W Carlis <[email protected]>…
We often would like to know when a device is unbound or bound to vfio. Since I have a belief that such events should be infrequent & in low volume; after this change the driver will log when it decides to bind and unbind a device.
vfio-pci doesn't log when it binds to a device or is unbound from a device. There may be logging from vfio when a device is opened or closed by some user process which is good, but even when the device is never opened vfio may have taken some action as a result of binding. One such example might be putting it into D3 low power state.
Additionally, the lifecycle of some applications that use vfio-pci may be infrequent or defered for a significant time. We have found that some third party tools or perhaps ignorant super-users may choose to bind or unbind devices with a fairly inexplicit policy leaving applictions that might have wanted to use a device confused about its absence from vfio.
Signed-off-by Matthew W Carlis <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci_core.c +2
-0@@ -2265,6 +2265,8 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) ret =vfio_register_group_dev (&vdev->vdev);if (ret) goto out_power; + +pci_info (pdev,"binding to vfio control\n" );return 0 ; out_power:
drivers/vfio/pci/vfio_pci_core.c void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev) · line 2299
Quoted 7 lines
drivers/vfio/pci/vfio_pci_core.c +2
-0@@ -2291,6 +2293,8 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev)pm_runtime_get_noresume (&vdev->pdev->dev);pm_runtime_forbid (&vdev->pdev->dev); + +pci_info (vdev->pdev,"unbinding from vfio control\n" ); }EXPORT_SYMBOL_GPL (vfio_pci_core_unregister_device);
Parsing dmesg is a poor means to track driver bindings. There are already udev events, why aren't those sufficient? They're certainly more generic. Thanks,
Alex
PATCH 1/1 vfio/pci: Log/indicate devices being bound & unbound.
In my case I was interested in something that would allow a human to triage it after the fact and potentially many reboots later. In our use cases we assume the correct things will have been bound & its really the exception when they haven't been, but stil it was desireable information. In one sense it was just easier to add the logging to the kernel than it would be to get from udev. I think the kernel log must also be a more familiar source to most than udev.