From: Stephen Hemminger <stephen@networkplumber.org>
To: Dimon Zhao <dimon.zhao@nebula-matrix.com>
Cc: dev@dpdk.org, stable@dpdk.org,
Kyo Liu <kyo.liu@nebula-matrix.com>,
Leon Yu <leon.yu@nebula-matrix.com>,
Sam Chen <sam.chen@nebula-matrix.com>
Subject: Re: [PATCH v1 1/1] net/nbl: fix hardware stats interrupt nesting issue
Date: Wed, 14 Jan 2026 09:23:01 -0800 [thread overview]
Message-ID: <20260114092301.62d942c8@phoenix.local> (raw)
In-Reply-To: <20260114081558.50370-2-dimon.zhao@nebula-matrix.com>
On Wed, 14 Jan 2026 00:15:58 -0800
Dimon Zhao <dimon.zhao@nebula-matrix.com> wrote:
> The timer interrupt handler periodically queries and updates
> hw_stats via mailbox.
> Since mailbox operations rely on interrupts for packet reception,
> this causes interrupt nesting.
> To resolve this, trigger a task from the interrupt handler and
> start a dedicated thread to execute this task,
> eliminating the nested interrupt scenario.
>
> Fixes: c9726a719ca1 ("net/nbl: support dropped packets counter")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dimon Zhao <dimon.zhao@nebula-matrix.com>
> ---
Automated patch review has some good observations, please address
these and resubmit.
## Patch Review: net/nbl: fix hardware stats interrupt nesting issue
### Commit Message Analysis
| Criterion | Status | Notes |
|-----------|--------|-------|
| Subject ≤60 chars | ✓ PASS | 51 characters |
| Lowercase after colon | ✓ PASS | "fix hardware stats..." |
| Correct prefix | ✓ PASS | `net/nbl:` |
| Imperative mood | ✓ PASS | "fix" |
| No trailing period | ✓ PASS | |
| Body ≤75 chars | ✓ PASS | All body lines within limit |
| Body does not start with "It" | ✓ PASS | Starts with "The" |
| Signed-off-by present | ✓ PASS | Valid name and email |
| Fixes tag format | ✓ PASS | 12-char SHA `c9726a719ca1` |
| Cc: stable@dpdk.org | ✓ PASS | Appropriate for bug fix |
| Tag order | ✓ PASS | Fixes → Cc → blank → Signed-off-by |
**Commit message: PASS**
---
### Code Review
#### **WARNING: Unnecessary cast of void pointer**
**Location:** Line 76 in patch (new function `nbl_dev_thread_hw_stats_task`)
```c
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
```
Per AGENTS.md, casting `void *` is unnecessary in C. Should be:
```c
struct rte_eth_dev *eth_dev = param;
```
---
#### **WARNING: Unnecessary variable initialization**
**Location:** Line 101 in patch
```c
ssize_t nw = 0;
```
The variable is immediately assigned on line 104 (`nw = write(...)`), making the `= 0` initialization unnecessary. Per AGENTS.md guidelines on unnecessary initialization patterns.
---
#### **WARNING: Resource leak on error path**
**Location:** `nbl_dev_hw_stats_start()` around lines 213-224 in patch
If `pipe()` succeeds but `rte_thread_create_internal_control()` fails, the pipe file descriptors are leaked:
```c
ret = pipe(net_dev->fd);
if (ret) {
NBL_LOG(ERR, "hw_stats pipe failed, ret %d", ret);
return ret;
}
ret = rte_thread_create_internal_control(&net_dev->tid, "nbl_hw_stats_thread",
nbl_dev_thread_hw_stats_task, eth_dev);
if (ret) {
NBL_LOG(ERR, "create hw_stats thread failed, ret %d", ret);
return ret; // <-- LEAK: net_dev->fd[0] and fd[1] not closed
}
```
**Suggested fix:**
```c
ret = rte_thread_create_internal_control(&net_dev->tid, "nbl_hw_stats_thread",
nbl_dev_thread_hw_stats_task, eth_dev);
if (ret) {
NBL_LOG(ERR, "create hw_stats thread failed, ret %d", ret);
close(net_dev->fd[0]);
close(net_dev->fd[1]);
return ret;
}
```
---
#### **INFO: Thread function return type**
**Location:** Line 74
```c
static uint32_t nbl_dev_thread_hw_stats_task(void *param)
```
The `rte_thread_create_internal_control()` callback expects signature `uint32_t (*func)(void *)`, so this is correct. Just noting for completeness.
---
#### **INFO: Consider adding missing include**
The code uses `pipe()`, `read()`, `write()`, and `close()` which typically require `<unistd.h>`. Ensure this header is included (either directly or transitively through `nbl_dev.h` → `nbl_common.h`).
---
### Summary
| Severity | Count | Issues |
|----------|-------|--------|
| **Error** | 0 | — |
| **Warning** | 3 | Unnecessary void* cast, unnecessary initialization, resource leak |
| **Info** | 2 | Return type note, include verification |
### Verdict: **Needs Minor Revision (v2)**
The patch logic is sound—moving the mailbox-dependent stats update from interrupt context to a dedicated thread via pipe notification is the correct approach to resolve interrupt nesting. However, three warnings should be addressed:
1. Remove the unnecessary `(struct rte_eth_dev *)` cast
2. Remove `= 0` from `ssize_t nw` declaration
3. Add cleanup of pipe file descriptors if thread creation fails
next prev parent reply other threads:[~2026-01-14 17:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 8:15 [PATCH v1 0/1] fix hardware stats interrupt nesting issue Dimon Zhao
2026-01-14 8:15 ` [PATCH v1 1/1] net/nbl: " Dimon Zhao
2026-01-14 17:23 ` Stephen Hemminger [this message]
2026-01-15 6:18 ` [PATCH v2 0/1] " Dimon Zhao
2026-01-15 6:18 ` [PATCH v2 1/1] net/nbl: " Dimon Zhao
2026-01-21 4:46 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260114092301.62d942c8@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=dimon.zhao@nebula-matrix.com \
--cc=kyo.liu@nebula-matrix.com \
--cc=leon.yu@nebula-matrix.com \
--cc=sam.chen@nebula-matrix.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox