Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp123813lqr; Wed, 5 Jun 2024 00:27:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVg5xBseI1Zhy5nnyaQfd+TjEYihTKy0KuMfDh+r6cXbIW1TFHNZIgXmCYRlqXMCk9jV2c+qKeate4zlYgg0rLxebKmAWDuOglS9tNyXQ== X-Google-Smtp-Source: AGHT+IGEZDpmipwAE8wCny8pTAQDgahhfQwLpRE09zEhkHNZuX5Yb5rmC5DwYlCuXQqTvNeoHsEQ X-Received: by 2002:a05:620a:135a:b0:793:181:5223 with SMTP id af79cd13be357-79523c24048mr186060885a.10.1717572440566; Wed, 05 Jun 2024 00:27:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717572440; cv=pass; d=google.com; s=arc-20160816; b=wN0tE8bMxDMVCh8LjbJgM3UaYS26/B6UF6dmtj047GL/ejuhIBhen4Cb9vgF4o2qRd kXAzzuvWWMdAggxJXd+2YG24eYTk60Zsk7tg6KOlvS1S2GdsSqbosFIpjKgagj4r8cvw 4XEkwFBCS6Yw8VJdYMqN1F3cmS124IpTYhX9dFt1U+3qhqJq29dkekY/Mut1e8upUz8R HN/3d3/TaI1SLpAwmTBaT3ZOrFfFcXTFUPTKpZZ4ewGyqVDASncZG/Ha2FbFOB9IBU0A 4ylh+FwK7FrS+kvGmhmGscPm48/jKK3kAOcIzYDaGLzpmq5FsA54lOfbko+IJjxM4pwE RyKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=O0Wi7iNQZyCR0ctMsrqDPCLKKdk4KhnD2xACC/XW/D4=; fh=8eoVmgxLw0HCyOKEL9MuHelSJxvYTGQ3f7Aprt836Kg=; b=ybZ/RMgrQMdyzuW1872P1gpb5xHfiG2JzpxH2BQTa+EC6TebhHigV4flpTh7O4AxK0 6VhzTD6iBe+883d3l3u2PNWhvxnK+0SBrHzXMRkagUMUJeOv1wrnvTge1VCsL0lHQhax JMb0ht1CIU6ZymNUEoJwEE/WFE4g0LtgyvXIEI2ZxyeIXVn8AAe/tlbeiasKMT4T5wbF MnTKn3Sy7nN/zSTzYRg68KslnIbhEV9HVARlV0XUwOjdnZzGPjM1ougrSSZXnTw1Oanq iYQLQdbvlqUq472YtW5eQNS0z0K9+RE5nzqCojkXBz8H8/4Jib52cG7mvjqSjSPnizxR LUNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-201880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201880-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f318bd62si362282585a.503.2024.06.05.00.27.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 00:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-201880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201880-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D7B511C210CC for ; Wed, 5 Jun 2024 07:27:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8A5D1922F8; Wed, 5 Jun 2024 07:26:58 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A43E1922D2; Wed, 5 Jun 2024 07:26:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717572418; cv=none; b=s7/P8x25N96LaZTqt9Oc2KhY8/19YucSS3hnT74nPZm+ubkpqRb7jRK2IKxYVBoq+Nd9kwcSwuhVCKH99DYL+w3Ag7Hzs3b3SuG4fuNhh2kSv6seA8TmpBoxt7qNRfwcXj7Nsku4/G50PUeI/gT86rBokGQ/Vbvg4qXQ65X9gzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717572418; c=relaxed/simple; bh=69K+lQZdPoNlIvPUhlkofZ/lRm6YaNS/ZEddmalITlQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F8VdwwuXMgeUZ6bfpYU7zg3FvtagvlF4IfbXJsxtQGU0/4tC916lpEBBMrvQQXXLk7qW4VbHQl3+aIkzyDadXlEvyyPHYPoevwBZigP/NmTuLNaCXpFMD2C/u6djAOeueLv4pCCmDwn8s/6y9ls/2YivfNLwAKeebVTdDXHu2F0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VvJp95s38z1S9Zh; Wed, 5 Jun 2024 15:22:57 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 1D2F81400D8; Wed, 5 Jun 2024 15:26:39 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 5 Jun 2024 15:26:09 +0800 From: Jijie Shao To: , , , , , , CC: , , , , , , Subject: [PATCH net 2/2] net: hns3: add cond_resched() to hns3 ring buffer init process Date: Wed, 5 Jun 2024 15:20:58 +0800 Message-ID: <20240605072058.2027992-3-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240605072058.2027992-1-shaojijie@huawei.com> References: <20240605072058.2027992-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600007.china.huawei.com (7.193.23.208) From: Jie Wang 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: a723fb8efe29 ("net: hns3: refine for set ring parameters") Signed-off-by: Jie Wang Signed-off-by: Jijie Shao --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index ff71fb1eced9..a5fc0209d628 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3535,6 +3535,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; @@ -5107,6 +5110,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv) } u64_stats_init(&priv->ring[i].syncp); + cond_resched(); } return 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index acd756b0c7c9..d36c4ed16d8d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -214,6 +214,8 @@ enum hns3_nic_state { #define HNS3_CQ_MODE_EQE 1U #define HNS3_CQ_MODE_CQE 0U +#define HNS3_RESCHED_BD_NUM 1024 + enum hns3_pkt_l2t_type { HNS3_L2_TYPE_UNICAST, HNS3_L2_TYPE_MULTICAST, -- 2.30.0