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 force-pushed the zl/softnpu-mgmt-deadlock branch from b875003 to c12da84 Compare September 5, 2026 15:31

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A clippy find on the falcon feature.

@zeeshanlakhani
zeeshanlakhani force-pushed the zl/softnpu-mgmt-deadlock branch from c12da84 to fb8e165 Compare September 5, 2026 15:32
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