Commit 8430f52a authored by Jie Wang's avatar Jie Wang Committed by Hao Chen
Browse files

net: hns3: add cond_resched() to hns3 ring buffer init process

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9NZTZ


CVE: NA

----------------------------------------------------------------------

Currently hns3 ring buffer init process would hold cpu too long with big
Tx/Rx ring depth. This could cause soft lockup.

So this patch adds cond_resched() to the process. Then cpu can break to
run other tasks instead of busy looping.

Fixes: a723fb8e ("net: hns3: refine for set ring parameters")

Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
parent e6917fe7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3786,6 +3786,9 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring)
		ret = hns3_alloc_and_attach_buffer(ring, i);
		if (ret)
			goto out_buffer_fail;

		if (!(i % HNS3_RESCHED_BD_NUM))
			cond_resched();
	}

	return 0;
@@ -5367,6 +5370,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv)
		}

		u64_stats_init(&priv->ring[i].syncp);
		cond_resched();
	}

	return 0;
+2 −0
Original line number Diff line number Diff line
@@ -221,6 +221,8 @@ enum hns3_nic_state {

#define HNS3_FD_QB_FORCE_CNT_MAX		20

#define HNS3_RESCHED_BD_NUM			1024

enum hns3_pkt_l2t_type {
	HNS3_L2_TYPE_UNICAST,
	HNS3_L2_TYPE_MULTICAST,