|WARNING| [v2] net/iavf: fix reset race condition
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Mon Sep 28 12:32:14 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/170090
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-28
# DPDK Patch Review: net/iavf: fix reset race condition
## Errors
### 1. Incorrect spacing in atomic type declaration
**File:** `drivers/net/intel/iavf/iavf.h:298`
```c
RTE_ATOMIC(bool)in_reset_recovery;
```
Missing space between `RTE_ATOMIC(bool)` and `in_reset_recovery`.
Should be:
```c
RTE_ATOMIC(bool) in_reset_recovery;
```
### 2. Potential race condition: non-atomic access to `pf_reset_in_progress`
**File:** `drivers/net/intel/iavf/iavf_ethdev.c:3534`
The `pf_reset_in_progress` field is set to `false` on line 3534, then `in_reset_recovery` is released on line 3535. However, `pf_reset_in_progress` is also read in `iavf_set_no_poll()` (line 3651) without atomic protection. If `pf_reset_in_progress` is shared state accessed from multiple threads, it should also use atomic operations.
Current code:
```c
vf->pf_reset_in_progress = false;
rte_atomic_store_explicit(&vf->in_reset_recovery, false, rte_memory_order_release);
```
If `pf_reset_in_progress` is accessed from the no_poll path or event handlers, this is a data race.
**Action required:** Convert `pf_reset_in_progress` to `RTE_ATOMIC(bool)` and use atomic loads/stores, or document why non-atomic access is safe here.
---
## Warnings
### 1. Missing release notes update
The patch fixes a race condition but does not include a release notes entry. Fixes for correctness bugs (especially race conditions affecting concurrent operation) should be documented in the release notes.
**Suggested addition to `doc/guides/rel_notes/release_25_11.rst`:**
```rst
* **Fixed race condition in iavf VF reset handling.**
Fixed a race condition where concurrent reset requests (PF-initiated and
VF-initiated) could execute simultaneously without synchronization. The
``in_reset_recovery`` flag is now atomic and serves as a guard to serialize
reset operations.
```
### 2. Inconsistent memory ordering for `in_reset_recovery` loads
**Context:** Most loads of `in_reset_recovery` use `rte_memory_order_relaxed`, but one critical path uses `rte_memory_order_acquire`:
- Line 3476 (early return if reset already in progress): **acquire** (correct - needs to synchronize with release store)
- Line 3734 (`iavf_resume_pending_start`): **acquire** (correct - synchronizes with release)
- Lines 770, 3087, 3335, 1109, 263: **relaxed**
The relaxed loads are safe **if** they occur in contexts where the thread already holds the lock or is the owner of `in_reset_recovery`. However, this is subtle. Consider whether all relaxed loads are indeed safe, or if some should be acquire to guarantee visibility of the release store.
For example, in `iavf_dev_configure()` (line 770), the check `!vf->in_reset_recovery` decides whether to call `iavf_post_reset_reconfig()`. If this read is stale (relaxed allows reordering), the thread might see `in_reset_recovery == false` before the releasing thread has completed cleanup, potentially causing a double restore.
**Recommendation:** Add a comment documenting why each relaxed load is correct, or upgrade questionable ones to acquire.
---
## Info
### 1. Compare-exchange failure path
When the compare-exchange fails (another thread is already performing reset), the function logs `INFO` and returns `-EBUSY`. This is reasonable, but consider:
- Is the caller prepared to handle `-EBUSY`? For `rte_pmd_iavf_reinit()`, the return value is propagated to the application.
- For the event handler path (`iavf_handle_hw_reset` called from `INTR_RESET` event), the return value is now checked but previously was void. Verify that callers (event loop) handle errors correctly.
This is not an error, but worth confirming in testing.
---
## Summary
**Critical issues (must fix):**
1. Spacing in `RTE_ATOMIC(bool)in_reset_recovery;` declaration
2. Potential race on `pf_reset_in_progress` if accessed from multiple threads
**Recommended (should fix):**
1. Add release notes entry for this race condition fix
2. Review and document memory ordering for all `in_reset_recovery` loads
The patch correctly addresses the primary race condition (concurrent reset execution) by making `in_reset_recovery` atomic and using compare-exchange as a guard. The memory ordering on the CAS and release store is appropriate. The main concerns are the non-atomic `pf_reset_in_progress` and ensuring all relaxed loads are safe in their contexts.
More information about the test-report
mailing list