From patchwork Tue Apr 23 03:57: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: 13639298 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2062.outbound.protection.outlook.com [40.107.93.62]) (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 644CC1CD35 for ; Tue, 23 Apr 2024 03:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844693; cv=fail; b=G5l1wy+PAbNuBwubVw3SS08PCjI/iPnPxmXwO8NtEAeFQtyEK8Sq2CdCFelV+oSAiePDYVTqvmxorFUNCm8SolhgNAnk/v2JvrWaQ0EKaKZVCnAM7ICGupQhSQmRMDz4utAS61qHB6tkj+svl1udFg/C9jj06NoZurYSAM2/7P4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844693; c=relaxed/simple; bh=pnOqH6iHv7NL32V89mNbIm0iyq5N7jureUnXTftRtcU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ByGb5vfV/i79Qz1IO3Gz2PndIOYjtTB7B6c++K/ixh//YFvvjs/b7mZhuZ/YqKzJgWk7CLIpceE7IGRByxvTX0T+2QKMsLbqU1TYEQysJ8e4GCh4Et217h64Iovdpt9FlqZSxfSLxYOIyeOxn4/vkXKihMq4DlB5aAgcGK5CCrs= 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=eM6BoRQH; arc=fail smtp.client-ip=40.107.93.62 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="eM6BoRQH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQx/8guyx5sBqx0DWy2Xxn72ErDwaIo5vAxNmvW6450pzSuwzEhS3tywJ52ozNTGJA6lCl+7kvo80MfpWBSEpj3wXKSQM8m2fZgOnGcUS2wKtKBZ2e4YFmN8JISCWxloXZ7o5xeezN2GbPqmEQwGFqUecP/tS9CTd1wIf8+qlEhfH3dyhds0c116r125dFEezWie+0KPKxGB8cN63wvf454wvrbMXkUKxxXuYiVSclnrWWlS4tOyAqVM2D7vNKpWiY26orLj6YX3CheRp/mSIphyYBPj87efOxkkI9+iOO1KLKaVNIGwsplfVbeL7o+UC3oYFbWz4RIe6VfA7GiZQA== 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=+jw90/y+0sI0GgoIU8LZL8BR5r2COe7SIhzBxhu0Fug=; b=M7dnN6SZvPiJAamqvMdPPDkPERfWjy1SmeLEijQNQ/14QpKHZssK+FshRHF0PMhMIMk9lDT31qv0VK0JBw2LigomNZDFmYDnQNy1a7fAM85qU+mFv8N9DWoacIxF8Ld+eJwPqh5jF3nQ1bRqnY/doOSStntETh/s7PX97Qr74jhz2ArY6HDGAdqQBuRyUscGKBH/FzC+DzqXkwcPek6zz/slEz8C11vUFeJGVrqtedSYJ1xYr8UCAo50BKkl0whSGO3xgOsFHwuJeyvRpNCKU9kD1dAGITjejMBWycgoxAoXltAbWVEJBBmTtyyfD4vtpQMT+mtTdKsyO2AqXfg3pQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=+jw90/y+0sI0GgoIU8LZL8BR5r2COe7SIhzBxhu0Fug=; b=eM6BoRQHU/a1ms6Q5QKHgc+nN98My1ZOt7M8Bij9wl0EpracIxiXDI2ULBSIsxUVxr2gCiNjb8cmGGw3iajkQOA/PAo31hzeZz+om+5iJw39yoi1RuxYInI8XQhTnOYpxqpyQOuwcVa/6TyRr+KgWjztpaRmlmL4Ditx5h8sAbrRCWxn60fkRKNrkrxTKoJXjjqkhQ5+LD/0DDovuQA16Jx2lOe3YNnGC/dI9yMoDy5e7ZymwnJE1nfHih/N3aaR1E4mjtw+5AC1FVOoBRiI5+McWSbrzYZpD1c5qtSsjVDlJy4i3H90WUz5YY+YDwQBhXh9QqKHmkV2aoZUvBLZ5Q== Received: from MW4PR04CA0254.namprd04.prod.outlook.com (2603:10b6:303:88::19) by IA1PR12MB6625.namprd12.prod.outlook.com (2603:10b6:208:3a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:07 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:88:cafe::38) by MW4PR04CA0254.outlook.office365.com (2603:10b6:303:88::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Tue, 23 Apr 2024 03:58:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.0 via Frontend Transport; Tue, 23 Apr 2024 03:58:07 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:54 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:54 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:57:53 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 1/6] virtio_net: Store RSS setting in virtnet_info Date: Tue, 23 Apr 2024 06:57:41 +0300 Message-ID: <20240423035746.699466-2-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: CO1PEPF000044FB:EE_|IA1PR12MB6625:EE_ X-MS-Office365-Filtering-Correlation-Id: 1079a917-46f9-4e17-ba70-08dc634995d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SUNvtdRdsSP3LlLwq13URTV68oeQpy1oxkEBLBRvdH5Qmk/03OyH/fCvBm8jxO00TrMADkEyEJr3zD2YtJHe6smtVQUHaa5dNR6lkbmo1qrXoYILYEf7LLqs9+OQGjapnopZNFfm9vFsoBGqCAcaX3o70eL1CRtHzjVlvfjkuMdjr+pI97vb2Rv0etncWD2bO6wdLlLsbasi8gpgqZaH08psTZx4BL5W/K5dgZV+fgcCqif0F/gjL2bQtvj45iFooZTbd4L3c6p69QuMKpTuKGLHmY83FFN8CjpRDZsRbGX8+A7pcmWVauLHzk2rdV+a22DrlXXt+Hrx6nssP3ZxYNxTGsPck1nUHsDDwNvZfyrsyoYdNfzGMwDNzGAGUQ60DHZU3TN3oQ5xBxgTIBydCZOwqQrJ5ZoDoW1u1RlkxF5rGxJiHD8Rsi0dxWg4xMGo4obTjoljL6yBAtBzjV4EHxFfJwertdC84hirP23mBbW2ApIHq7fNUSj23lVqqe/VVk1PYtWBqngoB28ispxg6wJY1vjtwShvHTBRc2qLHuCTu2xgFfyo3JSPF4Id9tfrmEHz0MQyjAImfB3jVAZykkHFustLqWl6J1snxi4Sc8KyzfMUAhH1YucwVmK5Dz76hzDZcvnICXT7knxuQ5rmo+tS+61kd7JKelP8jBpLLUr86QfqEqt1CVentuxI0afUMDJvY93e749bHeyg4RewhuzDDWgabkReROJ/tAnbVZYqtkCQmYkgyJi2YbNTIQ5gaXZmBwp8Jr9VKIo1ZbS3ph43b8UfPI6I2PFbxHFlldIOJf0YSWfWv76HD0u0prm1M3XVgBDx2/xf8sy1sVuBI3c1WX8IVBVm3/LTX4i9coiV60sI9WmIXTn0cGg8z/HXI5lUn1aAKnaw75qZqI4xExvIRNPLObpCXG7rA+rbECcOwmidhv8sv1VBik0aVgPR4aN79tEMtnVNsORBpawt1FMBz0c5rfDSizRdng0B/6Z8igAQTM2aVrDn0rUCnM9J0Fu9tTt2qS/q7One8MangxS+/B1/fn6zId9iW2UAt029sn0bzaKXkiWePERStLx/5FYzYWtr3mMcm2hdZNKW7CGI4ZxQl1wZ5YaNH6g4OpnVNpvuBQalrCQYmOsfgTO1hh6gXRtUrFro7aYv8Iz+hTG/XHXyEon49//AHinKPIuvSaNFL387aqmOWnKPbXjrZ8d2VFxG5z8RwWYG4NI97sp8zM/9YT5nblTvXU3av//g9a6GxAgPgOZ6vccmJDAWVZlL6kSCfCr2tSEcGMlJmJ+R+gAX4B30KmmniCAf4VX5Ii4T1jGDcz0wdNRKlDTKwNI9whrlFt9SB7UVJgN7JuNJvgqRi57kIl2UTkVGHF4= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:07.3486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1079a917-46f9-4e17-ba70-08dc634995d1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6625 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 115c3c5414f2..7248dae54e1c 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; @@ -3819,7 +3819,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; } @@ -3831,7 +3831,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; } @@ -4156,9 +4156,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 Tue Apr 23 03:57: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: 13639297 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) (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 657821CA81 for ; Tue, 23 Apr 2024 03:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844691; cv=fail; b=BNLjhnHYn4WZucMAE/8LEekfaJ5ppQHsxqwCn7BUWkDKR+1B3CleLgBOlxkCZtH5vHHiMaEz4KZ70mdGZ1DmZSYgINa9RPmJIUTKbduAQoeZY9CCmfesOMkEJqs9jX4NwNELVp/JTldO07W5bxyeVJqL08l0QCgI1pAdhJy+Qf8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844691; c=relaxed/simple; bh=faPBhRiMloCW3hvR2ZjSMcYeF3YINQvYToCDvrMYfK0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ALVnPCkj6ZEQAPZgKoOhneH+AWlDz+wV4dwAC3B0UoTmOJe5l+lb3+eJwIbJYbOMVlhLDKTDPqXa8cP2KRGJ87vwDcnLgxGQsuaJyvyyWzCMLEfEjhguqFgP1ua1TieNlTO0ZRPmYw6cJBsd2aByapKaZw0DZkooFBGcRFixJEw= 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=Huv24+/b; arc=fail smtp.client-ip=40.107.92.83 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="Huv24+/b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oUstl8gKHlspEd2yM2C9ulBldMjaanoOuiW9jSz9gC2uBWht/xfSW1luQHu+KeCWthmD4PA4zihf8xjcEPHC9tc3G112DO1HCLrveQVY7E1N125SnpAF9KLU+LclIQ5NWxukhEz4DgJZzmDbe0fG66EBUVYFke5pNW4U9NpQg5Gz829gjAzIvF4+gj1w+V/YFmieXZcHVA4ELgPBIi1P0HZG5QEh6zOy17CdIIGUkKGycJ7nqY8nNL2euoCYVcfLiRfM8Dk37roqI7OnMemVkylEMruGT6lLDqcY2wp8EaR5DAkICCOGhl6ge2Wb0bCA0317paQleuRzoEubvcK+aw== 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=JMHqiEPqezP/HQsOKJ08ZsTO9mxHb/ZXdGEU5bUd+Fw=; b=fCC/wXd689RooWSBG1nHeWeufiJLmQOC4cEztG4o2Fon5qlXMbXn7SUKtMNQz3BygPFpyHB01l3S9urHzd1SnJ2iGbsYj0LgCjKg8OS2gqQyHU86xb0v8KBzPHKQld11oSJ2YvpXRhdXvZW9eaiLE9UuWxZ1H96nd5LNchtJRcvBZmnDDOXsrhcnHaFdX11xAVcjTD9PFA1b36LqmaTWxDiVuZe5h11gZ9WTa3NRjoDvZtH45i/zMUKLumWxO2bPLw9k/thow1UkntwvZ7f1wioM3ayiIZJmPdED+E+5CsNousAFOQxMe6rCbB0Ff/hqmxqJD9I5CSYOpPEaTdlc4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=JMHqiEPqezP/HQsOKJ08ZsTO9mxHb/ZXdGEU5bUd+Fw=; b=Huv24+/b/szZPGf4RcYsaH6dsUA3I++QhG1InJn4fjo1L0kHUTJbQB1pFsnTodqhUAYqBJe+pq1Hqw/qbS5tGPefns58wwpPpP2TFw7nKicOLTtYK5PSyBL10DhUndoPgoBATDlgXMlo+1Vpi8dZL/sL2KBYwV/EYrF3bHBIfAAFbddHxPrXs27/dZeLUqUJp1aHWsNNEg6uPcmHElCZxZg5NnWdF/gHyy2eqiKPOTIA7YFi+9xdaM8z64aA8dWBctwgxvNvv2VMDpXXySwRR9Nh8bbnMzZbojUjaZPMz1XmEeKAsFpWfesoi/hYQtiMZxjRAlbB5KMClGF6ELqi4g== Received: from SA9P223CA0006.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::11) by PH7PR12MB5829.namprd12.prod.outlook.com (2603:10b6:510:1d4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:05 +0000 Received: from SN1PEPF00036F3E.namprd05.prod.outlook.com (2603:10b6:806:26:cafe::a1) by SA9P223CA0006.outlook.office365.com (2603:10b6:806:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 03:58:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF00036F3E.mail.protection.outlook.com (10.167.248.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 03:58:04 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:56 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:55 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:57:54 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 2/6] virtio_net: Remove command data from control_buf Date: Tue, 23 Apr 2024 06:57:42 +0300 Message-ID: <20240423035746.699466-3-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: SN1PEPF00036F3E:EE_|PH7PR12MB5829:EE_ X-MS-Office365-Filtering-Correlation-Id: 68146eb3-de5e-40e0-7721-08dc6349943b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v7RrrHcOJyTb45UWjBTr+JTJvmhtNgFrxIH2bmrfTP1wEcr8p7wZJK6khNgl9gjRYsDXI6MXF8drpA4JLSdLsp7r2vvBWlBFncZU/WFpRob9i+p5O7iRprOQqGqRTspb9MzieAzUAba+7TUFGLIQ+GyeMErrfQfj6dSUfNxMHzueaQZgqU8orUqATdGgsWBFD3XckdRpa/lhlNEmMDjYl/6dY4G+iaYp9zNdwsc9o+gZXCU2QPX+zJqyIXftds66L74Jy4obgFqna4v6xXHguafbV5sdErI++4e0IHLRT6umlVGXxK42/u9qnGoJ6O6HyB5oniQdjuifpVvJslwxUqj4fl670pHsO+7iaF0lc1Z5kIf+kEjrM6uWLNNikInK9ifSQe+uo8ad1+jsIgqKS7kmGmKbquXyhAKnw6cdWo9AkBnq8Qww0rt0LpHDxBSJ0XIfndRTL6YgKFGz2X/VEDHaLaFk23dWdz6VOhFlnXrOJzE9P0x/vIsdFjMV/xljLdAF41S6BuRIJZAyNMpqgs830ba75tRn6jDBMY2ovrGw7sb7HxyR/MpmBp5R/wIP8gtBGGKF/lY+yslLG6igRpdkavzTNCWQRlhi90rSk51WJF2AUREeS4R513g9OG6nieTshU1zlMz3mUeDSoUhtRqi0bTXqQnvr6ssD3jxV/qIoESUUM3nCIzMa6UjnMFfZqzQCw8l2A+uI3xJsWWQdfsX+vsRiPiliMEtIAnWKpN0VIGc2gr5G161PYi7h6HsRY7U5vAC7upxseiCz/iyKwiR0G0NMufGZzwsbu73MjpKMvkqTEMT8WYMxxwu8QluL+3GHSA6mfUo0n7H1IaCUNGSPMLXpbjVrybmGyR6fCg6+YmU6qufgvcfH0VkrMvm0HRPB2HOXgHjgm6f+R3d4FXAWJvrYZIuknR16pf17J+adVl6fsUbMxSpNG109prFsbY5ZrIEEv5V08lHbd8z2lNymRj2T53H0YrniFV8c3kx5ugqKWZOKO8Dpj2o1ejfxs2+KeWINCnYccMDj4yrTLB/NsB7rXWHe7oKjObdluKUQlpQ5u8iYd1oVd50F2d5M8oqnXf7kUbAz+SBMxszKhyvj1hVyISirO44HegsHeENVPhlAd0CShYqv6etk2xL0b4YR2zaYbhaD9ttAQH61yO40p76pkOswuNNtOXYxfZFfoXRFm4FQM/6yJ0chLbgqh+cYtBME6M50McxZ0TegMXnsN3Oqf6L9ghEb7iSdCiKgjqMxSqnr0wylgfv1y3Wea2WDr0wtkelJIoci1g7tCEzsvuzzdNpgHT0pooRL872EAcKMLVV6N/niwe2q3Hglfal6/DRoGueOzafkyVpjEX5CGvifcI/B9sDITDjn5y1KkZ36SuNr70bQMFxHGJp X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(82310400014)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:04.9049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68146eb3-de5e-40e0-7721-08dc6349943b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5829 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 7248dae54e1c..0ee192b45e1e 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, @@ -3951,10 +3984,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)) { From patchwork Tue Apr 23 03:57: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: 13639299 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) (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 E25101CA81 for ; Tue, 23 Apr 2024 03:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844694; cv=fail; b=ldt1uynndwlgZzuMuKWhhxqEcTVq5Pgs/ErzZnned65hfa7JBwxQBXnBrmr1CEhDCuskMWNGN9YMZPZtmq9+ehO+8lRkQk815kVJUr8aYZUaIsWTlX8QQfNuBOVRXxmJcygb5Ocq8Vj1/GPutc+xhibuqGUQUpcPKP+EULxQWeI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844694; c=relaxed/simple; bh=lNIkd0Ef1CCCXqTOw0sqX8pStfaVl8mJanbXkRWCZXE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cN+0hiGyMz4jO8MQdXBqLczyMYv2Zww+VvSnbqZplOdZFd+LLfApQ2namq7ji3IzJNtnEZYXqG1MMFqxfN8SnQZBAq0K2m28k65KgmWVg7AUBdWGUO33r1mP0cZ3PrWLyVNGZTsyWwL6a2wYAtz5nOd48mHmumEYw9zlJL2fS68= 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=IITsY6BJ; arc=fail smtp.client-ip=40.107.94.79 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="IITsY6BJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8/3j4i7po48QZ9OnNoUEAl6kyKUn4bowFRAa9qlS/LX1gXZ4XEC7pjVexb7zUPdtetK/2zOpGtv25491rxyamyH9Avrt0f/c5dfhvgAPuibUrYImg8BrovnjG11iqyIsq7ht12HOUfqvBqmAjEAp5ou5dQMDqXZmQiyqygHBtCyzEfdWYbs61Fj3kdVrYEUid1vEs4eUQmu846c4ko1vTDs8JxZCpNT6c3vrccH56PWkU46eo55cHu/Sk7ex9VcfwGHPmGNzqmTndbFchbXJ+tGBca4JcPr4sgQLIggnx6ryQJJuGTw9lCTjGXgzyalE0+yMW5ZhAm3VPoP1BfkUw== 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=bALITkeA9lQpug1dEWBFUQao7EbIjmzFU97QKQyReLA=; b=jHeXnIQWoUTPGH/1S/X43FveP5sQsD7i8lxxDJvnDGJI3tZZaZO7jsksQtlfXsNswNvi4nPntwknuqqOlQKxWuCdwtTxjddAChpb3RgU4gm6HlgbxwfZpV65LJtq7LEeoFLL4yqKIX9mGPYb7C9CsINW3PTEa/3jY9OQeNsRLUF9Hos7eIoP6OZUgRPsU0sb621Q3pQJYxVxSvakAbxgDm4tkbkerHLuIrYqoU63dO2o4IqJLavobTDFs16kXfVBcvv3WCzBW5G/khkpPsqg6fPlB1tRmsyR+xYSLi1tO9UzYVv1cbzkK0R8tw22V5S0kEus41SQGxovS4eHm5AoqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=bALITkeA9lQpug1dEWBFUQao7EbIjmzFU97QKQyReLA=; b=IITsY6BJKiX8E+nz9r4zFOKOQIUWAVwqwyquyOLXw3hA7qrX573lAOiOIs+3rmZ2W4ZANufysSsy8uUP/r/DmEusgx2HlNZ+J4WwkCG12ddDkJ1in9HDQB/ZmCpTpMjA8TvD7cJzZU2ITImjYoZpp2EamNDofutmjZkEr5JYos9KM89FCVCv7pvwxccOYegkrZc+yqWHF1rUHzDdr+hSLXGPSBWXmpkR1aCqcLgc6jonld31YVmhvRDZPggBfWdYaQKokyiQlWBo69F4vJiU5WAfolCME5cUfu0XkzSlpfcJUI7HJgQCS4hch5VV17is7xWzpKe2Tx7YqKhFSKF4tg== Received: from MW4PR04CA0243.namprd04.prod.outlook.com (2603:10b6:303:88::8) by DS0PR12MB9347.namprd12.prod.outlook.com (2603:10b6:8:193::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:10 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:88:cafe::a8) by MW4PR04CA0243.outlook.office365.com (2603:10b6:303:88::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 03:58:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.0 via Frontend Transport; Tue, 23 Apr 2024 03:58:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:57 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:57 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:57:56 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 3/6] virtio_net: Add a lock for the command VQ. Date: Tue, 23 Apr 2024 06:57:43 +0300 Message-ID: <20240423035746.699466-4-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: CO1PEPF000044FB:EE_|DS0PR12MB9347:EE_ X-MS-Office365-Filtering-Correlation-Id: 0671bda8-97e5-469f-8064-08dc6349975d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I5lS0r4VKVBy+sQn1dp3n0wAQRxks4IYf6/A7WQrf2lBTkonXdhQxbh3+QZGnLcUb/uZFNQlXWoFgXlP/7bNVWqmLndgPKVsNvD/rNWaDWvLBaoTmC1Q1yhj6O74PuYW94CvaXIoRyQd5y0aiyGkEyT6tAp3ZAMqjYvtKqVfr0xKm+6CHJPQwvC3fG5AG3B6laROucmJn1Pgt8tMKX/M4zOmevtmJ279yNmUVI4aR6qd48WtKeEhN7Fnx1heTBdzsT4ardybtsgqqZnCSSDdbWdoXDWgCT5BmhhQZOP9MjSK7M8nNR3zOkghBvaBwuD7jkFnhQiNrkIY/LAE2uMuAtGCxP2f5msh6L3y7Qua6vYgxZrTdy46P/scy+jQV49XnZ4sJoOQGDi21sd92bJqKqPOrxXsgWZRHgjFWv4JMdsRujXacy8TvhgQ1XErX7AunzSmXR3yiL7B1Qh2be7j/m+PDCZ/3yZDGXnvMs1CDZHwZoqFCXMlZFP8mm+CxSXXzvWbHyemA4QIkkvEY1GREkRSDmEJsXJuzQQKycWZuyzvBLR7Xof3yXxaNHz5V0ut6zv40AscdZyGmMCNyUKQfFWYJnV0WBnmeexpofEFtdQ8y8boIB/DLgCy2mb8YlLFjbNLAiT1+gkG9hRN0NR+uip/zbp4d4YLUi7bmyvUPLJcjXw81Y13NkBHTN8eRPQ7WE4f9CFjAvakdJTBKmWSwGgEBcjNM6wfVYuKq1hgJZjMk590b2a0Sp8VEdDEWeUYLr2zFhY+pVCm+B7NwFbVZgKzVcrbCis9kB9tglKszUuyXRPhBOKk/cTwBFsQY+RH5aAolQrDrhLB4yW14XVMLJBMG9cFcPMXEBsKeXvR3x7Q7hmnCUBl+WpVyvOftoukMuTje2HEnsDzO+4kn+rIV/jO/hPAobcMXuMaQaSyv6sJQVBlOO1OUgFNyxLGEUrjp0BapEaMkaLrqU/E//vXLxTxNPT2RsI78rXmO1NGskJtZb2o3A0k69iBR/Y7LxIjFyjbs/kuZX/T98O61QXkoy9my/ZTJnnaVU2gni4YALC2Z7SKvCW4OBAvDIxSO9Qun5P5zgBXNNh7lTY3MhLr7Eh7jX2EH+qQeViYDUiQGytU6//U8r+jK2zoBp6H1Sik8AuqKizM6egFzG/+6baZYaz789iPZPqqNh7GgYGF+2CSdGUrrvtcmZJc0fTGqWLYkNVJWAIXGX5bxHHmSLDl9rgM/pTtXOGYhwglcJXInc+SsqaLj5UiMpLBdHEHFVvEDXCPXnC4UFr5UcQiFr7SpL9Bdy5fLgYmRjg7dvLNRtjF90Uo/y7Eft3M438j/+I3JpgYWEv6UkcjWdM4eFeOMSmq2izrxBJqEiEmK1JhvKNbjezdwzHduRloYyyMK0tZ X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:10.1298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0671bda8-97e5-469f-8064-08dc6349975d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9347 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 0ee192b45e1e..d752c8ac5cd3 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; + struct mutex 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)); + mutex_lock(&vi->cvq_lock); vi->ctrl->status = ~0; vi->ctrl->hdr.class = class; vi->ctrl->hdr.cmd = cmd; @@ -2548,11 +2550,14 @@ static bool virtnet_send_command(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))) + if (unlikely(!virtqueue_kick(vi->cvq))) { + mutex_unlock(&vi->cvq_lock); return vi->ctrl->status == VIRTIO_NET_OK; + } /* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. @@ -2563,6 +2568,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, cpu_relax(); } + mutex_unlock(&vi->cvq_lock); return vi->ctrl->status == VIRTIO_NET_OK; } @@ -4818,8 +4824,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; + mutex_init(&vi->cvq_lock); + } if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { mtu = virtio_cread16(vdev, From patchwork Tue Apr 23 03:57: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: 13639300 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) (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 E42FC1CD3B for ; Tue, 23 Apr 2024 03:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844696; cv=fail; b=hi/XUvsUo32FU9ajKY54T+8i3kpVr6AG9WVjoFxwfCXjomn2klVrvWzhXd9/5/IXybeoMgABahp0NnixckPLI3uczfduf/TQdvWduYM16/cEhdKTY2oekAzUMvZpnpo+PfJvqLsr7kIPXNcSpxeMcNd1wuSLXNUd5NdlcunYaPw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844696; c=relaxed/simple; bh=ekmy5GIxckeBoex3o0comzFUbdMH7JBLVPt2nv2HyG8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UqP8u9TTf/s/B88GWtmq9klVHsxyPEx+QKHjZt3r5vNDICTJgFURIfJKvQiaMTpkSmp7AG2JgnLySUoyEw29HjlkRKME51kspIRNmbeoyPfYAZ9biJxabsDRYtrIM1nCNXgH1jZmzC1+Bw8Vd8p+QW8gKGgPx/0hlw5q9Jbral0= 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=cQtzW5RD; arc=fail smtp.client-ip=40.107.94.59 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="cQtzW5RD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bjCtlLEHGQoonL9InD50PmW9zQWXmPS6MEG6NysWTC24lh85MwAiWgHb+ba46JF2wJUos4Kql1qApyHr52BGv+oJf6u3W6u8a8AH8GTIw0Vc/vw6Zg66fidHbs2uwEthONyno8H5N+96tzYoJh3KEJR08lIYXxgHNPpFU2DW9j6K5FcohZpe3yOYcuxGJz+VC464JCp2HwOljV4um9FDJIveBT5ao7NGPqB+CHapm3jBU4x7AokMHhZLj6s105+lwUk50CALxU0WRn4OIoveIDyTV8ECXsenbuoUJypAKyqh+VfItZCv0k63gGQkTTO95rdgmKsMTEy29AYl0V2bDQ== 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=uZLhlR0GLG/5JIzlUhCG7S18P8sFmVzFuv+QIsHi8A0=; b=O+faceyNKv+4Cts+0p8hq9FzW+6YhSrAZYx42DzTWtfEDXUMOXtNCj3MyWKTJk0eyszyVUcEYC/VTYEQkwe2+gFDGxfc9jumPYfIOEp89Xy0RPkXpzdDbHzVCUk8NgjoYcgI23uhN0KehHuWI0USjwCq23A+njB6e8SMjS5WrYuGaewXGCsoVKhUR10q0fA8lzx1Zv6LWs0Dq4Yz4yKc2S5vbAX9v3Wq/ZyWwIGBiuk0mx+kocf2rGuA4lj4OX7d0USrqgBVNX6RRREk05BdAkuwETDhz0+FqivYyNlzlnkB/YjVKW+xHZ2xYQ+E3jr+6l9BAkdyzOGuaILoBwMTqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=uZLhlR0GLG/5JIzlUhCG7S18P8sFmVzFuv+QIsHi8A0=; b=cQtzW5RDaVw5J7BLP946ErgVEiHnoBXH/kS85ijFjG2Qc7/SR2l3xpDCdHIjYBuld7/e20PVpGtXUv6mtF3Qte0FrW48pGkeYUlrrYhsgXkwjcF3Dh0FOzSRDracnCNTLr0f/f8YwWjkmbGPUB+i5wbuqaJ0uNI/ge8jW+q5IwpfbS7fOHXHDbcwYPjNzltIhZ3RMnfFgLK8f0isuNWwn/WvJgTe/5UwxZVmJuvWi6Fid0wOmrWwbDPVS8HCWEx21aV6r/TL4DSEpVrD1xRBsI93TDefPXUFihmcdbDYYGwSwnaojCU+72efbRPmTHcNLTY00nPdtlqrJfrbOZxNog== Received: from MW4PR04CA0220.namprd04.prod.outlook.com (2603:10b6:303:87::15) by DM4PR12MB6493.namprd12.prod.outlook.com (2603:10b6:8:b6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:12 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:303:87:cafe::6) by MW4PR04CA0220.outlook.office365.com (2603:10b6:303:87::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 03:58:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.0 via Frontend Transport; Tue, 23 Apr 2024 03:58:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:59 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:57:58 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:57:57 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 4/6] virtio_net: Do DIM update for specified queue only Date: Tue, 23 Apr 2024 06:57:44 +0300 Message-ID: <20240423035746.699466-5-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: CO1PEPF000044F8:EE_|DM4PR12MB6493:EE_ X-MS-Office365-Filtering-Correlation-Id: e8b150c0-ee72-4d8d-a2ed-08dc63499859 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: khEkiWa0FMQsgm0P5FNc1HAfd05vllNGjrSmDxlUUjtNgvGrxI5DV/uW5rHaQmaPdKLjTUWLF5rtwHHOPGYBnwX4liVpD4ibQouZQURF4IjuLcAlQK4Fs+TPmyB8nZAedKUVzXu8WWTupG75b5FfUKCOfIJzsPYs7EOU/A/0ibfLaWF3wvmPG1Z7Kq/paAjX3LJB4GwaNLLS4VKH8iyxE1iAh1XqXJr2UzDaYBeB37rKp95VtPiQ0VRpkcQordW4qJc2xiRnY4BeMj3XjAMqDAT7XiRMHttaWGUvT/7rWDkV1k5EOSYfzduOGRmkCZdiARhdtNQL8kwrTddZL6GC9BcpzqYZ929ptqmVQudJmBGXnmnl/FK1MCnnXOOGX3LGQBcpmDRJq3BWLx8Ft4ZSX3AOAiB7RXQK4PFOPmVuXk2fPCKJA2G9Z20ULqj+/sTpkaCsGHjCE7tg6C39KvB32FUK4b6jOqNmSc83VVHVOk+gH84SxU0S4ddS7vdZ/rdXP39giC/zfAXCGPO8dOcEHj84ZyD/tnDZD/5lM/dEPouZTeNwDJmW4KbGiK45j4GdLy0iSa8hXNObkiSf+E0ylp17vrXQpF1Ihp2+JgpecroZ5L3TFMCiPJxOTj9JOUv2bd0yvNgcdJccjOXrhmhmLfn/UKrk7VbPaivtNxKPK1pMc3DzkW3jystNRoTnPG8qWfy4GkNFbsiyEBhfUdPGBzZAjzCY/dE5ltGbFVZSIDVRzAinO/AJB2e/MWpo45BHRqRtoVtyKvSRzbJy0GzR9VgLkUGtp4lEoqEPDHfEBwapsIpEMI74mhzVsItX8/docoWOBu+aMtkCyN2HoGMyHZA5+/uwOsh0wM+TTrkqfl6ME1F2+EG2xm1oUdAfz5NPY/Ox+bpiKYyEAivAkksVjkQI9lBA5+gn6+supKLAAbcAJ/nM8PBgyhijPE+LO4CWddkFKCq3czeCdvkGJ4H0W8j2EH1cvUlEOi2pWtrg8SouuIp7S61bihvy02uEvmrG5BdM0OaXVSvbMUtVGsESqxw3qU+IhFOPZ7YoGIfEa/nBdgse7mzboNYUjXjql9yX5kPEOeWhEruFOxQHg6pT+0N5M/Qvjhia0CtLFsq6YDYs4aHP3p2y13RqTvJ+Om7VgrHwoWpCx0DnDnbPXAZdFaxLlOJvoHiNUD4SAH3l3Q8WDFLFPDC+oojmxTqtSgxfl4SRjFfRC8L0/NX9kTFMLLuchK8J4DGEgbxKO0TrR2asZB899MJodxLkn+XXinie80q1jbypAaIuSa6GJyxP9FtpJF8AVxQ0on+GzxhcO2UNaGpl2+GueuiFMrm+C35FrWC61plPSfckOfKsvTxiWgY57fSE7gWhowhwt9cU0gZgQfv2Z/TrkD29phpH6VE9 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:11.7978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8b150c0-ee72-4d8d-a2ed-08dc63499859 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6493 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 d752c8ac5cd3..af9048ddc3c1 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3600,38 +3600,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 Tue Apr 23 03:57: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: 13639302 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) (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 1309C1C69C for ; Tue, 23 Apr 2024 03:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844699; cv=fail; b=A7sbZ9EGRFUSlgAMZq1NFm6H/YsKbtwDTACzV8ZEsxtDfh6fyjZdC0ool4DpmojGRbtEQNcSSqghWjBh0+JanAnNvFl4IiEnVyBm3O0IxJzb/mfJekeo2/t7WSHXJDUdghT/OaUQVadAzyof/SghFm5dBFM5ijmxIydgqyCbqyg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844699; c=relaxed/simple; bh=XstW/MQvGSHDxiLI60FgQNykK94EKIWwDoliVUChLug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YPpkhyhTM93GsqO7D6cmA+mnSKAaY14p5BzV1ruere8w/hWTeaig5LqTG3f1v8mBsQ4IUtZXgThhdst2iSPev5LAhIZdgE4XBdI+i/HvCf9tUr6TXupX0Ui1IcYZBIR3+bMZ+sjoZEycGEUoIOQ/zUH3n/F5i5sIc5/xt1Asllo= 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=WOZgkgV7; arc=fail smtp.client-ip=40.107.237.80 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="WOZgkgV7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0Lg226gdZ+OK+XvBxsPrTvFGKnGcalhc9xFmxTveOlsPad1x7aDcEcCcAIbagfAqhMfxOGYagdnvW7cBWZnYBS2Opuc7q81aH41k24/AC3zDeLYzlgFHS6uRGVbRvZroBsuRhPApmb/9CGtDEcWS69c0K0wcA2/TmZY8kedVdd3AcuD+GUX2KQ/zCIDUzsF7fWeQXxUyeBKcUzchZ5+sEC+x4m+NvnSOMLX9AGvOenJU1nLh+OiW/xBldsmUzvn4AVMoYrLeCfJsezIBP10VAgsTOZcOUffnNoJKrQRoA+78dJbsUZfkURdKWIZovWJ0nYoeD4HD0NIBoV2UYOh2g== 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=2/8QLAmuSPgLAaJmfMTllpe9B641KaO0vQMvxO3nbI4=; b=KnbmkCyRwW0CjLMvTqyD1as/e3ESkkI72S9UE0sAcTduIqT4q3CD/CLc+58ZvEZZTBy1gz/YaAUvQVRGpx0X8/+N/W1Ab/fZLptstGJNYNDApPys103oyNPkLmIxyi+z9b2SluDuQt5aqsEuvd+L47RC8RJbbWcd6kyg7YGLzJwECgaJgMcZHKtAw0EMzxLOW61LcD1zieGYxbPJ5LQJdQ8/6Ytmo+OoZt/0kRukx44cAeGvQSqhHEXYZOL2J2q9kUziY039vYL48kugMYKoK5aah51J9yONMOM6eEjW8WuG5c9vA8mPITsxWFYygyLuO9se7MGxzC+vSGGor6ElLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=2/8QLAmuSPgLAaJmfMTllpe9B641KaO0vQMvxO3nbI4=; b=WOZgkgV7FivDeSmTzCU0MtFj3CjBnNhu6AiIlyiiSBLtNG3G6s6TnTHO3ZqQgPf/U3ju2HaUcUAY0nKROlndstDzmH+MeUC3ltrGoSP0W/teKiweRyAojbzVlnEbfwaybNWTRGOJgxW7L0JhYkvhrspGB/1IOL9Rprw91vHgWjMM5KXDyHhJS1U1oZ8coeMwByZnh+49op9omN7WAwJSsFbWizFUmFfhW6jFRyncN6dyD4llw3zCKwT7E/Jho+xe2drLhLhrKMomVunM+nTC3fZ6Z2fhIDCKzoO0e2+K3gO/aNbjyXcxQYgqYv6niYUmaDjancy8bjo2oUuW+iIq+Q== Received: from BYAPR01CA0014.prod.exchangelabs.com (2603:10b6:a02:80::27) by SA1PR12MB7175.namprd12.prod.outlook.com (2603:10b6:806:2b2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:11 +0000 Received: from SN1PEPF00036F43.namprd05.prod.outlook.com (2603:10b6:a02:80:cafe::94) by BYAPR01CA0014.outlook.office365.com (2603:10b6:a02:80::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Tue, 23 Apr 2024 03:58:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF00036F43.mail.protection.outlook.com (10.167.248.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 03:58:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:58:00 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:58:00 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:57:59 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 5/6] virtio_net: Add a lock for per queue RX coalesce Date: Tue, 23 Apr 2024 06:57:45 +0300 Message-ID: <20240423035746.699466-6-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: SN1PEPF00036F43:EE_|SA1PR12MB7175:EE_ X-MS-Office365-Filtering-Correlation-Id: 4683f3be-0a3e-407c-aaf2-08dc634997c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: udE3H/VlDsn8l94nVPPzN+VjLnKktKId0bq3Uc0LbAfE/QODtF2meHNZWfmLYfR8xpuNThOlEXZtA4KDdd35ROBKumq8cV+WqLWILnWGRzSNuD02L094jNlDLhEU0B6JnL/RDfDB61sUCicrjVvVYKKuOYmsD49mKs1b+q6bj5lxI+cZXyA81dqNXE9PQmYMxQlHthkSLE1RZY1hkwlDD2fQPHRLkrco6Rs65j0FsgcKFkLRNxoUpTIL2SLkiZHgNoQSRWwQqA0iejHXVBHqWBrt2WoliSGXzwhLBlE4SjcR/Pyl2RbAEqySMjR0WWZOqwiwDyj/rPwydvRoV0pAekHaMrj2i4ORqzK5SXCpbPsPiDPUTARI21I1HpBvoCoQdlabJlIL3PifgsAZRHazUwAd0QlI3H1pvErn+FcrsJJ2xJEzune9hRbe5xaGX9bslxP3pQnHifIo6JPLZC0aLAFOp3MbIHsgRAjkN9XGFCNlHJnKC8gBN5fij5W3RHx0FQH4p0E3LtUirdM7XsyO7+U2Bi9oIvlHizdQT0jxUTxq+mt1odFuZ8/91oJl5OTzIAfgTRK3ICY/8QQnbnfpMQ3ae7mcxpwxdO4eJ8j8f3RLqCQls4+EkwdF2TVxJMtvp1oxkNVlTeagCQRaPSNZhTfGtB+FLp4O9LDsIGKE8ZPgwhTBAmS3FsgBDdOX5BXK4cqp7THFh24kHvyw3nh0CeD6apotb0hbuTD44eodTgI/cXvNQSSBzLE3uCfUCSLShBuneY9Ac0oVijpqGGVFCvInc+2vZS/mgQ45KIQa/TVbGdGE6SfV3/zOrXsYbyd2G9qT1qsw4cHgpUGJQARHgYzAxRKIZxvozu5wXdPnR3gXKEkYMiAV7Uca+Xff1zqRsOmlqFrp1U+XW4x7pLLqd3VeeZn2arwqgk2AlByJHWc+nHPByriO98Ond54Pt3Cndr4/rrw0WiK4x+SUfofkep9ObP1bIpAyEgUxvrO7w6TeHqPxZ7EzfDEpvH7/V8hwa04LFmRXb98PYi1pqh16vheD5XyRDX7gekiB2MoifXK9vwVFLOGpgu+xu4kwEKWersFnWkztRkrMkZqKu4YJkDRL7fB/eZtdW/TRlgDDGuepLpYR1fSMtp10teihb93mRhQ5KZHTK1/Gibi3qdtMcfM827IHyqtvoXv7tgSFbPWNVB8MMVvkURv3Q+zNSMMyrdhPLxXB5iSr0RW/3l5afYlu1pmoogf0u+VQeN7l+9sXibZes9++9NFDgZnQEeHI5StvdItlSeii5eMfBMWF/uFZcJxApTuSUnbtA1OdwlET4vqNhynavTE0Cjav2xxVFY4umdnbMVLTmecWFdm+roPO89BCtj1ZM4Aytv2V7IK1fagCsHnpcVuXdSysPgLF X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:10.8569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4683f3be-0a3e-407c-aaf2-08dc634997c7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F43.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7175 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 af9048ddc3c1..033e1d6ea31b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -184,6 +184,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; @@ -2218,6 +2221,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 could result + * in a net_dim call with dim now disabled. But virtnet_rx_dim_work + * will take the lock not update settings if dim is now disabled. + */ if (napi_complete && rq->dim_enabled) virtnet_rx_dim_update(vi, rq); } @@ -3091,9 +3098,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; } @@ -3472,6 +3481,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)) @@ -3481,16 +3491,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; @@ -3508,8 +3524,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; @@ -3517,8 +3535,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, @@ -3542,19 +3563,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; } @@ -3567,10 +3593,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, @@ -3607,6 +3631,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; @@ -3622,6 +3647,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) dim->state = DIM_START_MEASURE; } out: + mutex_unlock(&rq->dim_lock); rtnl_unlock(); } @@ -3760,11 +3786,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; @@ -4505,6 +4533,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 Tue Apr 23 03:57:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13639301 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) (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 9F10E20DC3 for ; Tue, 23 Apr 2024 03:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844698; cv=fail; b=ee/vsVevMw8iCKURmORB+tRy7snQXZfO03IvvO1uCmgix+SAQvycrF5YBhPFngQgtq4OeQh94gOChLNbswxpEGhiyqsKLcnTA9jxHj6XVm3P4tFKjS2JoI7CUDrFX1NfskTKDqhZvgHgoMSJ6PA6UJuwkoe3b9zT1m5ZXkg8qGc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713844698; c=relaxed/simple; bh=e3723kHlKG8NcoBJ3ZfxGxf8IR8Ix2c52EZkzSfzGw8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NV+6/8WmIPJcWhF/t9LD1204MjHFR5+m+g0da+UDKENle3rODtlr0dFfhbt9Sz4UlvMgPO+U/Gc76VJOx6GG12+BTIKXdf7RTjK27khAYpVLae7msRAZaZ+jIHef+ym1ea8CqCe+VxIfHSz0WWb0bqqExZEQ/HzAw9uLdetccNg= 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=kGfyVFyQ; arc=fail smtp.client-ip=40.107.220.52 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="kGfyVFyQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Df4ItCBNXEMFVh2nmJ2TeqRYW+Se6kHP8aJ3rwSw4iMY53hhmawuYmrxyXWFc3XCnz+uwb5iZLF7nw5lH1mJr+fHbDnf8QJqmf6zhM82eIAm+cvM8Je6H3OPbCrzO8T3TjBRYUKhoIbqC6vIK1B6mEqpFgTkkRazOzH83Kd/PICPYDCOZYD/f798VJNvCI2PIEYnEZ1MM4yzyi1bGk1eaYsidX6EiPj+v8WwIX0gk+YWKKQYoLEFiNJ3LHZoniZmCqS4k9Xz/CQsw+MlO1Q/vXlYfe9qGA5CUBIun/YTaq+By3QeFSUL40ZXwOQR/CyjqpyDZBGcCIPq/gOnuAOrlQ== 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=EWnepMLB54LcYV4yQ64z+NzgKdsrVZmz+dTYjb71qBE=; b=Fy8wvAXTTlbtDylkPaBdywy4rBTunQV1qASGxfQ+daZD8kQv+8fx4T+YtT9a8ejy1VeWZp07EHLq5YA+aLVh6VCqhi7x6qll2ON1TZoQXhnDV3c6GahovlVxayhCx19kBlCW2OK8UaFsWtRFnO+iDitiANz4JVcItQe8DM5/tQ7Fwrz1YH7bZh8EukVH4+QHWEnmHy6kyazV5Ks2IK5tOSXTc+BZrM9AtjPGwuogTO0WhNL2PilLkizKLp12CZoQbCEjzx+D+0QzjBKY9w9WFyZJM5g4xlntG5IOqEQ6EzH63SyEpX7vuUghiwUQJ8gd+awOXqpOKCAbLJViCTlSBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=EWnepMLB54LcYV4yQ64z+NzgKdsrVZmz+dTYjb71qBE=; b=kGfyVFyQrU1eIsbtgFcHGcxyR7QI0vb7q9pUFpszQOq4ZXMvSClRFrEjWrpskMA4/bvdKHVPdBInRXTQWtUUsWtA2YDCe2C6yHFlEZ7cba7MW+QS8YYqgOII91chQry4S+H7N3YTy6e0rRqWgoTt14oK7P+dE7l/iUQbfERi0SEo3r/wv5q3ShWVgyqCWHmAd2QMbX2tKDpnAzdg3OUYYz2QRrbjF9UEw+XIKqloedLruycLifNaksK+9yLZ3u1O2KKgCPHrSn8BBybFAFzlhveNjEY1xCVXGhm1JYnOkKzZYZ0WlNtoS2EJ8m+JK5+sVk1eUjJbS7UC3XwtURmTsA== Received: from SA9P223CA0002.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::7) by SN7PR12MB7105.namprd12.prod.outlook.com (2603:10b6:806:2a0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 03:58:13 +0000 Received: from SN1PEPF00036F3E.namprd05.prod.outlook.com (2603:10b6:806:26:cafe::ec) by SA9P223CA0002.outlook.office365.com (2603:10b6:806:26::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 03:58:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF00036F3E.mail.protection.outlook.com (10.167.248.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 03:58:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:58:02 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 22 Apr 2024 20:58:01 -0700 Received: from vdi.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 22 Apr 2024 20:58:00 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v5 6/6] virtio_net: Remove rtnl lock protection of command buffers Date: Tue, 23 Apr 2024 06:57:46 +0300 Message-ID: <20240423035746.699466-7-danielj@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423035746.699466-1-danielj@nvidia.com> References: <20240423035746.699466-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: SN1PEPF00036F3E:EE_|SN7PR12MB7105:EE_ X-MS-Office365-Filtering-Correlation-Id: b61a8b45-687b-423a-da11-08dc6349994e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QNpT+34ImWUwJlmKOO/Ie2mGovt8Rl3sMDUfKhvuTHqoNMqrz/tjvvFzRauTygL4OcjpDAOEVDc5u0wFKEOjcQlK/vGimPfRJVzTsYiVU/XHVHI5ALSJPAiQRULT4hozAbD7Z0nUoOtjmQq++2tkhYaZG39sGz2Bn4c1sBnpHdkuu/TqlWgdPRBbbfGOWycvSPY2nCdbXX63MpQ5BNQGoG/f2kV3hk6v3VpFYVPtAyfSRd66ELV8KsKb/yvlyy0XlMPmf+HHgpB/NEbYUX7lU6/l5T64LF1/D+GIKAY4dOM+VPTdUWH3ZJx7vBJknwz7la+fvt/jhCLd3zxskTrBWp4gMAuUJPT/lYGuoxgRcqHEBsMZ9bcLjl6spgxbZW0NMMISHomosuOnekrrWG4WtjVT2c9YzdeFgkgfCcANBga8leKCS3PqSqBKgDzed9bJZ7mb1rct/Mtlmmpr3kPaSu/wbtdNQkEP4QhHpahpa/e4w4tfhVEVaF/qkmV5TdcShigchPhbNvNvnNSqXOft8CV01viwvH9ngqPWfixENnxdJ0lWaa2nLx4WxwPtNvtas/UFRNzwZigXBVFHo8t6xSZJ6yIS3bz9Q3SKbdk6xDDa5iFrF6RsGKaOrfhTCb3rsuZ70+B46UtCGOEJIV2yDK+PRQaoayg2azs6aMVWNmdtyDifAX70uhDvThRoVhraWT0TOv2YwbDd15KY4RVgDh/qDI4iiH3atMEN1UNzMOvXQWX+LzoHkzrYUFxIyQreRh9MreBE/j1xHIYPRBvDduHyq9Q/xTwE3ZCOG+FjojxjanuiLOQU7whztDVaKM42305/bASP1Jg6uZ0cJvxoNNuWdG5+0f5tbvlbsysCbT2WXQai9NVSemo9+KYQq8P2BzzcJ8bFDMe1IjlkxmWt5JwjE1fjQksGPrd+G2wKZieNcdU0YIfXmUJfS2z+huuIlVxFFnmPNKppKB8RdFoM/qXRz0GcPii3poSrKUSioVf/7yH/dY/cAeVr9YZByiLV+52yAy/6Ravc8Z5LpMb1XR1FIBvaNSRjOxTLf44HaWWRisBJba6zqjSPzqRECUABpHxKWcxDnzVRvtkVkwULTuDtUk8Z6ijjpxjLFmsB9n841yI7KDTlpdUpzP0q9ZcNSiDjztLhSiIyYlQ7SNqFMC4jOVqAhogkJfF3mlqQRBMIzE3dSiNuDKgm5Ei/P+tR8TZWhG3ikXguQW7BzPRaBBXzFEh0P+6YZJYpy99JtCbuE2+1FJ8qT3r1t5/n7qYuwPYBz46Qsq1E4naBgYknr3bRshvPsnZy+IxnOI0HuLNTGODjqJeJX0864ztdXnAHGNtI0MhFJm9snlyyDjYBfdBPS6FWQWQJ520aF5lJOgckCQ30ux+Rf9svtPQqkWkX X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 03:58:13.3893 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b61a8b45-687b-423a-da11-08dc6349994e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7105 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 033e1d6ea31b..d00f4147c7c0 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2668,14 +2668,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; @@ -2706,16 +2704,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; @@ -3321,7 +3309,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; @@ -3626,9 +3614,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); @@ -3648,7 +3633,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) @@ -4117,7 +4101,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); @@ -4939,7 +4923,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