Skip to content

Implement Drop for vfio_sys Device, unmapping msix for interrupts. #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Implement Drop for vfio_sys Device, unmapping msix for interrupts. #79

wants to merge 2 commits into from

Conversation

erfrimod
Copy link
Contributor

@erfrimod erfrimod commented Oct 14, 2024

GDMA Driver allocates the HWC device interrupt in the new() method. However, there are multiple potential error paths that can result in retries. Any failure in new() causes the interrupt to leak, resulting in the HWC interrupt not getting unmapped. GDMA::New() can then fail on retry due to missing first response as a result of the leaked interrupt.

Log messages from a lab machine where I force a panic, causing calls to drop() -> map_msix()

[10.065737] mana_driver::gdma_driver:  INFO worker_new{ name="UnderhillWorker" action="new"}:init:init/new_underhill_vm:new_mana_device:  Created HWC with eq id: 0, msix: 0
[10.065969] mana_driver::gdma_driver:  INFO worker_new{ name="UnderhillWorker" action="new"}:init:init/new_underhill_vm:new_mana_device:  Max VF resources: GdmaQueryMaxResourcesResp { status: 0, max_sq: 15360, max_rq: 15360, max_cq: 15360, max_eq: 960, max_db: 4096, max_mst: 57344, max_cq_mod_ctx: 4, max_mod_cq: 32, max_msix: 6 }
[10.070091] vfio_sys:  INFO worker_new{ name="UnderhillWorker" action="new"}:init:init/new_underhill_vm:new_mana_device:  Dropping vfio_sys::Device
[10.070174] vfio_sys:  INFO worker_new{ name="UnderhillWorker" action="new"}:init:init/new_underhill_vm:new_mana_device:  vfio_sys::map_msix header.count 0 VFIO_IRQ_SET_DATA_NONE
[10.147768] underhill_core::emuplat::netvsp: ERROR worker_new{ name="UnderhillWorker" action="new"}:init:init/new_underhill_vm:  failed to create mana device pci_id="af87:00:00.0" reset_method=NoReset err=failed to initialize mana device: injecting fake HW failure on 18 attempt

In FHR scenarios, the GDMA::new() can fail due to missing the first response as a result of a leaked interrupt.

Log messages from a lab machine where I perform UH servicing (FHR)

[71955.164522] state_unit: INFO servicing_save_vtl2{ correlation_id=4d9f7e7f-158c-46e4-b3a6-2445e35cc9dc}:save_units:state_change{ operation="save"}:  state change complete duration=16.971171ms
[71955.166572] vfio_sys: INFO  Dropping vfio_sys::Device
[71955.166632] vfio_sys: INFO  vfio_sys::map_msix header.count 0 VFIO_IRQ_SET_DATA_NONE

@erfrimod erfrimod requested review from a team as code owners October 14, 2024 22:42
@OneBlue OneBlue requested a review from a team October 14, 2024 22:42
@jstarks jstarks changed the title Implement Drop for vfrio_sys Device, unmapping msix for interrupts. Implement Drop for vfio_sys Device, unmapping msix for interrupts. Oct 15, 2024
@jstarks
Copy link
Member

jstarks commented Oct 15, 2024

It looks to me like Linux should already do this when the device is closed. Are we leaking the device fd somehow?

@erfrimod
Copy link
Contributor Author

erfrimod commented Oct 15, 2024

Are we leaking the device fd somehow?

I don't believe the fd gets leaked. But without this Drop implementation, there is no code to tell the VFIO device 'unmap_interrupt' / VFIO_IRQ_SET_DATA_NONE.

@jstarks
Copy link
Member

jstarks commented Oct 15, 2024

When the fd gets closed, the kernel does VFIO_IRQ_SET_DATA_NONE internally.

@jimdaubert-ms
Copy link
Contributor

jimdaubert-ms commented Oct 25, 2024

The failure occurs in the retry case. There is logic to perform an FLR and try again to create a hardware channel if the first try was not successful (for example if initial commands time out). Are we not closing the fd before the retry case and thus necessitating this interrupt unmapping?

@benhillis
Copy link
Member

@erfrimod - what's the status of this change?

@erfrimod
Copy link
Contributor Author

We still observed a problem with the retry even with these changes. Back to the drawing bord.

@erfrimod erfrimod closed this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants