linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: hns: fix soft lockup when there is not enough memory
@ 2020-01-16  7:41 Yonglong Liu
  2020-01-17 10:20 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Yonglong Liu @ 2020-01-16  7:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, jakub.kicinski

When there is not enough memory and napi_alloc_skb() return NULL,
the HNS driver will print error message, and than try again, if
the memory is not enough for a while, huge error message and the
retry operation will cause soft lockup.

When napi_alloc_skb() return NULL because of no memory, we can
get a warn_alloc() call trace, so this patch deletes the error
message. We already use polling mode to handle irq, but the
retry operation will render the polling weight inactive, this
patch just return budget when the rx is not completed to avoid
dead loop.

Fixes: 36eedfde1a36 ("net: hns: Optimize hns_nic_common_poll for better performance")
Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic ethernet support")
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 14ab204..eb69e5c 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -565,7 +565,6 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
 	skb = *out_skb = napi_alloc_skb(&ring_data->napi,
 					HNS_RX_HEAD_SIZE);
 	if (unlikely(!skb)) {
-		netdev_err(ndev, "alloc rx skb fail\n");
 		ring->stats.sw_err_cnt++;
 		return -ENOMEM;
 	}
@@ -1056,7 +1055,6 @@ static int hns_nic_common_poll(struct napi_struct *napi, int budget)
 		container_of(napi, struct hns_nic_ring_data, napi);
 	struct hnae_ring *ring = ring_data->ring;
 
-try_again:
 	clean_complete += ring_data->poll_one(
 				ring_data, budget - clean_complete,
 				ring_data->ex_process);
@@ -1066,7 +1064,7 @@ static int hns_nic_common_poll(struct napi_struct *napi, int budget)
 			napi_complete(napi);
 			ring->q->handle->dev->ops->toggle_ring_irq(ring, 0);
 		} else {
-			goto try_again;
+			return budget;
 		}
 	}
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: hns: fix soft lockup when there is not enough memory
  2020-01-16  7:41 [PATCH net] net: hns: fix soft lockup when there is not enough memory Yonglong Liu
@ 2020-01-17 10:20 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-01-17 10:20 UTC (permalink / raw)
  To: liuyonglong; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, jakub.kicinski

From: Yonglong Liu <liuyonglong@huawei.com>
Date: Thu, 16 Jan 2020 15:41:17 +0800

> When there is not enough memory and napi_alloc_skb() return NULL,
> the HNS driver will print error message, and than try again, if
> the memory is not enough for a while, huge error message and the
> retry operation will cause soft lockup.
> 
> When napi_alloc_skb() return NULL because of no memory, we can
> get a warn_alloc() call trace, so this patch deletes the error
> message. We already use polling mode to handle irq, but the
> retry operation will render the polling weight inactive, this
> patch just return budget when the rx is not completed to avoid
> dead loop.
> 
> Fixes: 36eedfde1a36 ("net: hns: Optimize hns_nic_common_poll for better performance")
> Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic ethernet support")
> Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-17 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16  7:41 [PATCH net] net: hns: fix soft lockup when there is not enough memory Yonglong Liu
2020-01-17 10:20 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).