BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Zahka" <daniel.zahka@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/4] eth: mpnic: count packets, bytes, and drops per ring
Date: Sat, 10 Oct 2026 11:35:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-166468@kernel.org> (raw)
In-Reply-To: <20261009-mpnic-counters3-v1-1-7dc7644cc500@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] locking: u64_stats_sync deadlock in mpnic_clean_twq0() due to softirq reader
--

commit b438863957f763895e3efd300c4e2cd81b9bb11b
Author: Daniel Zahka <daniel.zahka@gmail.com>

eth: mpnic: count packets, bytes, and drops per ring

Keep packet, byte and drop counters on each Tx work, Tx completion, and
Rx completion queue. Report them to the core via the rtnl_link_stats64
interface using an RCU approach.

> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
> --- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
[ ... ]
> @@ -288,8 +295,19 @@ static void mpnic_clean_twq0(struct mpnic_napi_vector *nv, int napi_budget,
>  
>  	ring->head = head;
>  
> -	if (discard)
> +	if (discard) {
> +		preempt_disable();
> +		u64_stats_update_begin(&ring->stats.syncp);
> +		u64_stats_add(&ring->stats.twq.dropped, total_packets);
> +		u64_stats_update_end(&ring->stats.syncp);
> +		preempt_enable();
>  		return;
> +	}

[Severity: High]
Can this cause a deadlock on 32-bit systems if a softirq preempts the writer?

Writers to u64_stats_sync must be serialized against readers. On 32-bit
systems, readers spin in a retry loop while the sequence counter is odd
(mid-update). The preempt_disable() call disables process preemption but
leaves softirqs enabled. 

If a reader like dev_get_stats is invoked from network receive or BPF softirq
contexts on the same CPU, it might interrupt this writer while the sequence
counter is odd. The reader would then spin infinitely waiting for the count
to become even, resulting in a deadlock.

Should this use local_bh_disable() to protect against BH-context readers?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009-mpnic-counters3-v1-0-7dc7644cc500@gmail.com?part=1

  reply	other threads:[~2026-10-10 11:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 11:35 [PATCH net-next 0/4] eth: mpnic: add basic netdev statistics Daniel Zahka
2026-10-09 11:35 ` [PATCH net-next 1/4] eth: mpnic: count packets, bytes, and drops per ring Daniel Zahka
2026-10-10 11:35   ` sashiko-bot [this message]
2026-10-10 11:52   ` netdev-bot+sashiko
2026-10-12 11:48     ` Daniel Zahka
2026-10-09 11:35 ` [PATCH net-next 2/4] eth: mpnic: report per-queue stats Daniel Zahka
2026-10-10 11:35   ` sashiko-bot
2026-10-09 11:35 ` [PATCH net-next 3/4] eth: mpnic: count Tx queue stops and wakes Daniel Zahka
2026-10-09 11:35 ` [PATCH net-next 4/4] eth: mpnic: count Rx allocation failures Daniel Zahka

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=sashiko-outbox-166468@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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