From patchwork Fri May 3 20:24:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653405 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) (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 5E8641EEFC for ; Fri, 3 May 2024 20:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767905; cv=fail; b=F7e73Zhu9/8TJ5e6DX0NBbhChG2Cqi//SrmbAgs+xF7Gbj2puCXMxyMrmom1oEBcdnGEEp5/gkkDVpNzVAx/cAILpZIkZJyUuyHI1+O4DFGx/onNsspfDbPpDhMiOrNf7ViGGPdSU69xdkD59pN3/u7QCF4Hc/sHdPDZG8yLRgY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767905; c=relaxed/simple; bh=xwfSIKUWJW9K8R5YOy8ukLE+4O8qgQzdfIDxI5gWOsY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S1PfwfcnJYHbD5Wub6iJNOwuHKBhDmU+33NeWWEuccxD3rOvPpD6EAvqVJ3drBeSj2Jmvo20zgRJB2d3ErR0DqB5JL2VImPWAoYV+tAhuPgcRRSMaDDM3Vp+KE91wbnMfMMhdSAa5kdksyKMoqb37JWKrIxZ14Zqx/IvCkEXpck= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=iKEtoG6n; arc=fail smtp.client-ip=40.107.94.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="iKEtoG6n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=efhI6yPninIEkFwmcdYTKfuq3tfvry3BwPw+2KrgDcmdyOtbpUnsvPZOQxPpPEBhMonrJrboYYEv8mQs4mooR2HOv9rctHUK8WaJJLURyNrRnSvxM99RHGnYrJQQzOPMxlRhbPfgM9w3JKEgTyvBIXusAj5uiZCS+wTKVwxtedtpjLbpRh7ZkVP7QtxN6D9Aq9zW/1PcPGKG84llhbj126IyBmqyOG5xsNWfcMn2JoJJGUL3yBHmBUKyQe1twBrDpKnfeDeeaWNvC3YW/jr5ztfLBM4JX4fDjX0yYkHoJod3bMZCgEcjN+EDqK58JuaHlmU2X3p3hff9BRM1e8ze7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L9NEw8amvh1H1Szsm+DPBP0ymEB4Bv9ioYlM8BttYuI=; b=FAYGj6HpTt6qUOH0HkbCaf0Sc25eN/xIdvMVc1ActL/vOQWhB0X2pdOZXBWyQomKH4zzXV9bD94h15W2T1wK9mrTqmq3vAAKPGBob/B9TFcoBaWmgnIB+EAXbhKBsl9Ev/nluYKvWjdq7SqDCa6RsAfFlAaj5TsIf75fhk+zc0pVgFXE0YoMCRa3jkT/k+1NX6PkWYQ4ktRCsyOvTNyeiPdqfEYgr36NFzA12jwuHH2eh+xRFSIo1OkUnliUtwWRT/kWyKCGDr3OATth+3Nt4jVSpO4FvvVItkSXou1kFoGWc39EK/n7GBHTQUIs+K7lBGLrJEws1trc1TPB7N1k4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L9NEw8amvh1H1Szsm+DPBP0ymEB4Bv9ioYlM8BttYuI=; b=iKEtoG6npkyMTN1JNfKqjr4ooLFkpo+hmvm2B4cGQtCBBqDZHpGbtZ3euIN51h7uv3AdcNLqY9B5BWv7Pv4Sw8Ncu0Dk1VimjZ5bfuEW44zWfRq1O2F2JGftbAPYRXL3Im/4JEJPfP4NTSX5vt4a8/BmU/cJiWCIx8s0zBKZljyM+gTNCnwzyswleXJrMJRYJRlSSEtT3M8Ku+eoCMO2eEccSUkRZE+rsMga7kpWW6D3QbfaMcVvw3WToGlPOfatwcIoYLVuHJH8txfuTGXSwaUu5cCcqj2xbcY+KdNQ2mGZkgXgaeOMTBpjN3PIyS1VisJ1LIUIPXzNFEZgP40BpQ== Received: from SN6PR05CA0028.namprd05.prod.outlook.com (2603:10b6:805:de::41) by CY8PR12MB7708.namprd12.prod.outlook.com (2603:10b6:930:87::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 20:25:00 +0000 Received: from SN1PEPF00036F41.namprd05.prod.outlook.com (2603:10b6:805:de:cafe::e1) by SN6PR05CA0028.outlook.office365.com (2603:10b6:805:de::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.32 via Frontend Transport; Fri, 3 May 2024 20:25:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SN1PEPF00036F41.mail.protection.outlook.com (10.167.248.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:00 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:51 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:50 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:50 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 1/6] virtio_net: Store RSS setting in virtnet_info Date: Fri, 3 May 2024 23:24:40 +0300 Message-ID: <20240503202445.1415560-2-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F41:EE_|CY8PR12MB7708:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fab17a3-29ba-4098-b35c-08dc6baf1b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: 2tA29RsnQNhcdvl+7VHaturi3w5hB4atDJylYctTsQbP8lneWLNrFx84KhtU5I9sNxZZVvgVMOnIt3BFK6XZeIgq0OLBjMkaz0F0o5x4DlqyyX6Xg7s4CEIjYF6kn2+Bx1C3tjpqmTmHfnC+sZwbq85gBDTr0aZKdZ8GfzWxrZUS3DvZmPMPk3lUsQeSdpBPZYtpO0cmczw+g2g74vGGnBbRWPEWFHYROh38HB1acqJebDap1PPDIrG6c3SeybppqhCeVTFB+tl8Mmj9VMP+gqS9HmMG/PzoSfbmNsF5NS4VTafcMcgM9hrwMFChXTZXthNJfJa9SngYxYVbPTzvLez2IFegs/At4HtsZDXWJghbZ3x0CeVCUFSkM3lvZpE/aiEWEydQ8pJN4Zg1B3CX3HFWQBsUCn9JHwvorjJ5nNUvYgX3V8MMkPV2ZmBeMWIqnAtUMR/+DXWU+VdkXGOB/4SjiO8f+YfK+lTSgDrsHgLgCdFf1msVwbp9NNrNm8uxIxGvRd8kTyWeeGIqPrSkW6Rhfiek/LnAsrs8HX2LAd1WE8ofdBSiUhvXev9v7gB6XonoTJ/vnF/Ek4wVxSXUyuVcn8sO0RtIIM54Cf0SKS9Y3JCKomGfJHpXwDfMAw0zmYpw22DzamuMlDx+YT5qHjemdfWfuVuCRkeiVHDqpp93fR2ZiZPWigPXNflqzYr9mbhECDlDR3e7SSSquc5VK9BL9Rk66GAAV97F7quQJTHwUdS7m/51hhjyYt/v8crUUPFEvoa+R04sHrrnYPDgsosPGMcFnMKAsOjFhqNAuKEX8TEMUcdbow2z58bmsX6VqUQkoBVrq6Be/v1fkNbjSMMhf0W0avPPnD53AQ178IZd/3hIZlRACsq3KhPXpYWgNRObaNje0xf3SU4EqDUbvq1ywdSe6XZTFj4Tr9PnM6syw1BmWbztL5EaLznfI0sj7tc1gb7uGYcZABZQ81J9AIbB2eoL1r9d1hkPAaaMnC7TxsBvXRn7HysQ0t5k7qNxcKOVCVTczCA0AcwaE6qWYXrQUsG6PvVxn8JQpyWLcxIvkK/MlFmw+Hrey9Ot+6GMeRITRXjjSboI7YpTlrDdTjrj33q45XyLMLFZgqj/5tQ3VJIAbBW/dYhVsJo7iXHFka4kPvHt2hNfKQYJkeC9mCLG9FWMC/qV4DFKQH5BzRtsp+KiX32DXM+aIxxYh0rNXhgT2AZi9pON9usSuDs27bzDA+VwEdWvZybREwbZjfOMJKzpOxaGXavwOpIWlNhyQWFKltBwz9b+ftY6GZD0L9GXug4sn2Yiu9YD4qrYwZqBxk7hnbgZj3XlGdjkpuEyh/Y856PeDproXbAvEs9t+2S/9prWVx1iZuWmhI1PPtM= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:00.3713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fab17a3-29ba-4098-b35c-08dc6baf1b85 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F41.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7708 X-Patchwork-Delegate: kuba@kernel.org Stop storing RSS setting in the control buffer. This is prep work for removing RTNL lock protection of the control buffer. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1fa84790041b..9cf93a8a4446 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -373,7 +373,6 @@ struct control_buf { u8 allmulti; __virtio16 vid; __virtio64 offloads; - struct virtio_net_ctrl_rss rss; struct virtio_net_ctrl_coal_tx coal_tx; struct virtio_net_ctrl_coal_rx coal_rx; struct virtio_net_ctrl_coal_vq coal_vq; @@ -416,6 +415,7 @@ struct virtnet_info { u16 rss_indir_table_size; u32 rss_hash_types_supported; u32 rss_hash_types_saved; + struct virtio_net_ctrl_rss rss; /* Has control virtqueue */ bool has_cvq; @@ -3243,17 +3243,17 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) sg_init_table(sgs, 4); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, indirection_table); - sg_set_buf(&sgs[0], &vi->ctrl->rss, sg_buf_size); + sg_set_buf(&sgs[0], &vi->rss, sg_buf_size); - sg_buf_size = sizeof(uint16_t) * (vi->ctrl->rss.indirection_table_mask + 1); - sg_set_buf(&sgs[1], vi->ctrl->rss.indirection_table, sg_buf_size); + sg_buf_size = sizeof(uint16_t) * (vi->rss.indirection_table_mask + 1); + sg_set_buf(&sgs[1], vi->rss.indirection_table, sg_buf_size); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, key) - offsetof(struct virtio_net_ctrl_rss, max_tx_vq); - sg_set_buf(&sgs[2], &vi->ctrl->rss.max_tx_vq, sg_buf_size); + sg_set_buf(&sgs[2], &vi->rss.max_tx_vq, sg_buf_size); sg_buf_size = vi->rss_key_size; - sg_set_buf(&sgs[3], vi->ctrl->rss.key, sg_buf_size); + sg_set_buf(&sgs[3], vi->rss.key, sg_buf_size); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG @@ -3269,21 +3269,21 @@ static void virtnet_init_default_rss(struct virtnet_info *vi) u32 indir_val = 0; int i = 0; - vi->ctrl->rss.hash_types = vi->rss_hash_types_supported; + vi->rss.hash_types = vi->rss_hash_types_supported; vi->rss_hash_types_saved = vi->rss_hash_types_supported; - vi->ctrl->rss.indirection_table_mask = vi->rss_indir_table_size + vi->rss.indirection_table_mask = vi->rss_indir_table_size ? vi->rss_indir_table_size - 1 : 0; - vi->ctrl->rss.unclassified_queue = 0; + vi->rss.unclassified_queue = 0; for (; i < vi->rss_indir_table_size; ++i) { indir_val = ethtool_rxfh_indir_default(i, vi->curr_queue_pairs); - vi->ctrl->rss.indirection_table[i] = indir_val; + vi->rss.indirection_table[i] = indir_val; } - vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; - vi->ctrl->rss.hash_key_length = vi->rss_key_size; + vi->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; + vi->rss.hash_key_length = vi->rss_key_size; - netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size); + netdev_rss_key_fill(vi->rss.key, vi->rss_key_size); } static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_rxnfc *info) @@ -3394,7 +3394,7 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc * if (new_hashtypes != vi->rss_hash_types_saved) { vi->rss_hash_types_saved = new_hashtypes; - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; if (vi->dev->features & NETIF_F_RXHASH) return virtnet_commit_rss_command(vi); } @@ -4574,11 +4574,11 @@ static int virtnet_get_rxfh(struct net_device *dev, if (rxfh->indir) { for (i = 0; i < vi->rss_indir_table_size; ++i) - rxfh->indir[i] = vi->ctrl->rss.indirection_table[i]; + rxfh->indir[i] = vi->rss.indirection_table[i]; } if (rxfh->key) - memcpy(rxfh->key, vi->ctrl->rss.key, vi->rss_key_size); + memcpy(rxfh->key, vi->rss.key, vi->rss_key_size); rxfh->hfunc = ETH_RSS_HASH_TOP; @@ -4602,7 +4602,7 @@ static int virtnet_set_rxfh(struct net_device *dev, return -EOPNOTSUPP; for (i = 0; i < vi->rss_indir_table_size; ++i) - vi->ctrl->rss.indirection_table[i] = rxfh->indir[i]; + vi->rss.indirection_table[i] = rxfh->indir[i]; update = true; } @@ -4614,7 +4614,7 @@ static int virtnet_set_rxfh(struct net_device *dev, if (!vi->has_rss && !vi->has_rss_hash_report) return -EOPNOTSUPP; - memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size); + memcpy(vi->rss.key, rxfh->key, vi->rss_key_size); update = true; } @@ -5028,9 +5028,9 @@ static int virtnet_set_features(struct net_device *dev, if ((dev->features ^ features) & NETIF_F_RXHASH) { if (features & NETIF_F_RXHASH) - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; else - vi->ctrl->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; + vi->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; if (!virtnet_commit_rss_command(vi)) return -EINVAL; From patchwork Fri May 3 20:24:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653406 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) (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 269D3158DAA for ; Fri, 3 May 2024 20:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767908; cv=fail; b=Dhjppsv5eXC5XaNlzHYAgEWZTecnTGmPwUmmqDRiV1+8fUzTqqrk9n5CHef8wB/LIzNG7x8oKeJ76qRcv2l3gxBYcvL49l/DXDWVS+3T1XcrfAmHthJo8SCmyZKm/P4PyZUIO2cVfQpXldWzEFs/qxcQSG9pyVFMQ7ryd2pvsvY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767908; c=relaxed/simple; bh=yVLtM2rVnvlfbiUcprJ/yJx+5pzKOgsd+46TrTMdQ4g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fBp7AbyrucEPgDHIquyD2bj+WVkMIxIg49k7cpSwaj5gRdjkB5ytbQ9wLGJWrnPpOOtaMRbeN0FmHaIXsA6U863/xTDlnGgkFMrhsPh79oVC4+xHOWqfP1pAr0sgDKA/I4bubvDobUD69nBGZ0Rd/SodTrMqy9mLVdlo/Y10ZJI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=QytU5Otx; arc=fail smtp.client-ip=40.107.93.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="QytU5Otx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XojHUQqrXWq3MvqhAZu5a3cK6LU38lnNQO9zkUHHFI5YRaXwcEJoIGgpoX71l219TGnLFWXbz35rrheAiQTXusL6yPHGId9P9G9S8IZFYC4efmvot7SA7jDLVgj9zMxU7REXpulRHvDukuZfrR3SwHdrCQ+7I/St8z8Nk1PwhnhfeI9sn0rXO1jb9xCB2qq19FsEORF/xsWVMcNM9zpNjWxP1OWKRPslv6KdCiERHINQwmH+rdSgfDpxsHRz9A6NtDfMK6hQK+kNOXGrC4cT7pX+iweeWVBS5DrlUCT2FRHLR/SVWEfz/ezG6vsFEnVA7RRqhcIB/A5fLR6CWlo41g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=25TjUMHRDVb2YCsm5h14vrQErUWbP7QqtFxuZNFr1yU=; b=KkOLGL9sx9up4MPwX39FtJ8GVRLVIxSyiY1H85V3GsOJ3/b6RJbbJzNaDgYJcuWQpLPiMtdn+8LJq7vrE+uc7Zd6KJEscodMWijMO7460JwxX2xARrB8P64hpwM7wqWNGguQSJTeCAfb8SqR+byEa5TDP3s11XLq5BBKdEa4Ia87LOZbZ+ZZsmT5xS83LPCc+eVtA+Ofulu52OFcoB5ICUxGX45778bVHK1mZOMI/TUZbQGWlB5jOCjnSmlyIPyyGNHzNbMnvVw96wOYzZV2IVV4va2nv9ni88eF8w6nHuZFqR28obR8+rMsNnsmzOKpe1lQHJl9zPfoynoLfpCFkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25TjUMHRDVb2YCsm5h14vrQErUWbP7QqtFxuZNFr1yU=; b=QytU5Otx89xce2HajeYoBjfJM/wrg6YhH56ld0Iu9yATIEfQvij1ymEfo4GwJLzqI/CpxAD+SnicSITqBogD1k8REzivR7VJBPGRWR6IJYuJDUhBli8GOxOOL0n3O3ljJvskfFzZm8MTzElUwdbTHXDYZtuGEhMhMmK8+qp8AOJcD4JWr5r6f7mfXsSv1Cxyv7UEZ1aPaZZUAp77qv+vqqz1BHPg+DCBs+Qktf/4GME33xOEJT1YQUZJgoYdqTsGm5Xn0Imgw/be2L/GsbUAoTUBS4S+/Jzz5AiqxCZ38xmmrp4ZtLt3FVrk5VMVw4390FW4ksQkvUOL+Aa3ynl8ag== Received: from PH0PR07CA0035.namprd07.prod.outlook.com (2603:10b6:510:e::10) by PH7PR12MB6718.namprd12.prod.outlook.com (2603:10b6:510:1b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 20:25:03 +0000 Received: from SN1PEPF00036F40.namprd05.prod.outlook.com (2603:10b6:510:e:cafe::b4) by PH0PR07CA0035.outlook.office365.com (2603:10b6:510:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29 via Frontend Transport; Fri, 3 May 2024 20:25:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SN1PEPF00036F40.mail.protection.outlook.com (10.167.248.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:02 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:52 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:52 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:51 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 2/6] virtio_net: Remove command data from control_buf Date: Fri, 3 May 2024 23:24:41 +0300 Message-ID: <20240503202445.1415560-3-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F40:EE_|PH7PR12MB6718:EE_ X-MS-Office365-Filtering-Correlation-Id: f32a0bdd-27a6-48ba-b4d5-08dc6baf1cfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: x5OnpbbtmHu83+P9MUSTJ4hcof6h842VUDVtgDzpRcXrSNF/Gi9FvJmWK2u1XYEQh7B/COLA9ZekurteEVwAqijDPRE9QhKCu3E7cGdbsK+9WvnXo4p1015JUpjIo8APhMAiBHeQP2+aG8S7yInYmFg2OXD7lNj6nCFi3aTy0u7Dukzj7AAFSLWSHZwVbqjgS3tKykamvc5h38zIcsJl7/uAY7jT3zSYrAOEDmb4UzxNEHtW2Qt8L3aujtf8BSrelh/8Y4sXbsh+85mWpPuaQcoo0wGrgpfvLONPOsGdswr6CN1W5nSqrZxilATe3QbA5BvAho3zMKwHx2i8/zGBZrJiqU+9zifTbmAfw4OZ3AX887cnTlqtH2wCZwu9kQAqAcwN5SY2Z6PCzxvhQ+axp/PBhaVbjhGgpB17bxqRM/sxsGWZz2YPBSqepB50IeIIe3AqVoBjui8wKzyiIXm62t907lg9sbVNYzFP5JYkApcvEbiN0bqC/N04y0bOxVJJ5cmvDcvf82+rY8OWwYblAVpZvuUwivJB0TQCZQq9eAVBAfWRwchBr4lB6Fdy0DI9NXgGewX5RlhecoqPM/+sN0QcCi2x/bvp7G+8PHEdcIdAxcN9Tstpewp4vVq1aBx4aBDSJ58ATVwscrM4/GEM34le69kLoGAZbQ8sIxbbolsua2HMiwNAioGLfYX5wh6XpT+xsdAXcrgY521S/Nef6clxi9jDrtrulm9zcV0AhRNUORZ+fzHZeK5kzBULGcTdKdTc9ZaUWxVlJdukuXZ6eSzlp55yBYVu+reZ4jpbSbmd9ABlRfELVY3n9HRLnF9TzQByIYKQSZm4R8hSGADQQI8CMe+G1iXrT2yT9QDnoTjJuDaBIte27xznj1OfKzstumdl19hynEI0zDsgQ5F0nX0h5sVzKAe7nNWc0He6KSqPRU7Hrx9uViWySmVLaR8lehaOIbKkZNX114512AZ50wVl21G8MCSf5ezVGkfJ689nwrg99gf1IM4LsQukhRPqOEfh6U4EenqfRbrTmOiENldjbUIkAKccrs/St9ETMyTEsdQcaMX3JPgBbGZVTr5q4gfQqM7WGf79UWvN8LdDJka4p7NX6cnlNhuzcOvu1ztbGDs+rIkD8pEk58rDBPTsMMocIWL2SbNSK1lfOKjE5DaLeSh8jVrLq/Q4O+bKwCJ48La4yGXRRZk0Y5AOWEzCtf+I34hxD13ZOUkdfN/Tj4ekMU/AHzVPllSIJct1KFAdH6P9xhSKzFJVs6wPpRrD6BzGyqIRTwiZ9qRixE4UVPqNSLScQBV3+0Clxxac4CvSlmz/02bci6gQrdQnMQKtn9+56fXz7ekZ2YDn5dJI5lGFN+tqdpw7yk9RUDinfEqYwN8pYId2JSasHapFfiPz X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:02.8042 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f32a0bdd-27a6-48ba-b4d5-08dc6baf1cfd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F40.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6718 X-Patchwork-Delegate: kuba@kernel.org Allocate memory for the data when it's used. Ideally the struct could be on the stack, but we can't DMA stack memory. With this change only the header and status memory are shared between commands, which will allow using a tighter lock than RTNL. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 124 +++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 39 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9cf93a8a4446..451879d570a8 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -368,15 +368,6 @@ struct virtio_net_ctrl_rss { struct control_buf { struct virtio_net_ctrl_hdr hdr; virtio_net_ctrl_ack status; - struct virtio_net_ctrl_mq mq; - u8 promisc; - u8 allmulti; - __virtio16 vid; - __virtio64 offloads; - struct virtio_net_ctrl_coal_tx coal_tx; - struct virtio_net_ctrl_coal_rx coal_rx; - struct virtio_net_ctrl_coal_vq coal_vq; - struct virtio_net_stats_capabilities stats_cap; }; struct virtnet_info { @@ -2828,14 +2819,19 @@ static void virtnet_ack_link_announce(struct virtnet_info *vi) static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) { + struct virtio_net_ctrl_mq *mq __free(kfree) = NULL; struct scatterlist sg; struct net_device *dev = vi->dev; if (!vi->has_cvq || !virtio_has_feature(vi->vdev, VIRTIO_NET_F_MQ)) return 0; - vi->ctrl->mq.virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs); - sg_init_one(&sg, &vi->ctrl->mq, sizeof(vi->ctrl->mq)); + mq = kzalloc(sizeof(*mq), GFP_KERNEL); + if (!mq) + return -ENOMEM; + + mq->virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs); + sg_init_one(&sg, mq, sizeof(*mq)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, &sg)) { @@ -2864,6 +2860,7 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) static int virtnet_close(struct net_device *dev) { + u8 *promisc_allmulti __free(kfree) = NULL; struct virtnet_info *vi = netdev_priv(dev); int i; @@ -2888,6 +2885,7 @@ static void virtnet_rx_mode_work(struct work_struct *work) struct scatterlist sg[2]; struct virtio_net_ctrl_mac *mac_data; struct netdev_hw_addr *ha; + u8 *promisc_allmulti; int uc_count; int mc_count; void *buf; @@ -2899,22 +2897,27 @@ static void virtnet_rx_mode_work(struct work_struct *work) rtnl_lock(); - vi->ctrl->promisc = ((dev->flags & IFF_PROMISC) != 0); - vi->ctrl->allmulti = ((dev->flags & IFF_ALLMULTI) != 0); + promisc_allmulti = kzalloc(sizeof(*promisc_allmulti), GFP_ATOMIC); + if (!promisc_allmulti) { + dev_warn(&dev->dev, "Failed to set RX mode, no memory.\n"); + return; + } - sg_init_one(sg, &vi->ctrl->promisc, sizeof(vi->ctrl->promisc)); + *promisc_allmulti = !!(dev->flags & IFF_PROMISC); + sg_init_one(sg, promisc_allmulti, sizeof(*promisc_allmulti)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, VIRTIO_NET_CTRL_RX_PROMISC, sg)) dev_warn(&dev->dev, "Failed to %sable promisc mode.\n", - vi->ctrl->promisc ? "en" : "dis"); + *promisc_allmulti ? "en" : "dis"); - sg_init_one(sg, &vi->ctrl->allmulti, sizeof(vi->ctrl->allmulti)); + *promisc_allmulti = !!(dev->flags & IFF_ALLMULTI); + sg_init_one(sg, promisc_allmulti, sizeof(*promisc_allmulti)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, VIRTIO_NET_CTRL_RX_ALLMULTI, sg)) dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n", - vi->ctrl->allmulti ? "en" : "dis"); + *promisc_allmulti ? "en" : "dis"); netif_addr_lock_bh(dev); @@ -2975,10 +2978,15 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { struct virtnet_info *vi = netdev_priv(dev); + __virtio16 *_vid __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); - sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); + _vid = kzalloc(sizeof(*_vid), GFP_KERNEL); + if (!_vid) + return -ENOMEM; + + *_vid = cpu_to_virtio16(vi->vdev, vid); + sg_init_one(&sg, _vid, sizeof(*_vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, VIRTIO_NET_CTRL_VLAN_ADD, &sg)) @@ -2990,10 +2998,15 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) { struct virtnet_info *vi = netdev_priv(dev); + __virtio16 *_vid __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); - sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); + _vid = kzalloc(sizeof(*_vid), GFP_KERNEL); + if (!_vid) + return -ENOMEM; + + *_vid = cpu_to_virtio16(vi->vdev, vid); + sg_init_one(&sg, _vid, sizeof(*_vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, VIRTIO_NET_CTRL_VLAN_DEL, &sg)) @@ -3106,12 +3119,17 @@ static void virtnet_cpu_notif_remove(struct virtnet_info *vi) static int virtnet_send_ctrl_coal_vq_cmd(struct virtnet_info *vi, u16 vqn, u32 max_usecs, u32 max_packets) { + struct virtio_net_ctrl_coal_vq *coal_vq __free(kfree) = NULL; struct scatterlist sgs; - vi->ctrl->coal_vq.vqn = cpu_to_le16(vqn); - vi->ctrl->coal_vq.coal.max_usecs = cpu_to_le32(max_usecs); - vi->ctrl->coal_vq.coal.max_packets = cpu_to_le32(max_packets); - sg_init_one(&sgs, &vi->ctrl->coal_vq, sizeof(vi->ctrl->coal_vq)); + coal_vq = kzalloc(sizeof(*coal_vq), GFP_KERNEL); + if (!coal_vq) + return -ENOMEM; + + coal_vq->vqn = cpu_to_le16(vqn); + coal_vq->coal.max_usecs = cpu_to_le32(max_usecs); + coal_vq->coal.max_packets = cpu_to_le32(max_packets); + sg_init_one(&sgs, coal_vq, sizeof(*coal_vq)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET, @@ -3257,11 +3275,15 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG - : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs)) { - dev_warn(&dev->dev, "VIRTIONET issue with committing RSS sgs\n"); - return false; - } + : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs)) + goto err; + return true; + +err: + dev_warn(&dev->dev, "VIRTIONET issue with committing RSS sgs\n"); + return false; + } static void virtnet_init_default_rss(struct virtnet_info *vi) @@ -4193,12 +4215,17 @@ static int virtnet_get_link_ksettings(struct net_device *dev, static int virtnet_send_tx_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { + struct virtio_net_ctrl_coal_tx *coal_tx __free(kfree) = NULL; struct scatterlist sgs_tx; int i; - vi->ctrl->coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); - vi->ctrl->coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); - sg_init_one(&sgs_tx, &vi->ctrl->coal_tx, sizeof(vi->ctrl->coal_tx)); + coal_tx = kzalloc(sizeof(*coal_tx), GFP_KERNEL); + if (!coal_tx) + return -ENOMEM; + + coal_tx->tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); + coal_tx->tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); + sg_init_one(&sgs_tx, coal_tx, sizeof(*coal_tx)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_TX_SET, @@ -4218,6 +4245,7 @@ static int virtnet_send_tx_notf_coal_cmds(struct virtnet_info *vi, static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { + struct virtio_net_ctrl_coal_rx *coal_rx __free(kfree) = NULL; bool rx_ctrl_dim_on = !!ec->use_adaptive_rx_coalesce; struct scatterlist sgs_rx; int i; @@ -4236,6 +4264,10 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, return 0; } + coal_rx = kzalloc(sizeof(*coal_rx), GFP_KERNEL); + if (!coal_rx) + return -ENOMEM; + if (!rx_ctrl_dim_on && vi->rx_dim_enabled) { vi->rx_dim_enabled = false; for (i = 0; i < vi->max_queue_pairs; i++) @@ -4246,9 +4278,9 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, * we need apply the global new params even if they * are not updated. */ - vi->ctrl->coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs); - vi->ctrl->coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames); - sg_init_one(&sgs_rx, &vi->ctrl->coal_rx, sizeof(vi->ctrl->coal_rx)); + coal_rx->rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs); + coal_rx->rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames); + sg_init_one(&sgs_rx, coal_rx, sizeof(*coal_rx)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_RX_SET, @@ -4823,10 +4855,16 @@ static int virtnet_restore_up(struct virtio_device *vdev) static int virtnet_set_guest_offloads(struct virtnet_info *vi, u64 offloads) { + __virtio64 *_offloads __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->offloads = cpu_to_virtio64(vi->vdev, offloads); - sg_init_one(&sg, &vi->ctrl->offloads, sizeof(vi->ctrl->offloads)); + _offloads = kzalloc(sizeof(*_offloads), GFP_KERNEL); + if (!_offloads) + return -ENOMEM; + + *_offloads = cpu_to_virtio64(vi->vdev, offloads); + + sg_init_one(&sg, _offloads, sizeof(*_offloads)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_GUEST_OFFLOADS, VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET, &sg)) { @@ -5810,10 +5848,18 @@ static int virtnet_probe(struct virtio_device *vdev) } if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_DEVICE_STATS)) { + struct virtio_net_stats_capabilities *stats_cap __free(kfree) = NULL; struct scatterlist sg; __le64 v; - sg_init_one(&sg, &vi->ctrl->stats_cap, sizeof(vi->ctrl->stats_cap)); + stats_cap = kzalloc(sizeof(*stats_cap), GFP_KERNEL); + if (!stats_cap) { + rtnl_unlock(); + err = -ENOMEM; + goto free_unregister_netdev; + } + + sg_init_one(&sg, stats_cap, sizeof(*stats_cap)); if (!virtnet_send_command_reply(vi, VIRTIO_NET_CTRL_STATS, VIRTIO_NET_CTRL_STATS_QUERY, @@ -5824,7 +5870,7 @@ static int virtnet_probe(struct virtio_device *vdev) goto free_unregister_netdev; } - v = vi->ctrl->stats_cap.supported_stats_types[0]; + v = stats_cap->supported_stats_types[0]; vi->device_stats_cap = le64_to_cpu(v); } From patchwork Fri May 3 20:24:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653409 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2058.outbound.protection.outlook.com [40.107.102.58]) (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 904F7158D99 for ; Fri, 3 May 2024 20:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767914; cv=fail; b=EYPpj0PV5X1j+gWVUlYbfHv3v8xwFQ4Loo+QWz5D0YBJ+W7CJgEZj/+FYr1Er2SrV/CXeUfmNNhBijnTboBFvkuO4vIh/juRSphtGeV41LYE2R+ghaP6PMYCThnrrY2AzjqSCOi/tTu3I8W0LDugUMv4331mQKFZBnCwLGGA29c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767914; c=relaxed/simple; bh=FR4DqlrFPSKTlk2ibZjIDDAigCDunNQxvbL2X7+5RnU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X4fCXbTO/gv1xbEQyq7QZ6qXL94Ji4ePbruq40WKiZm3jfk0Mr1B74GwryfNHqGdYNlzOh9OJ2p9u3JPz3/w/3QXFktcmrEqxvPE1YeAiQdw46F/kEesHRiRraBia4lOrAulZikFW/DDex9BQvfi6wL8ysT6vbBxKlzYry+OymU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Gl9jiinD; arc=fail smtp.client-ip=40.107.102.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Gl9jiinD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ODFB5S9Aun40T2QxWaUcQv6Ovfj+Y0EQNVNopHpWb5rw3nim2r1h/aElJumnnBvTTAtAu2WrvSqi3slfaJtHElAtoZKqo7KO6NfVVhy0oj/vuCbF+Iz4Rl+Os8DZkNj/xOxvbl0J2dvIZPRg06LCX4ag3SCrBbKchp/yAojmQJKVuPWxkd08SKNhtkPmqYf65Lne+FjoL//LjPlV3BL2eBkY9FAS9Z4UZEv6gRywlwRqYnIXNVuCGHfEN++geUGjIOZNxyRHoNIqZEchk+Z1+yaEtFUoUorIzQh0bToCdB+Kk6Ng8jMj5dcYx1AV3QyBnFDkcbIYvLEnDPyOGVrqQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T+LYEJS4WLRU7WRlBelprBuxLSx6dAQUkrnajZX5zuQ=; b=lrxvixRN2F6LTvToVOqGIwN6DG3jfj1t/DvmppLtF0FOJam9BwzPRK8W8E0l8CnxQBYqQscTAT2ORwJ37q5KMe5bwrA0F3cP791rgDezb4fmu2Uoo+ueTWkRCwLiI/TYUfo5QYqJNlEk1imLn1i6wzmS+V2wRHJw/JBb4yiVx4+k6cmop5XQR0m11S71dcbGY6LrZcFeskybZabXUTd99gYOD+rjL7EsmQIB9SAKv5adAnLp4kHtYfxv6qpRACiO6wJaTO3brqAEcu4XPP57LiohIpkTOahMU9iooW1Z3kxQuuGVONwsMTvKv6pz4oir1MTqxrtcHnioU6+YIIdaiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T+LYEJS4WLRU7WRlBelprBuxLSx6dAQUkrnajZX5zuQ=; b=Gl9jiinDJZD/WvjGX9QHd2wXrCf3uPmBkUODR9+/1k65hCBHj807gzlzIwtvOC/8OE8QBGGAf9pj7/HthFrh8sXIBM7icSoD3S8fipL7oWD8oAgR5bgCnp6IZAYoauYO5X2yIusszskDlJRHMtv57YmGmyjRWnD5vICAr4niz3JRaYUQBmHe5XgvnYCGdIcACCzXqIstauOGI6B3Oo1ze5hm0TjXge2z5Y1D3P/I8H7h6sXNRAfMpX2HEy4spSZwpa5YLLMVlPRtingvtkLhQHVJpdv+lx+i9v1Unc8nnROskZpugqNBRuSAINAQg5qWKloPX57ivmIXJh/36el6og== Received: from BY5PR03CA0011.namprd03.prod.outlook.com (2603:10b6:a03:1e0::21) by PH7PR12MB8426.namprd12.prod.outlook.com (2603:10b6:510:241::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.28; Fri, 3 May 2024 20:25:06 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:a03:1e0:cafe::10) by BY5PR03CA0011.outlook.office365.com (2603:10b6:a03:1e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.34 via Frontend Transport; Fri, 3 May 2024 20:25:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:06 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:53 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:53 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:52 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 3/6] virtio_net: Add a lock for the command VQ. Date: Fri, 3 May 2024 23:24:42 +0300 Message-ID: <20240503202445.1415560-4-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|PH7PR12MB8426:EE_ X-MS-Office365-Filtering-Correlation-Id: ea638019-28d1-41c1-23ee-08dc6baf1ef4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: YpABm6eMhORnRlUqT24nUfELacXOvYF2GxmhzvL5iTCjE48FFESH/manGhGDuCt5lXGM1p0Rf89iH4fA11yMf77EJNKf8WWTPqESYP5A4c2WS/3j+ocREKR9Z17wO/7p54VatX7UcLIa9uq/nXx4j2nsWrNZAFNSUhXIxorGmrCY/+9RIS3ckYGEKGDGqdlQ8Dnu6i2klxtDAiocBUchtpqPyJdcoUu8CRKlqjwZjomGrbpjpKryp5B2T+rJNdTtKdF82U9WpINlZshIKPCvA7xnz7Ismn3wgPNOFSjjf4jjz6N6VtJnviwxSGK2hZ+tkeHyjl4wHrmQRwy2AhWb/7HBNfc2wRQlSeYa3CNZxFPvHi7qLrOm6aRFywpI7UvFavDgzOFjFTcijMs+l+YeYck51CSaghiiP9gdcIRhkBRH5ekzft3wQEe4llxPv2jre3RU9TNyzP5NZOrr75GosCatMiLVTMbU2PAbDe5xDczoecDfp7/5IDF95quoH9vzizD2zYc8m5sq6Emo6EZJWh0/WrXhVVTplVnMNxfxUlzesBNUePOSpIhsA/X8PkxpO481PW+why/KexfvCfnEt9bC8DEMFSIKYBHcjLLCU/kFWTePnlXnksN7Mm0hw6Nsb3sdic/TkLnqz7fpaED5CYMFkKro8Db/296zhxNYgU618UcH4cbEta3B12Gy5OvCOnf3Vit9LdKHChSBPjd1SLsMMqHgqPEW3/vMzdWmEJ87GS8dfzsTv/pMU+cyZR9saxK9/MI+pNBlrag7OiY/KfFjTztQ6acC/Gojnmt7zrBuHEWbJbjiNIshu3R+JqNa5htm40tKGv6qwSpFlyHNW9rJHE9CSs+63PfUqbvEsbZXi9bzx/BCy9LukWev1F8TKdfpDRvpHwsiA7puVqISlpF/Wyh0T6fEC+h7uA79I0bXUcOW8XUVBV3iyPQAEo6npbJBQG50vn+pPZQdj1XQhXXwott94+KbTLwbARVktctiaa/Zwsf7I3FL4vpFpre3HtDItr3GkUdhoKcixq65asG/wzPE6IAm8DgvJq0fQLaf3HVkeIUTOSSjHmQHKQSVWL38w1LTcaDG3Km9MC7ZDCk5In5ZoALrowFJT8H8HN0j+F9LLihC85WDo9tqBYB8b+RqJNOtsxqXsy6cmWBLF1gigDTR4gyU5vx+NkSoH3Cd60ys7/stZWoWQ7nm6j7yYACYF4S1FNMOCDbCCEYfYrXikB9mxizMVq5aC4YNL3iU3zlhYOeQ2Td+L7Sohapxs7usL2aB/9eP+sXRf/cs/1LD3wYkLuz7RiFRA1SQuYY9XO1cr/dSbmWMezDvP4A4AZ6Z9Xpity54H2BrFG1d7Yn5TPaDgxWS592Vit+lBhq7ZLRZwKGR8H2zdnr30ho0 X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:06.1595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea638019-28d1-41c1-23ee-08dc6baf1ef4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8426 X-Patchwork-Delegate: kuba@kernel.org The command VQ will no longer be protected by the RTNL lock. Use a mutex to protect the control buffer header and the VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 451879d570a8..d7bad74a395f 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -411,6 +411,9 @@ struct virtnet_info { /* Has control virtqueue */ bool has_cvq; + /* Lock to protect the control VQ */ + struct mutex cvq_lock; + /* Host can handle any s/g split between our header and packet data */ bool any_header_sg; @@ -2675,6 +2678,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd /* Caller should know better */ BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)); + mutex_lock(&vi->cvq_lock); vi->ctrl->status = ~0; vi->ctrl->hdr.class = class; vi->ctrl->hdr.cmd = cmd; @@ -2697,11 +2701,12 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd if (ret < 0) { dev_warn(&vi->vdev->dev, "Failed to add sgs for command vq: %d\n.", ret); + mutex_unlock(&vi->cvq_lock); return false; } if (unlikely(!virtqueue_kick(vi->cvq))) - return vi->ctrl->status == VIRTIO_NET_OK; + goto unlock; /* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. @@ -2712,6 +2717,8 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd cpu_relax(); } +unlock: + mutex_unlock(&vi->cvq_lock); return vi->ctrl->status == VIRTIO_NET_OK; } @@ -5736,6 +5743,8 @@ static int virtnet_probe(struct virtio_device *vdev) if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) vi->has_cvq = true; + mutex_init(&vi->cvq_lock); + if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { mtu = virtio_cread16(vdev, offsetof(struct virtio_net_config, From patchwork Fri May 3 20:24:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653408 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) (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 76E05158D9A for ; Fri, 3 May 2024 20:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767913; cv=fail; b=L5g5xk5gFKN0xuPtjrcWY70dzVJY+2ctwqCMKDa7tjtwX3qhWebGF3zNGwFNwolldnqYVji4BR6+8m9N9iDsT+sBkIkjAOhZeqWFIOFKQDi0hp5uAcV09L3bLjZAjI6MbQwKZ0V7b9oZmH2DVlIm+Ov4FtKjrmdteaRsmn5ky0A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767913; c=relaxed/simple; bh=BNQA0K8t/h2WEJmX5esJLqX5EbVUtBtGRGXFHsghqjQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BADY8TTkeCUQb4lQK4GPb2Inh8fZR1D4c9xXR7dVP4PR358+mZW9CKQimIUr9txF3p+2NR2OqKtDxKx4dfwDVJbu/hxz0h2dn+goM47FVXEFfbm5+J+wprhotgyOJjrM7BCR23rPS6lvJpHoAoNDrYe1hbHHZ+zUTyzRLXo/fsw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=WdrUCgTr; arc=fail smtp.client-ip=40.107.92.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="WdrUCgTr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBAde0dsaDZ77YzxA3wTO9h9bGFt2kN3JCXusS1ygLFbCySnOITT0+zIAxP3sdD5r+tXOv0f/KOty9a6Ort5a4pCs5XqK5rbuwVbnj4plKqYXiMP8k7Mgw0iqaZ8NsWrB2mFHkqLGIUTkRqRC/ZGhd5MYi5HT+Z9OZWIC2fThFrwEsWe3ktp+z46rgRJMVhxh80CULm6arl4i9PiCQsmkDp2cQEcZ9TE1lrIZ1nc7URPtk7YiHsAz6pjb9zIpg7IVhAbnzAdII8VJg4vQp4kom6E9rNWxrMHsg8eLNJUTZEhm60FQlOIDvZQEQ5+Py0wfd1SGRqqGvH1S7QvfwVWRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Uj//Iwn9b5WqGZ60URc+2vucVHKJcIEa3EXV0FG/jiA=; b=jV2jZh8fIA+H4vGWMEVZngOrkAGdsaMB7LaXGEAFJmFz1BFUljCpH3I+M9AzW09J0llA6BY2s6NeMlKvKhIopa/a8alNhs63QlPUd6b9Bc8HsgKzsI+we6N+zj4NsTOo/poOVzI+RTUab2JeWVkVAThrUD2NgP7P6FsfKFSn1090G2Re7NYG+nbREb4EYJYLDZnp93a3wg5SYE8P9pQaKm4B376t2K+wZilUHto77UTlQNoNPBU5Z5ZzF+aHGikVED4+jZ+RLsoG7m+yahWM8nX2XUTJUwUfgP2o2tb4f1rIZ870RzliKeMxR6VEo6T7KIxosoSX07S8C7FUq6hugw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uj//Iwn9b5WqGZ60URc+2vucVHKJcIEa3EXV0FG/jiA=; b=WdrUCgTrB0YCWWdu+sPDivrc+JZLHT5eW3kq2JlUz3HVzgKxJldxCrrijZkCLMjqpzTaGnrL3tdIA/BdBBdsDghlT44JnV6t8BIuqFU3zyrAtztdhWJQReeLoTb7P6sPElZyXwoKk0ecENq+vU7ePiVmhmzOj52FBCVt7Wx9XcIYHn7ifkvDJQmY6+dWnj/O0SzK3ZXztwDzzLsyVe2mTYUuIUKMKbONn2CTsVjY/L4F30sT91Zx3odhzFS9qmxIl9R1srX+zNjPO8SdIuBzHIe0KDjNJQc7Co+QSeXXHQA63iofLZvDkUbq/8xh79Dbe7XgmXhUxbF3jn+RUYxGZA== Received: from BY5PR03CA0005.namprd03.prod.outlook.com (2603:10b6:a03:1e0::15) by CY8PR12MB7516.namprd12.prod.outlook.com (2603:10b6:930:94::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Fri, 3 May 2024 20:25:07 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:a03:1e0:cafe::95) by BY5PR03CA0005.outlook.office365.com (2603:10b6:a03:1e0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29 via Frontend Transport; Fri, 3 May 2024 20:25:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:06 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:54 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:54 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:53 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 4/6] virtio_net: Do DIM update for specified queue only Date: Fri, 3 May 2024 23:24:43 +0300 Message-ID: <20240503202445.1415560-5-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|CY8PR12MB7516:EE_ X-MS-Office365-Filtering-Correlation-Id: 666dc3bf-018c-4016-f85d-08dc6baf1f49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: DE3v3KWGLxprVY5BES64e2yZzYPfmUr/6E4xcwy+szRsA6H+lzm7M6RMrhBqSj2faaP+fdV3LP1Erhm1FAlBZY2isbx6cet0yrvBL4ICFL7gfINTfTtwrQ/tEmes7B7Vilbrx3w+eNrofgQo16Yio7F+VCcu02kXRPhkW5Mq/FmayKjq+6Owhur1OpqpMhG66SdyApeyIR9HCqQ99I7fXKcbDRUoz1ZRVWg8SNCUSNhPX9t5oKLKSpL/gQW2l/o+y/duN2yM/dbj4yoMDcRpu/YHZEqttmeQKlXHhkUlzsDGO18uI0FUz6j7Ctl8ZTio5UNrN1ceo1MlBvtoz98N8KhKrgbws0tvSSGNvcChWSwInQmRZ85mtUjCR9PTPwwKzEYhuQ1PI9RctJ6fVMuMOX+GJzR1hEuDD1ckbKFXkj7Mi+0/DE4gBza9RO5ycO4+umK1p8CtlyagDYWqv/3jDw3rWVSQ8MiizkwQGqSHR57nefP0Nb/hli2OP25jIQCLCToLPPBcpqXizJ4/5YCkHrCpNzixzYpYWwTu0hW0iWuYrmCccJBAEXTzII6rL3c6zAtyu069m832x0iunX77dQrNEAGGPgr4kmtkVerJom9xlNZHuJ88g3SkbJ4wBQA3GMM8ZSPD7m9F/G6MBnIcrxI+g1/ALWbPDC6URyBdG3aVYzJuKpxD/b1oStw9NjO00cnZ0Bl1q+nxXFXQ+TFSD50G3c5y0FVJmYyPU9tCPMalcr8m773GhwYaDw6eEDNSvYktVicYlBZFdSbuf1msIrFqjjkMNnkotfq9eRDhcRP4foj7DcDa6ZkvS77Gf7kJRkNMK9AIG2h9a47SzT8Oh523nDrtnk99u0E1nGeGeJdTl3P/jdm40xHDb17utecetTN6VA7+hcnL8k0tZvL2mCKt/5OViHiwgHs2mZX9RPTyIPe4EI5hfWXvJnm6V84Gc0JFmHqMONND4vy0ti8VT+0nxqQyK4UUxbu8IyMeOhWuVAe0SOF5CtSVcvS2CvUd5z0gFfVYgsEy5qHxzYQ0Np055JiTWN9ihRh8jqQw3d/EfvI1rDCdxmVyUmwOds/KSJxXBBSLJ7ZhTxwiPmRVsrGsqCQ9e1YABI0uX6anz/eVNr6n77mjVVMeglSADKEK2kuDoe9IPC/V6/9lbdMeWb0TV/qdfhFmdF2qHuYwOUL8y93Su3qwmfCf2mcjX6fh+uerjU2SbK+wGdw8v2QSNRrltZ3pbhlwyar//0VfHpgi/jWXYHoF8AdtHLoNNX3NkggC6YLXTLXEWhkEW4G48QTW9PpxMi1N4moMm3YXpZnq3YhGdsLyhC0w/BbFpI8gIBF3b2P+CJwVxHn+169jyak3AKokLkVXTOARx55d0YsE/X839nBZq7BeiGiUT6Un X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:06.7220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 666dc3bf-018c-4016-f85d-08dc6baf1f49 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7516 X-Patchwork-Delegate: kuba@kernel.org Since we no longer have to hold the RTNL lock here just do updates for the specified queue. Signed-off-by: Daniel Jurgens --- drivers/net/virtio_net.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index d7bad74a395f..386ded936bf1 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4383,38 +4383,28 @@ static void virtnet_rx_dim_work(struct work_struct *work) struct virtnet_info *vi = rq->vq->vdev->priv; struct net_device *dev = vi->dev; struct dim_cq_moder update_moder; - int i, qnum, err; + int qnum, err; if (!rtnl_trylock()) return; - /* Each rxq's work is queued by "net_dim()->schedule_work()" - * in response to NAPI traffic changes. Note that dim->profile_ix - * for each rxq is updated prior to the queuing action. - * So we only need to traverse and update profiles for all rxqs - * in the work which is holding rtnl_lock. - */ - for (i = 0; i < vi->curr_queue_pairs; i++) { - rq = &vi->rq[i]; - dim = &rq->dim; - qnum = rq - vi->rq; + qnum = rq - vi->rq; - if (!rq->dim_enabled) - continue; + if (!rq->dim_enabled) + goto out; - update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); - if (update_moder.usec != rq->intr_coal.max_usecs || - update_moder.pkts != rq->intr_coal.max_packets) { - err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum, - update_moder.usec, - update_moder.pkts); - if (err) - pr_debug("%s: Failed to send dim parameters on rxq%d\n", - dev->name, qnum); - dim->state = DIM_START_MEASURE; - } + update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); + if (update_moder.usec != rq->intr_coal.max_usecs || + update_moder.pkts != rq->intr_coal.max_packets) { + err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum, + update_moder.usec, + update_moder.pkts); + if (err) + pr_debug("%s: Failed to send dim parameters on rxq%d\n", + dev->name, qnum); + dim->state = DIM_START_MEASURE; } - +out: rtnl_unlock(); } From patchwork Fri May 3 20:24:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653410 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2050.outbound.protection.outlook.com [40.107.220.50]) (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 A712F158D9D for ; Fri, 3 May 2024 20:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767914; cv=fail; b=uJAAIiYW9m6x8LO7gsdTidtjFeNFIW1mJvICDXMJS/379QsGsRPlwz+7gJSQZYvVY4hckGAzqi/zmBzgD6rxj1k+37z60haZL9ahkZ/CNJ1DoLhCeJLeIj9KPlvCq1yDc8UQv0ypfipXtOQ+0PSIKNQd59uVkK7t8qn4J8OICQw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767914; c=relaxed/simple; bh=20scjcxqKg6UwodT1G4a0xGYvpRZAJm3L7HeSJ1G7vk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S4VZT6GbnH/4emrlHq4rpQ2+gM14ZHxhlY/BIcj3Kh/81w54wSV2ve/d4tX54RCn8cNeW4rcg9BGYfuClEND9EYxWWsAxItMO52qbZUZLHy4bA8qdZGBrhB9U8LSqHWyRtBGNAW8FcLsd3F/mVIYnLk5iiqjNQIHyNG8ertRZvU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=uZGlmNmN; arc=fail smtp.client-ip=40.107.220.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="uZGlmNmN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hd/fZfOmbFWSFeNu0KhDzg70qiEZ4IYWU/fL90BaZ6/4a0r5XDQ5RNEoRDczrdoTbLLzlaZeQSxY9cvyNDmX5orHSXxZJTVft9hJkYZnq3qrGl+TSk6OVqEwOsuz3PIY1dkfS9VeRSkRkg/V+U8hdImyg1ogGbNa0//zIzORXXyfDucYSTktFZ+sR3BhpdKPkuPEByvoOzCPY3NGC6VP04EoHK7ZdDNE2OzqPARciMkcv2qGKhes83lGYQ3vNap52ir+UJPx9ww4/rNTSkev8O3QeQ7TdjcYBUnJPIsvuQf1cursIcQXixsN1PSq/kh1vMqI0YYgiDE0QdYY4MXdrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5xHR1GTHlfgmFu/rKfdmXEmKE+lNJ964tSnqFVzqD+w=; b=IhLdpi85wO9jLhSVn8jKhkMDyQpaWgFuZDnTtjPr/ICfsdPDNy/qX/rup56t9EqyPcaQkP+g6sLFBsrXi+Pyec2FtPI40939MInN6DcXx910sr3zBVmtU8dPsAzDbXsP0BZnexITlMt//nhBtEsCjneQYRDdSNo8DoWiNEBDXjHMriyduK1H8U09pDPU3XTv2qnluCbeS0LTvczbkVOe+dFcuPgpHILPVFuu6Vl+aX/NHE6EVaJgW0aF5gufF9tAfdTroIfsZ4ZewL8bPxXp8PNBBOr6mvfT3v+yVRzDRI6rJAMDRWsqSfAZH795/jvXcZRBaoqHbFrobbVfv/YGDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5xHR1GTHlfgmFu/rKfdmXEmKE+lNJ964tSnqFVzqD+w=; b=uZGlmNmNF6EQY07UePF121brM1p/ZHiBR2x4KJU+TfqTnQwCsJ/AGEMdRMv/JwXqrlc9M7cdo9sK1UTnVUeI9DDh211fniDaKemOqpeRbPMtLr5Z0zY2HxSR7U8e0XnutjYXg3GqoKHxlRtUvIdWo4F3s601L1D3MY6bJX35OPsNuB1yDmVQyZYmS8ZBDcKAjcud8NmbohzAN+6wCUehp3yCWrCsrKGZK70syNK4jGskokLC7S5qftWOe5YJCybAyMqjCquT1FarhWvxMVdgaKeDmhu5fI7hmoYKpKjcukobeGPtIbeyfxCQMQUAJR4xgHcMja9V6PnRg+bNGSbrgw== Received: from PH0PR07CA0035.namprd07.prod.outlook.com (2603:10b6:510:e::10) by DS0PR12MB8344.namprd12.prod.outlook.com (2603:10b6:8:fe::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Fri, 3 May 2024 20:25:08 +0000 Received: from SN1PEPF00036F40.namprd05.prod.outlook.com (2603:10b6:510:e:cafe::7b) by PH0PR07CA0035.outlook.office365.com (2603:10b6:510:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29 via Frontend Transport; Fri, 3 May 2024 20:25:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SN1PEPF00036F40.mail.protection.outlook.com (10.167.248.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:07 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:55 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:55 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:54 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 5/6] virtio_net: Add a lock for per queue RX coalesce Date: Fri, 3 May 2024 23:24:44 +0300 Message-ID: <20240503202445.1415560-6-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F40:EE_|DS0PR12MB8344:EE_ X-MS-Office365-Filtering-Correlation-Id: 00e5cc57-20f6-42c3-ac8e-08dc6baf1fba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005; X-Microsoft-Antispam-Message-Info: krw1j1bPLG1hU0Ve5EwV45zlEPLINJTS3Xx7WZbyP7rp4qKQoyxvgxGtM4rb64yNIlzDyQZxiUEmHckLFjo4SKxmXL03DRLvn2lzfu1ofWfI/+J4dbO0gAjFex4fi+CpZhZdJ+bus5NDZYt4GT+g2EpMe0tH59C1FPp4CpSVL9P2YPI9yqDeV19TvK6HDgowCKq/nAchVd8dHt13C7ATRSJMeiWL3SU1SawLWxlB05cmNfauiaImom0jViDh5nirKlp2roXJ+IDxwlpxsTESEfE4120D+wR4uG+T1xo/apGeO8X/yHxWhGzi9NSLTn2j17UMNealMl+jIQRYFchpIk4wvPxP/r44KO1216179RDEX9iRmiX1r4sLwury3OeXjcd0/zXtYlp0hmr0vW5ladr438q8VbKiKUHQCFlYYKjRVFvijfn77ATy7UziDeHkf4UQjEc2jXfDQZJpLu7X0rYoGQ9ylVuT7oVFylUibzwlcfqObjhzhI9n6fe6Y8bwQbwF3roSd+D3GtJ08/SuokvCpbKESn/xF07C6zgR2Q03O2DY1met4edOyJa8sUsAtKe0Mr3rxa1psSJ2Yomep2I9/to7A/jYClHCrkknhztwTQRQH4JgLbnRg0Glz+o4jETehXHmGWfVG7YCPow8vTgMOc84+yrFCjsaseYsLMVHaYd2DY8XRwTCNEJbV5zfKcCnkgZyj7gjfieMU019GWPY1mAcqWSpEL/7rNCx/iUyqMpW/AzEcOU3sz/y++JKxNI0SkxHI3SevG/gwLjwgbYoCz5hBDT6vPgQTAn3AKpTdIqlBWJ/ns0GIputAcH24gaBSQ4w7dYl3KdaWSHXY85ssy7aHh4+ViqZ2v0MmAXQAVnHP10TnEAbmrQsgPyvI0+NMpHVgfCXwI18cy9QIcxb3tYVazM1FPtxv15huo7q5DSwg5L1O6MQpC3zXVTkEymYJIHEf2FYypMsPWjLmn3UFKtaq09/E9lN9lX6liF7kPzHEU4KLCNQDePWrEqbVj5LVVh7G6ZGSP/rsrcK2quSRrwErM6kWDQaZsquJoqMYw5gCZWxXxUrzZAyy7qJlgAbGBqHA9rdE89/+Z71VhoCOOIE46HWqcp8yiuI8mkKo0UFn8zWCNe2Lw9HMWgVjy4WRYXl/xO+YCW5VH4CmkLeWbJYbMqrODzlPnrg49h6fC4cqX8+XyWbzLpNVuk8yF/qc8MCffTahVwSKnBBpZ1utPaNByCWUQd32sEvconHN7DruirHhjC0rwzuKlv7s83ZmFaB6l98yVI/sDZLYOMUZ2j4Mu1APgjCY18C0DcXX8K6XmF+PXSeCNSqkDIvyvOuJ+Rzc3DW4TGnRL5Vng5OaoTlat/VFnMOZ+FQNIwSxLxZUfzO4odaS/yvV6S7 X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:07.4606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00e5cc57-20f6-42c3-ac8e-08dc6baf1fba X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F40.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8344 X-Patchwork-Delegate: kuba@kernel.org Once the RTNL locking around the control buffer is removed there can be contention on the per queue RX interrupt coalescing data. Use a mutex per queue. A mutex is required because virtnet_send_command can sleep. Signed-off-by: Daniel Jurgens --- drivers/net/virtio_net.c | 53 +++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 386ded936bf1..a7cbfa7f5311 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -312,6 +312,9 @@ struct receive_queue { /* Is dynamic interrupt moderation enabled? */ bool dim_enabled; + /* Used to protect dim_enabled and inter_coal */ + struct mutex dim_lock; + /* Dynamic Interrupt Moderation */ struct dim dim; @@ -2365,6 +2368,10 @@ static int virtnet_poll(struct napi_struct *napi, int budget) /* Out of packets? */ if (received < budget) { napi_complete = virtqueue_napi_complete(napi, rq->vq, received); + /* Intentionally not taking dim_lock here. This may result in a + * spurious net_dim call. But if that happens virtnet_rx_dim_work + * will not act on the scheduled work. + */ if (napi_complete && rq->dim_enabled) virtnet_rx_dim_update(vi, rq); } @@ -3247,9 +3254,11 @@ static int virtnet_set_ringparam(struct net_device *dev, return err; /* The reason is same as the transmit virtqueue reset */ + mutex_lock(&vi->rq[i].dim_lock); err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, i, vi->intr_coal_rx.max_usecs, vi->intr_coal_rx.max_packets); + mutex_unlock(&vi->rq[i].dim_lock); if (err) return err; } @@ -4255,6 +4264,7 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, struct virtio_net_ctrl_coal_rx *coal_rx __free(kfree) = NULL; bool rx_ctrl_dim_on = !!ec->use_adaptive_rx_coalesce; struct scatterlist sgs_rx; + int ret = 0; int i; if (rx_ctrl_dim_on && !virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) @@ -4264,16 +4274,22 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, ec->rx_max_coalesced_frames != vi->intr_coal_rx.max_packets)) return -EINVAL; + /* Acquire all queues dim_locks */ + for (i = 0; i < vi->max_queue_pairs; i++) + mutex_lock(&vi->rq[i].dim_lock); + if (rx_ctrl_dim_on && !vi->rx_dim_enabled) { vi->rx_dim_enabled = true; for (i = 0; i < vi->max_queue_pairs; i++) vi->rq[i].dim_enabled = true; - return 0; + goto unlock; } coal_rx = kzalloc(sizeof(*coal_rx), GFP_KERNEL); - if (!coal_rx) - return -ENOMEM; + if (!coal_rx) { + ret = -ENOMEM; + goto unlock; + } if (!rx_ctrl_dim_on && vi->rx_dim_enabled) { vi->rx_dim_enabled = false; @@ -4291,8 +4307,10 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_RX_SET, - &sgs_rx)) - return -EINVAL; + &sgs_rx)) { + ret = -EINVAL; + goto unlock; + } vi->intr_coal_rx.max_usecs = ec->rx_coalesce_usecs; vi->intr_coal_rx.max_packets = ec->rx_max_coalesced_frames; @@ -4300,8 +4318,11 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, vi->rq[i].intr_coal.max_usecs = ec->rx_coalesce_usecs; vi->rq[i].intr_coal.max_packets = ec->rx_max_coalesced_frames; } +unlock: + for (i = vi->max_queue_pairs - 1; i >= 0; i--) + mutex_unlock(&vi->rq[i].dim_lock); - return 0; + return ret; } static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, @@ -4325,19 +4346,24 @@ static int virtnet_send_rx_notf_coal_vq_cmds(struct virtnet_info *vi, u16 queue) { bool rx_ctrl_dim_on = !!ec->use_adaptive_rx_coalesce; - bool cur_rx_dim = vi->rq[queue].dim_enabled; u32 max_usecs, max_packets; + bool cur_rx_dim; int err; + mutex_lock(&vi->rq[queue].dim_lock); + cur_rx_dim = vi->rq[queue].dim_enabled; max_usecs = vi->rq[queue].intr_coal.max_usecs; max_packets = vi->rq[queue].intr_coal.max_packets; if (rx_ctrl_dim_on && (ec->rx_coalesce_usecs != max_usecs || - ec->rx_max_coalesced_frames != max_packets)) + ec->rx_max_coalesced_frames != max_packets)) { + mutex_unlock(&vi->rq[queue].dim_lock); return -EINVAL; + } if (rx_ctrl_dim_on && !cur_rx_dim) { vi->rq[queue].dim_enabled = true; + mutex_unlock(&vi->rq[queue].dim_lock); return 0; } @@ -4350,10 +4376,8 @@ static int virtnet_send_rx_notf_coal_vq_cmds(struct virtnet_info *vi, err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, queue, ec->rx_coalesce_usecs, ec->rx_max_coalesced_frames); - if (err) - return err; - - return 0; + mutex_unlock(&vi->rq[queue].dim_lock); + return err; } static int virtnet_send_notf_coal_vq_cmds(struct virtnet_info *vi, @@ -4390,6 +4414,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) qnum = rq - vi->rq; + mutex_lock(&rq->dim_lock); if (!rq->dim_enabled) goto out; @@ -4405,6 +4430,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) dim->state = DIM_START_MEASURE; } out: + mutex_unlock(&rq->dim_lock); rtnl_unlock(); } @@ -4543,11 +4569,13 @@ static int virtnet_get_per_queue_coalesce(struct net_device *dev, return -EINVAL; if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) { + mutex_lock(&vi->rq[queue].dim_lock); ec->rx_coalesce_usecs = vi->rq[queue].intr_coal.max_usecs; ec->tx_coalesce_usecs = vi->sq[queue].intr_coal.max_usecs; ec->tx_max_coalesced_frames = vi->sq[queue].intr_coal.max_packets; ec->rx_max_coalesced_frames = vi->rq[queue].intr_coal.max_packets; ec->use_adaptive_rx_coalesce = vi->rq[queue].dim_enabled; + mutex_unlock(&vi->rq[queue].dim_lock); } else { ec->rx_max_coalesced_frames = 1; @@ -5377,6 +5405,7 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) u64_stats_init(&vi->rq[i].stats.syncp); u64_stats_init(&vi->sq[i].stats.syncp); + mutex_init(&vi->rq[i].dim_lock); } return 0; From patchwork Fri May 3 20:24:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13653411 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2069.outbound.protection.outlook.com [40.107.236.69]) (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 8F4A2158DC0 for ; Fri, 3 May 2024 20:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767918; cv=fail; b=sAkJ4ANEB4qpAQCJOfidFMP0Mn/IL6qzgYAOEvRAfvYvWusUoMv6yTUeOfJke6rRe/dUEKHaSQ0NhXFVwOxQDiAg2m+iYFoXfGjIHoc/5m/8rMW2qtbaSd6yzSL592S5lSUEHxC3gf3QIl1ipS+SXXsje6Ev9d8Rdka87wzvgnI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714767918; c=relaxed/simple; bh=0Ts2WNzVC8WO5gSsjMbGsZrTBumQhTX/cnFj/kGG160=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D7MdTFmHvIwrhb/SZP9+TpGGZBWB1sRfoFWjh8Wvg8TEmm0APBc+hHTwAjvXA6hnm5o4u3h3vy4cDSikIETAQ68pMtxr3S6KtUkvbEbrB/eQMDQYo0F0vrgbwDdf6tBPw8f84obd5hKQAyf7RkIG5I9T9we1iXnlDQCEETC+kas= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=CbY3QYaq; arc=fail smtp.client-ip=40.107.236.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="CbY3QYaq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FAYqaQk6eOJozdsT8igQC3NRBkG0RLQBoibK6ubskyVmpYI6bp7FBJCXMyVDqQ8My0LJuFKK1ifUm5KDCRoms3t3kdeafBq/M/jjrR5ThVk0uIpEHg1ebF08BkaS237Nt+mLGt2CeU+4NcBao12PwQ9xcWHu7TclhaH3qwII6CGR0hP2GLM0vsQywinFEcYGLEJk5jJd6pd3yDGg/P36jijfK4j8u5f0phgmEuExcFs4s1L9naP1icegykxKcf1pVodxmS7UkqC4MQDS7aoKNP6n8aMJr5+Gh0uAh8aBMm0ij8OmQ+G5VVtDMD7UxEKWzMWFxfEeGitmbcHTL4q59A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ICKA/sJ1pDK6Be1rmZXVmAgMOusoM/v6AkqMs6trNsk=; b=cnXzZtEuW8NDR3CxZDzkhJWEipz6fAESzMiJJ3L7o/RgYTdox+270KPYfjlgpxcJzBXj/spmIFjk/cZMMCVnNQJYsy37msjpIkFmiV8acFur/6oraPI3i6NoYQOx448Jh3PeEQ3IM/z22JhY4jjnG2OA/6ELSAXzvPBPt4d9r6l92AUmbogz5PDr1CyEsXXoL7i7Ur4mTLwlGUFIJ2Nt9oVVEHX282LMmqzucpsChWpeS9ca3sTU5KXLyWy2EZdtuaEIc8V7F29kMCgvk615jdyiFXjuBb1A4H0hD9ovIv6eQHQntYbBJRbu6+WS7eiT2AfalWolZ+jR1ok+U2AI3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ICKA/sJ1pDK6Be1rmZXVmAgMOusoM/v6AkqMs6trNsk=; b=CbY3QYaq8z0jl2neayspLCXBgyCETqxAAlFXipq1iw6SxLc25G/XgStwvBiJz6ipNhG1U1XBefVber50U/6fji0COFmjDCEOQRzvowWzXINGYnL6Hk+5J56z2CQjC5ad2jgR2p/R6JTm5/q6x9lUb5URM02O1ms620rdv37KsvECNt3jgLNbPIooEjgkCPiAOiQX6LusJrKUE41NEbrxjrRw1d0KtzSIPR9zMzJneYt8PNLUlrrsvYOdbmKcSPXs+B1Qp4YfY25XC6EQatc9Hrg1huEsaDmaX87oEgzil9uTQd2Ow+Q/Kk4Lr5LKoJ5sZUPslUVnxUBOQ0iWMay9Iw== Received: from PH0PR07CA0044.namprd07.prod.outlook.com (2603:10b6:510:e::19) by PH7PR12MB8593.namprd12.prod.outlook.com (2603:10b6:510:1b1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 20:25:09 +0000 Received: from SN1PEPF00036F40.namprd05.prod.outlook.com (2603:10b6:510:e:cafe::82) by PH0PR07CA0044.outlook.office365.com (2603:10b6:510:e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30 via Frontend Transport; Fri, 3 May 2024 20:25:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SN1PEPF00036F40.mail.protection.outlook.com (10.167.248.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 3 May 2024 20:25:09 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:56 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 13:24:56 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 13:24:55 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v6 6/6] virtio_net: Remove rtnl lock protection of command buffers Date: Fri, 3 May 2024 23:24:45 +0300 Message-ID: <20240503202445.1415560-7-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240503202445.1415560-1-danielj@nvidia.com> References: <20240503202445.1415560-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F40:EE_|PH7PR12MB8593:EE_ X-MS-Office365-Filtering-Correlation-Id: 983360f0-fa89-4da9-b5a8-08dc6baf20c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: vSd83jbahmPwusISXnWxqnoSHSLLMV2QXPjjoPYUGNT9VLDMK0K7+N8FPDA5Sk9Kn8zu0mxsAT2UgUzBqyNorzXTTw8WfDv0Wl0sNKu4wBfxb1vRPO7WE/qw9VAhI+93IwalOCcBxC7eAnzQ0YglmXwOi3leceE1EOPeIRsb0FRHTEoEpxoCQ/wDQJa09NeD7oTWYgzqYaQLX6vR09a56j5iRbE5S5t4nqTmsaQ7kB4SMrb7U5ceHc/Wd/ijetCL6YILdp/XjhiFe48A/KSixebG9Jf3UMpFwE7WS9jda2rGJGxcETyX0GjsUT2QriZdpxShPep2Vh7/MAOBb+OI1Qr7OcrckG66ddEGl3oNxFOeFTDKuJvv9vYZa90DTNh/BmETi0KAGGmtKBWxa8LkntGrSB/CDyzFfiJP3jei+48NgveAH0BKb22NHCFL5ifpOsHsg3ZiOjet5gGeErQ37H2qY+9j1SpA8VGhcsRxuLPDkLUk4+IZlxfMWf2GTNU7u4+cgxA51A6+RaAzFTHIXxcJgGpp8FAGMCKcH9WAkbYZHluIm4X+56lCKlHpm0N7kiRL24tfGS/ZB57PBV73Zn8MankCyOlO9FDsj0P4keU6mXk8Uy++skh7wftE6WfFQgcqFg+tV4edwv/sUUEO40J938gBUm6m+MSNdi8ASysoXGzdn7TkUZSgCZu+PsWhiY6EDZBbHh8xEYL3Bw36Ky8HRWwEaGSFJUfxA18TpWuaH7kQdEgm6zzIyEmFJev6ewNEY62k4FTNH8heLfdANlbk2uCgHUjPdSwnV2JkU5sHMq+OAGK0lFgjdg3vnLcMrYy2yeMe+8WyToFr9Y96+vXgYo+LNfGgUJ30v3pxxoDyatOKMgqZnY/XuW8kIGbEdrFuBD2kfd2YFIH57qHv9nZk+hlYPEjcApJ1YnrMlm/tYBAvwlMKO/Z93mrrVgroaPfv3xYDol1/3JGqIyFsXgO81JugP4g0UB1w8p3z5RLK16hP4scji02oLWgIDzOo2FNU8YQQF8imsew2Ew++QbQ/hyWRpHTje7KAqc3gY8sk3d7YaZbTALShnQu5HYgVbEvyrrKF5WR5DXdBf8qMEBcghe3dya43NE4nZxGMSXVw0M3w/OxrrfJeS3KJmuuDHOU+PAlAJjmOrZPBZ3JWQhpCN953sYOcG0iQjionH5wPS+Rv8CF/fm6bK5H4Oulmyew4naE8RkW6YDkpHQ6lvVdiVrxZhOUPfaXiNjy00LJGgHnD17aJr+ASMG4S+SVyDpA3eylD2sDbbY0iKIUrSsVwTShZGHxjAPz/cGvMemyrvlTVWjF9vT5D+CkSPgMT3wJcXVESvDunMbB3dDp/SaKLA9OCVFJQ56NGkvHT3quNRaRhvJwiCx/yoY+vRjfI X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 20:25:09.2107 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 983360f0-fa89-4da9-b5a8-08dc6baf20c5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F40.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8593 X-Patchwork-Delegate: kuba@kernel.org The rtnl lock is no longer needed to protect the control buffer and command VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a7cbfa7f5311..218a446c4c27 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2824,14 +2824,12 @@ static void virtnet_stats(struct net_device *dev, static void virtnet_ack_link_announce(struct virtnet_info *vi) { - rtnl_lock(); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_ANNOUNCE, VIRTIO_NET_CTRL_ANNOUNCE_ACK, NULL)) dev_warn(&vi->dev->dev, "Failed to ack link announce.\n"); - rtnl_unlock(); } -static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) +static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) { struct virtio_net_ctrl_mq *mq __free(kfree) = NULL; struct scatterlist sg; @@ -2862,16 +2860,6 @@ static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) return 0; } -static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) -{ - int err; - - rtnl_lock(); - err = _virtnet_set_queues(vi, queue_pairs); - rtnl_unlock(); - return err; -} - static int virtnet_close(struct net_device *dev) { u8 *promisc_allmulti __free(kfree) = NULL; @@ -3477,7 +3465,7 @@ static int virtnet_set_channels(struct net_device *dev, return -EINVAL; cpus_read_lock(); - err = _virtnet_set_queues(vi, queue_pairs); + err = virtnet_set_queues(vi, queue_pairs); if (err) { cpus_read_unlock(); goto err; @@ -4409,9 +4397,6 @@ static void virtnet_rx_dim_work(struct work_struct *work) struct dim_cq_moder update_moder; int qnum, err; - if (!rtnl_trylock()) - return; - qnum = rq - vi->rq; mutex_lock(&rq->dim_lock); @@ -4431,7 +4416,6 @@ static void virtnet_rx_dim_work(struct work_struct *work) } out: mutex_unlock(&rq->dim_lock); - rtnl_unlock(); } static int virtnet_coal_params_supported(struct ethtool_coalesce *ec) @@ -4989,7 +4973,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, synchronize_net(); } - err = _virtnet_set_queues(vi, curr_qp + xdp_qp); + err = virtnet_set_queues(vi, curr_qp + xdp_qp); if (err) goto err; netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); @@ -5855,7 +5839,7 @@ static int virtnet_probe(struct virtio_device *vdev) virtio_device_ready(vdev); - _virtnet_set_queues(vi, vi->curr_queue_pairs); + virtnet_set_queues(vi, vi->curr_queue_pairs); /* a random MAC address has been assigned, notify the device. * We don't fail probe if VIRTIO_NET_F_CTRL_MAC_ADDR is not there