Re: [PATCH v5 net 3/4] net: hns3: fix interface stuck after OOM with full hardware rx queue

From: Jijie Shao

Date: Wed Nov 25 2026 - 22:58:48 EST



on 2026/11/25 22:31, Paolo Abeni wrote:
On 11/23/26 08:33, Jijie Shao wrote:
on 2026/11/22 21:24, netdev-bot+sashiko@xxxxxxxxxx wrote:
@@ -4489,10 +4519,15 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
       * FBD number with head pointer
       */
      if (unused_count > 0)
-        failure = failure ||
-              hns3_nic_alloc_rx_buffers(ring, unused_count);
+        failure |= hns3_nic_alloc_rx_buffers(ring, unused_count);
+
+    if (unlikely(failure))
+        hns3_ring_set_oom_state(ring);
[Severity: Medium]
Can rx_oom_cnt be incremented twice in a single NAPI poll here?

The commit message says the counter is "incremented for each NAPI poll
that hits an RX allocation failure". When the fraglist napi_alloc_skb()
fails in hns3_add_frag(), the path looks like this:

hns3_clean_rx_ring()
   hns3_handle_rx_bd()
     hns3_add_frag()
       hns3_ring_set_oom_state(ring);   /* rx_oom_cnt++ */
       return -ENXIO;
   goto out;
   failure |= hns3_nic_alloc_rx_buffers(ring, unused_count);
   if (unlikely(failure))
       hns3_ring_set_oom_state(ring);   /* rx_oom_cnt++ again */

-ENXIO doesn't match the new err == -ENOMEM check. But failure can still
be true, either from a failed exit refill or from an earlier failed
in-loop refill. Under the memory pressure that caused the fraglist
failure, the refill is likely to fail too.

hns3_ring_set_oom_state() has no per-poll dedup, so in this case the
counter goes up by two for one poll.

The second increment only happens when a second allocation actually
failed.  hns3_add_frag() counts its failed napi_alloc_skb() and returns
-ENXIO, which doesn't set `failure`, so the exit refill still runs and
bumps the counter again only if it fails too.  Two increments mean two
failures.  I agree "for each NAPI poll" can read as at most once per
poll, that's just imprecise wording.
I agree another repost is not needed here. However patch 1, 2 and 4
are net-next material and only patch 3 is borderline net material.

To avoid a repost and splitting, I would apply everything to net-next.


Applying the whole series to net-next is fine with me

Thanks,
Jijie Shao