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

From: Simon Horman

Date: Wed Nov 25 2026 - 05:38:59 EST


On Wed, Nov 18, 2026 at 09:03:29PM +0800, Jijie Shao wrote:
> NAPI polling on hns3 is driven by hardware RX interrupts. Under
> memory pressure, RX skb and frag allocations fail, packets are no
> longer reaped from the hardware rx ring. Once the ring fills, the
> hardware stops generating RX interrupts and NAPI is never scheduled
> again -- even after memory becomes available, leaving the interface
> deadlocked.
>
> Break the deadlock by adding a software recovery path that re-arms
> NAPI via a 250ms delayed_work, independent of hardware interrupts.
> A per-ring bitmap tracks which RX rings are in OOM state; the work
> function schedules NAPI for the vector backing each affected ring.
> OOM state is marked when an RX allocation failure is detected in the
> poll path and cleared when the delayed_work fires.
>
> This supersedes the busy-poll recovery from commit 68752b24f51a
> ("net: hns3: schedule the polling again when allocation fails"),
> which returned budget on allocation failure to keep NAPI polling
> and caused CPU spinning under prolonged memory pressure. Now
> hns3_clean_rx_ring() returns recv_pkts instead of budget on
> allocation failure, letting NAPI exit and the delayed_work take
> over. The exit refill is still attempted for the descriptors
> accumulated since the last refill, so the head pointer is written as
> before; descriptors from earlier iterations are not re-armed when an
> allocation failure short-circuits the in-loop refill.
>
> Add a per-ring rx_oom_cnt ethtool counter, incremented for each NAPI
> poll that hits an RX allocation failure. It is a diagnostic counter
> for this recovery path, not the standard rx-alloc-fail qstat.
>
> The bitmap is allocated in hns3_init_all_ring() and freed in
> hns3_uninit_all_ring(). It is allocated after every ring is set up,
> so a failure inside hns3_init_all_ring() leaves nothing behind, and
> it is reused because hns3_set_ringparam() calls hns3_init_all_ring()
> without hns3_uninit_all_ring(). The delayed_work is cancelled in
> hns3_uninit_all_ring() before the rings and the bitmap are released,
> and also in hns3_nic_uninit_vector_data() before the NAPI instances
> are torn down.
>
> hns3_nic_net_down() does not cancel the work, so a pending work may
> still run after the interface goes down. If it runs while DOWN is
> set, it clears the per-ring bits without scheduling NAPI. If the
> interface is brought back up within the 250ms window, it sees the
> stale bits with DOWN cleared and schedules NAPI for those rings once,
> ending in a single extra poll round with no packet to clean. Both
> outcomes are harmless.
>
> Fixes: 68752b24f51a ("net: hns3: schedule the polling again when allocation fails")
> Signed-off-by: Jijie Shao <shaojijie@xxxxxxxxxx>

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>