Skip to content

[bug] Avoid holding the pipeline lock across management uart writes - #1206

Open
zeeshanlakhani wants to merge 1 commit into
masterfrom
zl/softnpu-mgmt-deadlock
Open

[bug] Avoid holding the pipeline lock across management uart writes#1206
zeeshanlakhani wants to merge 1 commit into
masterfrom
zl/softnpu-mgmt-deadlock

Conversation

@zeeshanlakhani

@zeeshanlakhani zeeshanlakhani commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

handle_management_message locked the P4 pipeline before dispatching the request. For dump and radix requests, for example, it kept that lock while waiting for the guest to drain the 1-byte UART FIFO.

In turn, if a queue notify message could send a vCPU into the process_guest_packet fn, where it waited on the same lock, that vCPU would not finish its PIO exit. This would lead to the guest not draining the UART, and, boom, deadlock.

The Fix

Now, the dump path copies table state while under the lock and writes it after unlocking happens. Table updates still hold the lock while changing the pipeline. UART writes now have a deadline, where if a response times out partway through, the handler will try to write the missing newline while waiting for the next request.

Note: I ran into this issue on a long-running voxel session. The pre-fix binary reproduces it within minutes under a scadm polling loop, while the fixed one does not (A/B testing).

`handle_management_message` locked the P4 pipeline before dispatching
the request. For dump and radix requests, for example, it kept that lock
while waiting for the guest to drain the 1-byte UART FIFO.

In turn, if a queue notify message could send a vCPU into the
`process_guest_packet` fn, where it waited on the same lock,
that vCPU would not finish its PIO exit. This would lead to the guest
not draining the UART, and, boom, deadlock.

## The Fix

Now, the dump path copies table state while under the lock and writes it
after unlocking happens. Table updates still hold the lock while
changing the pipeline. UART writes now have a deadline, where if a
response times out partway through, the handler will try to write the
missing newline while waiting for the next request.

*Note*: I ran into this issue on a long-running voxel session. The
pre-fix binary reproduces it within minutes under a scadm polling
loop, while the fixed one does not (A/B testing).
@zeeshanlakhani zeeshanlakhani self-assigned this Sep 3, 2026
@zeeshanlakhani
zeeshanlakhani force-pushed the zl/softnpu-mgmt-deadlock branch from 3d694ff to b875003 Compare September 3, 2026 12:45
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.

1 participant