From patchwork Thu Mar 28 04:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607963 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) (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 E1C4AF513 for ; Thu, 28 Mar 2024 04:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601256; cv=fail; b=iIciWzfiCMyj62ec7XZzXWVCAAWh111WF1/Z5fm3YxhHrY1+ca2PhsqakPAmvYDa80Vbtclw+R0y9F/0l9kBIdqD7QIEU06zEPZ96zSw+hpgSOGW+FwqJTlP10CnAws/icXzQBa9kgB/MstGpe2/NgM0ijYwhBa9KEDMMT3LcEs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601256; c=relaxed/simple; bh=TFE3tIVnQDjRbR27QgLOY7Q+Wb9sqckMgUlTQ4I9Yxg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P3XJOpb6sv/GxIVLzsQBBRLWQ6Z8pUpkgeTJEMWZWkDw+ry1jy+QkUbPZ73KtlzrVZ+pyvGduywmhJy4pdFmddn9qrAmbUHO065Vp95Z/Jz/poBPy/J/azUp5/ADqyeCcLut+usqV1gY/znBS2gBtIP6iJLc6CaGoR44d2WGCg4= 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=miBCcr0a; arc=fail smtp.client-ip=40.107.93.81 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="miBCcr0a" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YI4zP1y+fgRv6EnBw1su3xKJ3wUXCoMjAAP+Cw8fY91CH2g2ziBvukzsLSobmjI2iUDTvOl0M7twEf0Pl+wqZ0DekvLkMuZ0nn6tr2au9BfVT2MqTCbTCRWQnesyHrOptsJnyZUk1Vig0IbVzJ/EKT20YrCU7ciwAZGy9KMSDjePc5FVyIUwCEd8PriE1zqwNzDr5kWYDHEdDNwEDWvHUJLqA63BAjTijJ2s27kpJSe0Y9cW5G0jKDkdRQrDNuUJRRxwKJtEFyqJeZkVXXzyDqu0c3HHHZw+rozyxFzfoDNdr8tD7wIOYkIMg5yYaPJKnVfdvW0Jn6cbZvJwGPbhRQ== 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=6usZJJQQ07l2JEb3ZMrbwACNrFhBJcTduKl6m0TS7Wo=; b=LJz0q13LBuTH3SgGXpi4ruKguJdNoVpMoEqESexPtbmxb0X+CCWCuL5PbvHt1B/29ECGoafVwn5VzP2f/4ztgUh5qPPU+HdxTcFdeGAXXLrk86R6Yy/UV3iNAcb+Qh/ge8mv9WRI/3YJezeJXOphLjBXlYm/AZg9e1eNrTYTElYYJ/nzUCzHDVN440qZN8GbJlhYyulUZ/OBBGnIaPbL2XPNv8V51wdug5ofiGf9KRiHObRJUT5fs7UnD3DBFhcWDaB0LxGiP320nbL6C4bI2bIk4q80FmmY+W4A4HTFy+/gbdPVErRBCKCDNrDvaJy30xcGkKPbPC/1TZ+kg5NNSA== 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=6usZJJQQ07l2JEb3ZMrbwACNrFhBJcTduKl6m0TS7Wo=; b=miBCcr0a5M5m64/57gLnqFy1qeL/4evz26dyrlpx7+dlgP0aZBdTaFIqC/KZYQAlqk9Ks+Ksh0zxB2QbnDNRQhQGs9E5a1XjSHHpYKK5LN9O6dgrAP4NgyXYOuqe7BDjuPE/gcX/3KxSnoq33Zy8pyAQAj8A/QEjRY3/drVZJJ0IK6z3PprpRnk33DVrrQw7XJt+NKAK2RLMHh5AcITLL0NYaiKbQac65DkB0zOyo2YYu75PA/KZs8RKFLP4WZPWLX1rmvQsKlADY7nUPl812ZKIxtq+c0fMnsuO87Y3de6DVlkOcrCXQfLr622S0zIQ8OoSispJ7EJFY5i4gLzAWA== Received: from DS7PR07CA0009.namprd07.prod.outlook.com (2603:10b6:5:3af::9) by SJ0PR12MB6855.namprd12.prod.outlook.com (2603:10b6:a03:47e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.33; Thu, 28 Mar 2024 04:47:29 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:3af:cafe::4b) by DS7PR07CA0009.outlook.office365.com (2603:10b6:5:3af::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:29 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:28 +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.986.41; Wed, 27 Mar 2024 21:47:21 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:21 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:20 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 1/6] virtio_net: Store RSS setting in virtnet_info Date: Thu, 28 Mar 2024 06:47:10 +0200 Message-ID: <20240328044715.266641-2-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS1PEPF0001708F:EE_|SJ0PR12MB6855:EE_ X-MS-Office365-Filtering-Correlation-Id: d260e2b5-68a3-417b-43f0-08dc4ee22c23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c3V1/WGZ9t6gbw4A397/WtjMHh+GlsZ12rqFxseq3myoPqEl/L3DSGwzvBVCas24hXLZTGSFE4iyb1LJ59lyi1JUsckMnjzJEgUNRfFAcpkjCKmVmmEq+6FXoyhaDDtgJsB5sd8Rc2YaWcslOEsRZGKu2Z4wnZ1nXyXwNa3rFp17Lf7OkR2uEm7MNdlgJANU+hwmWuaeUjJNi4kxJWo6thf1kN0yHsBdk0E+vcEqLcoQ6l9TGa0Rup+o0S/xiicGuqdsxhmSTmSh8tuAJxDd5+VrPb6+/icMj6tqE+qxwov27Oh5vdW2OCe23MrYR9XwIx0HyucqqMlwLFXJ3tZpB85hyEJwvA8APZPEyT1HFaCK2ZOpOes6Dc7cfKstbGdBoJJ+I5bYEfgPwdqB5KBR1QBWoNoOd2f7uh2wXTTOOH0FVVXmREFtqNirPDIcnyVMwuSTv7PoOsjD2N47uSBQ785u7sb4Wt4UTcuvWsI02bmxW3DvaTJrJo7vZuRBLsvQk0qf4+Nx7/ZMAVRZQh7X/cPJTuXPt/RaF3UsxfzT6+h9eRKzycrW0Aq/OpYhBgkJhpGK3/lF1U/c6M2SWR/IHYmzmNAp3ZYuHQOYr4B4eTqUY0HDNORM2H7u4rkQwEWkOXczsewKpHiZukQbIklB+Um4mJyYmuj0Tczz9shVgRi5pqPTWZvyuJ9AJtCbR0bZ5UCz4uesapREH0Ug3+aCYCfzLnVlmZB4zafozGnF+ecQ8NU0Y3EE6y0HoOkYG452 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)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:28.8445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d260e2b5-68a3-417b-43f0-08dc4ee22c23 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6855 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 c22d1118a133..44525e9b09c5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -245,7 +245,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; @@ -287,6 +286,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; @@ -3087,17 +3087,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 @@ -3113,21 +3113,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) @@ -3238,7 +3238,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); } @@ -3791,11 +3791,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; @@ -3815,10 +3815,10 @@ static int virtnet_set_rxfh(struct net_device *dev, if (rxfh->indir) { 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]; } if (rxfh->key) - memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size); + memcpy(vi->rss.key, rxfh->key, vi->rss_key_size); virtnet_commit_rss_command(vi); @@ -4140,9 +4140,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 Thu Mar 28 04:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607967 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) (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 374663FBB6 for ; Thu, 28 Mar 2024 04:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601263; cv=fail; b=R8eLSPKPSPVY4o6GRG3ECTrveMLU0QXZSSFvrB9M0WIXKLVeBFnEPt3Wvn8CkqofNt/ex/18XeR+NiUuYaWnrMcEsbgIJf/+jE5paysXtfJHvmve21j90CCHRFePM+YvBM4XhApbINwYemTp7uLY1FX/1DHTD2vR+UmidvAvc6w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601263; c=relaxed/simple; bh=xTwnoEeVzoE3Veve/tcz+h8CMbOAHzmcX8zkFrhW7ik=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aY200au6oOwIJrv9Vz2GHqLHjymd4c6P9o8VlzIhVjH8A+YqgWCU/sbXw6CZVcbd7wr1mHRy7dZ6WG7NsbgjVctGezBDhcW7UU6wfstQOibmf2TFT/XxrXq2l6rXO3DrPy+66ylygHwI9Fj5OEsk9kEnkVq7jPE6D//0qzDAppM= 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=cLAfRYoS; arc=fail smtp.client-ip=40.107.220.68 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="cLAfRYoS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LajEJl3F9bdm+CfsuNjkB/c6kh0LSnvK/FGWpN0LLK/POl9Ka4krpYMXR8Y+plTzTgYLKqX3Ou3//tpacMZ/+uLkQyDSuVPfOOQQsFUnxKFNgAH1bSaTEgVzxqAIOmzJ01FAWE2TVgppIyna97e2kcm/aRyu+Fd+aQoT41hoWBZCQv/oVbKlYYhPK6dp6JDgptI6VwdXOs1LGfk1YEPrKIHDeczpNAOqb1IwkVFJt4G4S82ajJFtopEtNIsZBNJH9TAbWPakkUBP49sHMCKSyrclR0+LbQsRkhODjLMJLfTWjWdtw0vXpT4LlkInrDs6iPuCUbzpRRc0Xjwu5AHFtA== 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=1IKza6w4nyMAUTF3QaIZIzKXH0XC460EBUluTwPn3vs=; b=lEKCzXfEu1Q+NPkDC6ER2VC2Ql4ycDxd1GJ2vkQodeq02hcbhDD2sEY+okSvWtzW5TrOfILKMPYB4yWyPYSa5G+dIjt9sWJqZqDiT5L/vHkOXbdfbQCdB13TYsUmBATpOyx8+uP+u6aMoOm5FmES3me9wWNIWchaNaLioYK6ec0K2/zqUU9DeNv/JEGcF/xLEKF+RSvjZl+Sj+t3C02K96OIxhBq7ziiL6sPA6Xx0UR+RmY5LTp2rgd9+TM3JCfk5rJU3v4G6uiWd6FjXhtBl38aVoKgm7goByR5fI2KP+hr/E691RXBwAaqQTKz4X9H1fgwOv8uMVqhoqIpSebtrw== 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=1IKza6w4nyMAUTF3QaIZIzKXH0XC460EBUluTwPn3vs=; b=cLAfRYoSGp8EglgBTDFl5txk2rP/EdCtGjacGhd6TKw2MpPlwIXyTD5kssKjM59qbZcws8wOX0kcuxaTyjdzYKX+9i9UDan6yBMOUL2cbcjdAYCLkPpEWMtvOrCeOyaxj+w/tRReVtSr2bdsBlbjs3nLX8qiXUSoVDilF79ckz5hFACetSVTmIMVL/HkVxUwvPPpv9D4MiY0kNUs95w/Ol0UJO/rRBRSQpV7fdAuIXDFCgKv73KNYPMCn7HiswXGuvLYdUeArpqK4X7gDBGkVXzoyvQwC6oFzFXHgavyOmlMNrBb0sut1kKB/YmPc698WT9zo+NeQh0mhFw0IdxwXQ== Received: from SJ0P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::32) by SJ1PR12MB6361.namprd12.prod.outlook.com (2603:10b6:a03:455::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Thu, 28 Mar 2024 04:47:38 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:a03:41b:cafe::ed) by SJ0P220CA0024.outlook.office365.com (2603:10b6:a03:41b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:38 +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 DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:37 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.986.41; Wed, 27 Mar 2024 21:47:22 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:22 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:21 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 2/6] virtio_net: Remove command data from control_buf Date: Thu, 28 Mar 2024 06:47:11 +0200 Message-ID: <20240328044715.266641-3-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS2PEPF00003442:EE_|SJ1PR12MB6361:EE_ X-MS-Office365-Filtering-Correlation-Id: b1d71fa4-5cf7-40f3-90ca-08dc4ee2317d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1BJCRKET4Cn0wjwCe39jwZKHi0aZSpwb3GeAgQZ91FkFIT2tJaxGKzFgntCKZq+ZY6Ksaf2kz9XgoIgtoUiwIX+8nwjjU8N0442pwl+0haC8MjZjI5AZrFtF52mAYfdxt53NRZquHcoKMErU9PebXuqA1wLzbgJa+cbCCAMs8UcMF+qyWWFd0wCTtAUqJEjDnhy5ftDTum6+fONg9qdmg2YtqsusGGz0+ltjp1q1dqkzEZ3Xw159ss7uWPWzTQQRMXiYU6j6yHSRZ73mN5yyH6j22qIxi9FQAftNEtO3iq1v/Xg3ENEBc7m2HRRp2N1sUB3pmDel0HXjt/M5nPRt+gP9zQwfXT0nB1uWIn28XHlaVzFZQVj6ZI9vPQMWJALQPRMlqXAVfx9AvwBKznrYrFGwCVnjW1I35oefVoZC8S1PCXr/21WP3xFmbYIwP1wCgnyI+b6gZJ8ExWeMysK6yrLo8wXwiWa1fcXcwmrtad28JEe08kHvQlMKJUPSHadz5WWv95g8KfptsDdAr6+ydjwwxUGRjE7g/71uvhZ8K7iKtpeMeU38Eqn/KHN9DHF07O9IPV2PGgclRG93tx2e+69gVKloP19JGnnhZsPSyetZxhiAacaHm8DHoCqh4DKfa8WhoNJ3btV0pd/II2Q4AwK44D1+ohsYhLaTdNXGuGw7d7BL3j5o5jOIIhSKzwstaFwFSy+JUF7dyExj71rZ1kVjhhMHsu/LmgPllVFn170G84a7hqXAL1EKscDFCzUK 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)(1800799015)(82310400014)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:37.8249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1d71fa4-5cf7-40f3-90ca-08dc4ee2317d 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: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6361 X-Patchwork-Delegate: kuba@kernel.org Allocate memory for the data when it's used. Ideally the 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 | 111 ++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 44525e9b09c5..ff93d18992e4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -240,14 +240,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 virtnet_info { @@ -2672,14 +2664,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)) { @@ -2708,6 +2705,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; @@ -2732,6 +2730,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; @@ -2743,22 +2742,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); @@ -2819,10 +2823,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)) @@ -2834,10 +2843,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)) @@ -2950,12 +2964,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, @@ -3101,11 +3120,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) @@ -3410,12 +3433,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, @@ -3435,6 +3463,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; @@ -3453,6 +3482,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++) @@ -3463,9 +3496,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, @@ -3935,10 +3968,16 @@ static int virtnet_restore_up(struct virtio_device *vdev) static int virtnet_set_guest_offloads(struct virtnet_info *vi, u64 offloads) { + u64 *_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)) { From patchwork Thu Mar 28 04:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607964 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2051.outbound.protection.outlook.com [40.107.244.51]) (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 A4FF218AF8 for ; Thu, 28 Mar 2024 04:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601257; cv=fail; b=KVaa3b/qnjZVHfbYBe6LycITUCtJ6eHy6Z/YCC4QRHxpS4DcSJ/olYQCc9nRJdUOeGtd8TdCoMTg2ClNutvFtzPfPUYDHdO50oRm46gWAS0jf0/mPxjvFnoE9B11h1idYpaTevblfa5mmoSO2VHde6GYgbIEE7FT3iG05L0PFvo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601257; c=relaxed/simple; bh=PW3zqvG/4pWWdZNSa5Ub+BXgKrQtNSG1FHggwCJ/07Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QiCScvryU409bb/Wp8uPL0ZMXNjdGEOIq1l/wJaPrJ9XzKxBEp/SzEVCTQUXcVWaKK9iNi7jmeInKgTGyiMXtoNkFNRPMvEcAlWCyA3hHGZN/WKXml4dex7BNKjx+Ceu+nJydCOG6Dee55UbClY3Dq48iV7+zVF5w9JAi77pycE= 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=BqTbngwb; arc=fail smtp.client-ip=40.107.244.51 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="BqTbngwb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRdkSsO0NxhAjBlRpICY8Ir8JUtVRR/uO31nGVY+hx55e7nC1DmjXQieR8ZJN80BZ61NkY6dXNKvHBaQ5BKoS9ytb7EupMT9DFBHaesdDJWHfh1WU0Rq5EyPm9nINBBOD19eorQLbnCwWyZAIkHR3y50Y3jPSquJ5V0zyST8dQWj5NSN1SIUTKlB4PK/oaXwBuHsm3VDa+5gYgsXB7AGyWmn7YxAjNctV6/Cq/ly7kyA0MA3KAAymPLr5uNR2r7NZHLP4H/T/OHO1O4I3KEnar/+D9kxFM/Ik2YUJXWlaibiBYOZzKh9qE2AjFZuwHFU3jl51bm3MMNE759ixgCzow== 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=M6Qahc8/kxlJgf646bX0I/c5wTHUAXOULpse0bOC5DM=; b=MCDC/l4WSu3ewhcqcEworDhEAjCVLgQqC9yGDsRj5iAHcN/S4W1KffLLmitv5K2n9QkIihBVUoQjuYs976UqAPkv+mgFDs8LAlYgH3+sWWfAm6VIsjvaoB34XW5OUVw05KQMd4OyCwG31PxWUvLSyifodgh8lWfT4SHytXY/laalxWO8RmwxklFZfE0p1cGZKB1EmI5sLx8Nbz7SDPSEh4uFx/F7gvn6fF4D6JMvLUfyIlTk4CBWOI6ApU+Pea3G00f8X3oWK+7j8rfAnivxA5055jxAhXNOt3Gb+hEU0++SMrNqK/Jo201GJlbjgwzpxXAJUyw+VFd369tEgpi4iQ== 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=M6Qahc8/kxlJgf646bX0I/c5wTHUAXOULpse0bOC5DM=; b=BqTbngwbKCFatYi5eWbKfEfQgl2AnZn84Iqm7wpPtFx9jYhZgjTL11dUV8zXod2qgL+z2X11eIwCZXE4IQAAqTiuBJFOqiVw+OEnYYQXWF1irejBWIG3WYaflUTBDLPsOmOaTDJl+WJyLu5gMdpf0D3geMYYyBMIViaUz80E0Mi+8Lpt9wb4GL2XedUPPEB6bVoBkBMQXCszJHCZ6SgOxnPpbrTSwU41nbNJeS9i/qmDof7TwzTFl2dM58nfnYyLFiY3iZHG+IonELs1wg40KFE68spIYg693hKZXocLyGb90ysAhPCYHrg+GYBGUgjVggbdlMo02ywHLi67nJOg9A== Received: from DS7PR07CA0008.namprd07.prod.outlook.com (2603:10b6:5:3af::21) by DM6PR12MB4186.namprd12.prod.outlook.com (2603:10b6:5:21b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Thu, 28 Mar 2024 04:47:32 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:3af:cafe::26) by DS7PR07CA0008.outlook.office365.com (2603:10b6:5:3af::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:32 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:32 +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.986.41; Wed, 27 Mar 2024 21:47:23 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:23 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:22 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 3/6] virtio_net: Add a lock for the command VQ. Date: Thu, 28 Mar 2024 06:47:12 +0200 Message-ID: <20240328044715.266641-4-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS1PEPF0001708F:EE_|DM6PR12MB4186:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c2f3f17-ea9f-4510-1457-08dc4ee22e7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t9uOUrqFEqp4V+jZYa9qTq6dlgWPqP3VkVFV4Yk21BEjeZ6tq877u87TDrRzh8QVfIHHqZEb/kVLyBYpHowB84ks4P+rfQHSqgWataYqjRNDNLCTEuGsgGDlFb6oQoZXuthrzIM32iHc7+lAg3dKiMWY50N9Vx08im3LL7IdiZDvDsgnwHAKyWr+UhEzMtpu2Zu2z2AKRBhcLdNMnMIStpkIoMp5OBtIyFeQekI4GID4W/PtmG7Ah2INLzbnwwWoNwhs95bLnLaeb3IxDsZsxTzhOVU3GAERTxuQXy+3Nw4vWEzZc8FwtgG+t9okHe5DGTbeI9gtBO+eUJ1qcsufIlclCj7cbTZz70iIjkH2X5V3JbDeNo+4o5OhiDe/zc/oqkpXr0Rc0NrIu6lWVLCAanBceShsJNM1GRjNlDNtW2ECcI9ADN2JsGFYhm8CVkgHopBTVYPFm/z7PvpP74R8vPm/KxCjXc/9Rrn8quAox5DHFTBZet0Rg2v8TmE/U/mxi811FTPsOuUYR/KLY7bvxRcxFvCskTovTZ5yQ3/ksZjKPIp58tOoJ2QkvE+6h2P0nr1/8TXlJ7IhF8+dTwSZOGL+Tnbr2LQlD961w9bb5gn9KWQ+5BP0NdJCT9VBPVfhc8mIKE+1/65NWJ8ht5ZuriQZdB1fdJbmiZgo3DDY1y5xaQgbB1C6XamrPdmEXxONTYEz5LVKSlJjOP5WkPkwuAaY2ZsPT2Dt+kniyHyA1eVSUwa/MskVGS35isF77PTV 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)(82310400014)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:32.7820 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c2f3f17-ea9f-4510-1457-08dc4ee22e7c 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4186 X-Patchwork-Delegate: kuba@kernel.org The command VQ will no longer be protected by the RTNL lock. Use a spinlock to protect the control buffer header and the VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ff93d18992e4..b9298544b1b5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -282,6 +282,7 @@ struct virtnet_info { /* Has control virtqueue */ bool has_cvq; + spinlock_t cvq_lock; /* Host can handle any s/g split between our header and packet data */ bool any_header_sg; @@ -2529,6 +2530,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, /* Caller should know better */ BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)); + guard(spinlock)(&vi->cvq_lock); vi->ctrl->status = ~0; vi->ctrl->hdr.class = class; vi->ctrl->hdr.cmd = cmd; @@ -4800,8 +4802,10 @@ static int virtnet_probe(struct virtio_device *vdev) virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) vi->any_header_sg = true; - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { vi->has_cvq = true; + spin_lock_init(&vi->cvq_lock); + } if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { mtu = virtio_cread16(vdev, From patchwork Thu Mar 28 04:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607968 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 17F8045955 for ; Thu, 28 Mar 2024 04:47:43 +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=1711601265; cv=fail; b=GJkYkci+iVb64ucae0Btk3uanvGK6JMW5tGhdVhbtq0CuoQUYRieQjyfTEATRn9fGgRLI6Epqj5TEIm9miGfQUcDQX23kRjpdTEv3CE+XdEW7CGZGV6UdI4FnZSIUrKNvkRp2oGiKvIUKu23WSTPBgDvcubb/+D+IY7M8HlH4Hs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601265; c=relaxed/simple; bh=8asetLhAtj+Mm4mafBKKZ75rVW+ctuS2cn954eyDXjo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WnR/DVYfs3XIXwkASOQNRATi95HXnl56h20d9Cw2wUokfWHVGDpB0oISd30z/rDZ7zloQQzjd74LYqrIUWJdpnhLQEa0vVbTkajhR2M+6Y5WajMsbcK4sdPkPau4JX1AcZTteXwto01GYfPsJuPaiqGlfBUYd7ZNCqmEt7MCHeA= 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=n/ChnUMI; 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="n/ChnUMI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XI5Ex/I0t+UXGBWX0xB5E4oHafiSTCxXNL8inb7C/p1ffHT+kaEMu3fpwk6l/ZKFp4vWBU3Px5dpq7gRAe6YU8sWOtWQNrVt6mqObG6Pgi8qSjEvPmz7nbk/Ly1bm+iVECBTn3l/bGBlHkHEnzpC9HFejqBDhaBWjrMkMQ5ni8aN2XEhejD9eAnVOGHkGCI5+/FpBVDCf22LOLukqnUgy7FCq7pWvnr53U/XXRBHVaXeS+f5etYrf9ZdLM2Bs8nGHnxM1at+I1eIKMr+tHrgL+BxDZ2dekDAk84AKgkwu4Pwxvt2t2mvD4sMYvGaSIH6czLt17TlaVUcsU5JISbK+A== 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=Ka69XECIaWNdry0PCShmXJjUTPA65RpARbEEbcdAteA=; b=SHZpcWFkjPF0B5vIfHsCCrPm2KZxQS1S4mRswL8Gw5rCXQ3nEdm288AJLz2cxAg3jgkpefk9kPL5meLY4wNZzYvCYmJRlW8fqUQH3f0lAL5eYLocEyqrCkF8bT7zqXGP+db0qHSzMtThazdZnMZjt8qLcfKQzFwzcRMExMW6/ZxBZtbs7076k9JeJi9IszZIQeLEsX+cph60qH6RuGVxYpBgghn/AtLN2G4oKTfBO0DNmTXRUr+RPyFszfC3x9rXmIgqpSLLE/TyUsqrWsq3EfRoRaZ8XsaGF2o5lGlOniihCUQ92F3agGrLbE5lJsYx18ghFJhGDo3XYefjwdxn1Q== 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=Ka69XECIaWNdry0PCShmXJjUTPA65RpARbEEbcdAteA=; b=n/ChnUMIfBO5jv7VmRCcXdCDwh2istwp7KbafRPJNWaF44iIaeyC11exQQQ9nCW1wXI95K4DoRcUxhaa8kuJ5brPX4GvSfzmOAHv63nPNMWCghuRPBY2r7ZrWHJon7ocCe/m5Sq2zjYoiKahGeh52NPIc7eOZpyx4T+TAEEKamPraALTGEC2cD91GCDid6X4lgJithbxUzF64G8f19fHb87pFQSjhglJq29xiwSj2e3BGSnS8ScO0dtiyC/wgqyHWKVd3FNrM9lj9ioIkGWSumRrsNHNx83f2LsQ48Tzv3laK/fCKQwvEg2v7S+OZUMr7R7dn7vwN0ybZDs4h1w9IQ== Received: from BY5PR20CA0016.namprd20.prod.outlook.com (2603:10b6:a03:1f4::29) by CH3PR12MB8969.namprd12.prod.outlook.com (2603:10b6:610:17c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Thu, 28 Mar 2024 04:47:41 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:a03:1f4:cafe::16) by BY5PR20CA0016.outlook.office365.com (2603:10b6:a03:1f4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:40 +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 DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:40 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.986.41; Wed, 27 Mar 2024 21:47:24 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:24 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:23 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 4/6] virtio_net: Do DIM update for specified queue only Date: Thu, 28 Mar 2024 06:47:13 +0200 Message-ID: <20240328044715.266641-5-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS2PEPF00003441:EE_|CH3PR12MB8969:EE_ X-MS-Office365-Filtering-Correlation-Id: 17b5128b-12d5-452d-3399-08dc4ee232d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WgvCkGFg3JS+p0eVq09AYq5rfIUSPdRInzqf2aiDdDHlRWofZg2aVfUVKdVMedC7fMKitYFapKFJ5d1yYXVP1SLk3DZYixBwuUWfmTaNc6uKXh9Cc0iNdBPVilZhvFsQWlJjf+ANKZ8CVOFnubcVn+yPNIu2HGXVJA30hTILmy8m+/r+MNs2etUkFQcOF6Xo7s3J5cxlHn8A1Io6NKdmi3IjjKIE7FmZ5uEtoi8c9xGsd1u1hMU98Aaaxl65CrIzSgl/kYRa8pXi6Avf8+kp31ts+2dvNX9Cn57FEu/PuxxwlJ7YaroZ3wwMHvFFb3OZK4N2l9mH5odEPkb5kzNH/8NXAQZXv+OvNb8bRkozEBSMBt+rQPzc3EZRXVoLLNQeFfb1waySXFhg82O4MobTyildOIGZs/guyBMV1xG8tq1Xo4A2mp5js8ip6QdT5uNd9PoaV1k0VONBy9CKn7h0YMr4mqi8/wgBUxxZQvXGRw+o/WkVixNofbfpba1UjfmqQx0p9E+E0HAZFU8XV0nstzFnFvrd20+rMPDPBYloI11Lsz7UK/40AIWVDVjG0+Md/liK1Otk9LDo3lcnfAYMhy82C75NAWy+/bWcMlnV+NnCuaHKZ7NinhPTQ42apVn/Jvin/fbbiip2ZgBBBbqCSqhyY3PEacdrWR2CmELZ5fgAJjlpD9wvsugm/9r9LYwhkQIxYMFk2TBVPFVmYFTaVj5C7/RyQdvs/55lPtusQKrljexm/usDS/39mCTEFdt7 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)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:40.1032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17b5128b-12d5-452d-3399-08dc4ee232d9 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: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8969 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 | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b9298544b1b5..9c4bfb1eb15c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3596,36 +3596,26 @@ 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) + continue; - 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; } rtnl_unlock(); From patchwork Thu Mar 28 04:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607966 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) (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 B2DAB18AF8 for ; Thu, 28 Mar 2024 04:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601261; cv=fail; b=JhPfIBAtmPcsl2q179hVQQS0GCtXoWclWFWcOM5yId9rXk+KGk/dcIJqsJqhOylVVWsqpZfjaDukq9s0aflyYumE54MojEBq4iPh4sryTQGQmID5rfzqL4LIbbKHiqnsppMSCmZ98nG7rDXx+hiJpqxA98zfrz1eiVnUOy/0jac= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601261; c=relaxed/simple; bh=gsTV3FlnZJMFTCSlZ8pHzSf/GXlzJO6bRxdkSi1FnjM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NksKzTtp3X/1WA+4Pyl2rVi+4yN0aierN5NDTXDSfGArSOtVLFW40bRz47Abc8WyObpBQ+ykzKz6cYZLjpHF+k9Ohc+Hjk8q1UQRyn3vX6CNCdaZgSVI3dkjSySqwHMs1yfTnd+AQ/91UfNH4aOFLr4thDk0dQT7c+kFGNzzRbw= 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=KLCdJ8UT; arc=fail smtp.client-ip=40.107.237.77 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="KLCdJ8UT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BdiapXrjZTVGpTWqdEaghgSe/D+SL9wK4ohWppSyEby1jvZ51N9ePBBlRHhtcE4wBUWwOTNsT0geiRgbWKCjEGh62Xrw4jvEsRRDrvT1qLNrLJpfMUhJe3CQEh/KguBl0+SfGzSvbkeJb1/Qi8CkH2rrLHMQv+/NkAF12jPtbWzuS/+5OJ6s3zbVi/aQfND149/qUvdXN1Sru6pLdzDTW5p425hqXC9sdEak/R8Z/dNcW84iwgs489j5NdObAOIOh7y861PfJnEIZF7CN1TElhR/2eCyoZszbhd3bi5lvYw28vUtkc9kO//t4qaMH+kaepIKFr0epIZu9lZneb/tYw== 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=X01ceE2MsLtf84g4slB8XFxLHnujQkWQ26Sit9xfO8Y=; b=j5avjytQgiIurH6YThx+VQh/Wwy14+5MbsJvGq4pkjyrPWrX1YjF9oebXZa9jjDAqdF8m3OF6jTToTwrm2aIXQmVHqLlnCuh9q3M/XBvhOLsInsEqs1cTzVGzXnuCLnQGPOIpCaAV5RGOuaMz4XELRHhlC8BuvM4ooThRUoEgCeVh/sHbwAGxARxXNwu+j8eT2VYaD/YZ69CARTOpEAWkq1iLEgHrKwy/moVTILZs4e95MKc2hL6YX+dvbGUsCfQw738gSLxvWIWSrUrNZzxheiNIrKcEUnzS/5rsw4jWsL+WDhlTagqypOyoGYotxq5ztgnm4cYfxL4Kx5fz186Ww== 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=X01ceE2MsLtf84g4slB8XFxLHnujQkWQ26Sit9xfO8Y=; b=KLCdJ8UTyW7B8VthEdpnfp35SvEEAi7ZL5aeUXTuKoIjMpwnWTpcw+iokqMhmvpr1ht8TXHTXrT2N2Sa43JcYw64IXGmO8l3r7zQdHe7CjiKg4cf5BNXB83pQ6AkPE4kA3CWTHtDwxG8ndJkq/7fD699NvHFdtWLMsj1bTsiDEj64zf5M99G7sWoQ2HNTpUJ+H4U8rQesAIqRH0A9+SCO0G69BW4UYcQQxi6XfJlrQSO5oDh1jzb80VAZlj9S6kl+uVjmYKS0OokAZNQZrmTpEYbfdihJonG2PdT8zxbFNH+OASG/kCPgvJCxEYmUPZ4UiAP00fEY+3E50II1QgyTg== Received: from DS7PR07CA0018.namprd07.prod.outlook.com (2603:10b6:5:3af::27) by IA1PR12MB7735.namprd12.prod.outlook.com (2603:10b6:208:421::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 04:47:34 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:3af:cafe::8e) by DS7PR07CA0018.outlook.office365.com (2603:10b6:5:3af::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:34 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:34 +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.986.41; Wed, 27 Mar 2024 21:47:25 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:25 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:24 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 5/6] virtio_net: Add a lock for per queue RX coalesce Date: Thu, 28 Mar 2024 06:47:14 +0200 Message-ID: <20240328044715.266641-6-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS1PEPF0001708F:EE_|IA1PR12MB7735:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e8ca1e2-038d-42a0-e1da-08dc4ee22f6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LRC5D4dYr9y/fBaDXT1Rc6CCsqdt8eP3InqZ6gm2gD6TjSQCuYoroBF9/JPrO409P+5mctzliBzkLo4QOC/F2mPTPTSVHaUR9/W4tc16OAjRG9ME+ond7M9MFgE2RDRXFNTO7pXxt1CzUBY7cqhIClIxyq7lHD4QrbbpmC05TknI/ih1ys2JQ9dGLC+yzZH9pg2jWSRwsYsxrpz+UKQNYwlsgVPietcwCzX40kSjnaGBBx2+HiR3d3LXIu9CNxvWtLv7xmizLPY4EGtkgNk3AgDX5M1cb5nOD9vjRigetfODejHGk6IAAdWHcFNK9LL4XSp55wkKl6Z38masEsL2Jm+rdBR4VUxSPCWQJOn6oNk+CxO6F5Gpu4lpBVVD8KAvC3MuuNh4KdSra7l2xMwpq5r/sAOPO2oEKZxR91UDMudaujDpFRbGVkUUPFxwenmVhaJXicOy2D9MjUIZJSHDycpLVuTVycBCROyWb4A1WzrLyQZEZ6rPjojXf/TiqX7Gm/MFPOtDEhI20UbcO0O5qVt8VoEchknAY8jTf28Z/+pLTsVIxWdvzt2SwvdsopJ7iwFEY2Iik6/79cKb70z0eOzZw/T4aOe5Q7Y0GK2MjJe0lcutl6KrGORkZhqR5tUcKfbuNUXVJU32kBSZWXt2o/zNP0NaedSmwLiwDnXnMw5QIK/vJsvCEROl8W9Gbm7ajJBoRKhMNVXF9ySavyY5t1s/nPHpTn5ERovgzghiiFbxmMeXNT7dgZ26gHKGl+9p 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)(82310400014)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:34.3601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e8ca1e2-038d-42a0-e1da-08dc4ee22f6c 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7735 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 spin lock per queue. Signed-off-by: Daniel Jurgens --- drivers/net/virtio_net.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9c4bfb1eb15c..859d767411f8 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -190,6 +190,7 @@ struct receive_queue { u32 packets_in_napi; struct virtnet_interrupt_coalesce intr_coal; + spinlock_t intr_coal_lock; /* Chain pages by the private ptr. */ struct page *pages; @@ -3087,11 +3088,13 @@ static int virtnet_set_ringparam(struct net_device *dev, return err; /* The reason is same as the transmit virtqueue reset */ - err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, i, - vi->intr_coal_rx.max_usecs, - vi->intr_coal_rx.max_packets); - if (err) - return err; + scoped_guard(spinlock, &vi->rq[i].intr_coal_lock) { + err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, i, + vi->intr_coal_rx.max_usecs, + vi->intr_coal_rx.max_packets); + if (err) + return err; + } } } @@ -3510,8 +3513,10 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, vi->intr_coal_rx.max_usecs = ec->rx_coalesce_usecs; vi->intr_coal_rx.max_packets = ec->rx_max_coalesced_frames; for (i = 0; i < vi->max_queue_pairs; i++) { - vi->rq[i].intr_coal.max_usecs = ec->rx_coalesce_usecs; - vi->rq[i].intr_coal.max_packets = ec->rx_max_coalesced_frames; + scoped_guard(spinlock, &vi->rq[i].intr_coal_lock) { + vi->rq[i].intr_coal.max_usecs = ec->rx_coalesce_usecs; + vi->rq[i].intr_coal.max_packets = ec->rx_max_coalesced_frames; + } } return 0; @@ -3542,6 +3547,7 @@ static int virtnet_send_rx_notf_coal_vq_cmds(struct virtnet_info *vi, u32 max_usecs, max_packets; int err; + guard(spinlock)(&vi->rq[queue].intr_coal_lock); max_usecs = vi->rq[queue].intr_coal.max_usecs; max_packets = vi->rq[queue].intr_coal.max_packets; @@ -3604,8 +3610,9 @@ static void virtnet_rx_dim_work(struct work_struct *work) qnum = rq - vi->rq; if (!rq->dim_enabled) - continue; + goto out; + guard(spinlock)(&rq->intr_coal_lock); 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) { @@ -3617,7 +3624,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) dev->name, qnum); dim->state = DIM_START_MEASURE; } - +out: rtnl_unlock(); } @@ -3756,6 +3763,7 @@ 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)) { + guard(spinlock)(&vi->rq[queue].intr_coal_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; @@ -4485,6 +4493,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); + spin_lock_init(&vi->rq[i].intr_coal_lock); } return 0; From patchwork Thu Mar 28 04:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13607969 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) (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 D77C945BFE for ; Thu, 28 Mar 2024 04:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601268; cv=fail; b=F6xMEOh0y1eostqSlWjURxBfivjv39++gnOY3oJqRLKkcQYaPEfgAMqRM7B4cE5wFzlnJBCSa/HswShUCn/JPFOnu1iEQQG3vfPlPsBA5v17AVwt+xcZug89fVlNQaKBuWNxN17jVNJDvIwIukJuSJTAYZNJvBMIe0l7DoUA8cY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711601268; c=relaxed/simple; bh=sgqx+w9t+Pix7RWNlSX7dR6Le4P3NB+t68cyImPiR/4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=peeo2mlXdxDkNW4fjZqlGe63GpC5ZEFjlTq9NhSNgOlHcEznwsqcyRv/1XdvMwDnUM7QvrtqjiVtV9VlaTGn76FzgoPdWC2F9Dz+MpCq8LLVa/qalqxh0LSUcQ95TfTAjaKnzuzrG1DuYwkV4HeAwtlq91MT7UZ1pqRs2el6BHQ= 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=W1xonUSU; arc=fail smtp.client-ip=40.107.243.40 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="W1xonUSU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FRG2kXeJKGvFWElCgBE02xtZN5qI4ikKSjXovb6iib09gddDzilzRxQj/U3DmDGI9a7Y4ba4xi7yn+op1zhFLAwbyq4s5z8dZVGpCTNs9yLCpSUtDbrPw3chyu0KXa0ItWxwIS15IyENvmobfUY7F4mhSnq1HWzQsSsqvqsbbTvAhN7/Art0WXVlrN/wmESKDuSGSDCmUyKbitdQ0cGvCRf3RgHv+XGV9yLcElzb00FRfJEWzDYyA5x9HE18egoZH9NhrWZc+IQvXB4lHd1RBE2Bd/huDxg8Bbx+GMKDM21e/n5n2qKAOagIOj7HZaToM2S+VaFWXakkBuWq4k/s3g== 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=JuqoC2Un06h0rWPzOlTstWpulblmjCIfdrnzk6YFoOU=; b=cTejq9XZxiQop3q30ba47bvjWxVsjUlD0lJ4X02SRwGz0jVZogQZ4qvTBRoIisx9gA919Rinra1/YK6AZbHiBU6YPWRv8+k24HZWuSqGUBg5HEEz+hMeMpD7Qfz0jtLZS06wRaMUi6l77nerTfLvwcngoLvEVbJEUf/d9c+LhWBeEk10sDmqouZDfmRg+96voGoRBsMBJhQ2QsoJGyCcorrjr7f1fYfbukivGdmdSY7XWYfohbS3qMKlaKWW06fd+3KdQaenWvV0mKHSclluRfJYN8HMySQ0c+HybO1SVLhF+y02eQKFj8VTm0iEErcnmeHPVL84vwRPd9k0ErgUog== 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=JuqoC2Un06h0rWPzOlTstWpulblmjCIfdrnzk6YFoOU=; b=W1xonUSU8jbWSZMtz94FtvEDRXsbZp5Dy8HjbeEqwnHFWzBlkgBQGPRZcENQiaZkWnlkXUpc+qpeuIu6Q+47tLmQ9Mc3g5/ivrn3FQENb7EZRsQswfNQbHUFuk9nzfTEu+Ol+nanAytCWIJqblUuGVGcoWRUc8PW89ct/4JfB59TbDfsxAqMjPLVYpXiLIjjEFEgeIyRqsR/Hz6bFhdOpoyK/4QH3goHTASCjMl3RbcPYIBL1p8dAQDl4emPqu+risngikBUQeQX6xvcflHwGey66341tSRYUEle4Xow2Ec5X39BC8ZMFMC4HnZ9p04qSs4FX0YFh+o7LtReKoK0vQ== Received: from BY5PR20CA0034.namprd20.prod.outlook.com (2603:10b6:a03:1f4::47) by PH7PR12MB6000.namprd12.prod.outlook.com (2603:10b6:510:1dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 04:47:43 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:a03:1f4:cafe::fa) by BY5PR20CA0034.outlook.office365.com (2603:10b6:a03:1f4::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 04:47:43 +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 DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 04:47:43 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.986.41; Wed, 27 Mar 2024 21:47:27 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) 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.1258.12; Wed, 27 Mar 2024 21:47:26 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 27 Mar 2024 21:47:25 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v2 6/6] virtio_net: Remove rtnl lock protection of command buffers Date: Thu, 28 Mar 2024 06:47:15 +0200 Message-ID: <20240328044715.266641-7-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240328044715.266641-1-danielj@nvidia.com> References: <20240328044715.266641-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: DS2PEPF00003441:EE_|PH7PR12MB6000:EE_ X-MS-Office365-Filtering-Correlation-Id: bfbba450-dfc8-4111-80e1-08dc4ee234ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9TmtGTRb3RzUZSrw2w3/n0Gq9amSvmMzr5IE0N/QPONMDc6r/8EkY+774E83kWawA60b6kK7rW9wOi8Dn+YByFvYhLlGKIEnjuf+dW+mJOhM7nDhVMVQL/QPeN58ASvEhW7z9vQbV+Gn9SUNp3MyX1bb4hnVcAEWv6BZIz/Jdl7i9NE+mBpaCymMTjhdWe3VfLbHBqekv6xP9h2Cg2jMU3j5RBCn5rFFcclPAvg3jN8pQ3MlnSRvOdNUWpgbWMtJ54tUjKIyR0GKV1qM6jELMtnN75NtT8tZ8vsy2DhBubP2pOyvPBh2ZBG/N9pM1ijj1pEMfVygFG8CiKQFEthj8OnLb0lvpTuYixA/Myd52i6iesiRMEh89qkY3Ak9A1lffIFBXc+EF4yNZLGftmu7RhS0g8oTAKBeZXNc7N7dqT7cMx7+z5f3J730YsKJlWy7xcgvXoXVyvT7mCTO/dSvzgsr44K8Ifd4dyg5rpOWISFwfDMwRX9OYX1ZlzYUKJ5QR9KevoB19NGPZHiYyo4+SIbJi0Qi0frxZ7FTt3imDljc2HzwloF0VskRMIssXvr5n2Lz/glchMZtz3H3B92MH+Xgil6lu49xDibj8y+oNdAs/RjxTT98KWs0NRSSIk8RveezflVOnfmcuJjRAayv+/hAtoo8u63QVOCQA4yO7oXmJ0m5myEbfKRBqGy1RhJ756Dh7QccvS0EOulxt4LySy6wY5p6EsKLA9LpJLMWcxSJynlavTHzjHDTwBfZg6jf 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)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 04:47:43.1657 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfbba450-dfc8-4111-80e1-08dc4ee234ac 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: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6000 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 | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 859d767411f8..351d9107f472 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2658,14 +2658,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; @@ -2696,16 +2694,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; @@ -3311,7 +3299,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; @@ -3604,13 +3592,10 @@ 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; if (!rq->dim_enabled) - goto out; + return; guard(spinlock)(&rq->intr_coal_lock); update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); @@ -3624,8 +3609,6 @@ static void virtnet_rx_dim_work(struct work_struct *work) dev->name, qnum); dim->state = DIM_START_MEASURE; } -out: - rtnl_unlock(); } static int virtnet_coal_params_supported(struct ethtool_coalesce *ec) @@ -4077,7 +4060,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); @@ -4897,7 +4880,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