From patchwork Fri Apr 12 19:53:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628296 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (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 039B93D547 for ; Fri, 12 Apr 2024 19:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951620; cv=fail; b=CnUVfta6m7uf+I6mtpdTbwoaLRUyWwUfZnzquhFKfGVNMDKXTKCrsdsskoN7bA14YGTCrvpZBtMsPx2dMfJwGsTjnXnDhIoTEVlElxQqGLO6ZQYjIAfGKkazGRJ5H9SywGCK13hLaBR31hh8WnuD8Zbo1DQHl4eN1KFQC1R1p9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951620; c=relaxed/simple; bh=UfEdyCz3LlS1WzdrAvGxjzUnAqARglaVKhC+FvqA3oE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uu1IOILnc6lL+bMwkva8CKFdnqTdlzAg9yOtUU4jPwDZ2pVjHMaZ1nar2qxudhDrrejHaGjuFSOMD2caGWv3LWSzMcBiOIZ50/4dspdXYMvjVrVYX0C9i+Ow1AdA9MUkFIDcDGMw6wbVbk37h0P4zJ1+yQph6aWVPYCTPCq+plY= 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=g7dD+v5H; arc=fail smtp.client-ip=40.107.94.47 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="g7dD+v5H" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnHz+Vyd71C0d9761183rUvtM+/VT9HEcsfYzeLef7IyJyDgJ8JZ7Smp2spL0NjfJICcwMjSAV7dT/RhjpJa7p/aBUoEX5D0VgZ00KlQKBIxlSRS/hJ4VN31EcDDeRacas5U/3J7y8nTu61FdwDTdh7SHQgR28FoaHr8o0cfxLdICpFNquF/vYmgQuVNxmk6X2wohNsCP/vg6fV78bZOEuLJtcTDf/hIUvDXRQhP09ZZFcSY9iqOIhG2AX6GEc8IJSoNCSIeZZtthGsjGh8ylLBa8A+Ns3079p2ekoY9stLMF3hU/UIftwvQryN3glhfKQk/iO2ltk9clzxBUhiQWg== 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=3gjjb+VLytpV1AWnJFcsVnfyfTN62MVNj/uuDrcOQQs=; b=i+pX9iqzQZc/pvAubLif6uH/5a0quiGyM2Sp746p0AGKB7wCSN2Wrr1fOVwOeW5xIw7EH/sIWzdJjG4lMvQUdaK1fL+bcusUibvqzQmHus6zHlB7go+i93sQQETIFzMZydy92vjPUbfbRkhPLfRewa/Mt+yosGvh/BS+DzIlhjkC4UQyWfh0tf3TDaxdoso67ocaFckJmFh7ET1VTtIVo8Ud5ARYbSQo7VoRwyyU2Af/54sIxLl5qYPxsKqZoSj8ocvjkSVLk+7PQLPFodGh0/zFRHj4hyaZSOZzNRgi9Ql2nP2XGRpzlBDbxk+JgAGHZOkAAXkNN7AqbuLohU57XQ== 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=3gjjb+VLytpV1AWnJFcsVnfyfTN62MVNj/uuDrcOQQs=; b=g7dD+v5HyppUoWZnfLOWW+re/6X6w6FfOzJO8HPQHAX4prIRSIYHCq4OZ9Fq/LGT06VmWLx4PohUOgeCzgNFEFnMx+NhIvouu3PuvtKZSoycZfAm9lf9hRO1eVfdNrppGQEyWq1PKkc5ALfF5JQPwwmbTs80qavL5jMO1wOveOA4Wq8atuOStPTaobQXlShUb5irVsyHRkPLI9EiqhC7jgP2HTQCJf/0edR/KzLVbCfP/VzYweISS5YftiWBx2UXaCLlTKLwtUfiF3THyA/rSfPMSZ4godsSRyf4zS8uMEBxZGR8TSPPU2YLUGElHkFu7SMU/r0mDG8WW3WXA0RigQ== Received: from DS7PR03CA0343.namprd03.prod.outlook.com (2603:10b6:8:55::17) by DS7PR12MB6191.namprd12.prod.outlook.com (2603:10b6:8:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:36 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:8:55:cafe::20) by DS7PR03CA0343.outlook.office365.com (2603:10b6:8:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.21 via Frontend Transport; Fri, 12 Apr 2024 19:53:36 +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 DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:35 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.986.41; Fri, 12 Apr 2024 12:53:22 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:21 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:21 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 1/6] virtio_net: Store RSS setting in virtnet_info Date: Fri, 12 Apr 2024 14:53:04 -0500 Message-ID: <20240412195309.737781-2-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: DS1PEPF0001709D:EE_|DS7PR12MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: 31b4120f-18cc-43b5-9756-08dc5b2a3d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UbVTsoJcsaZAQ1m39MvNbyXaFiUAeKQwxDHo5L+kh5fPD5CVpIybWuoo2T+0uIv4okQnWngcxYXys4KOBxBPTuUNNjkQXSF5WhpX55rIFBk6QyZ3cMYtBCJpoGkVXewtTmk7kpb2Jfo1J3aGHqKdURiyai5pAzGisRoA+BpahESCLA0iyTXo9lXFivdI6oiGrOvRlA8Z4HiScH1/PYzDrF7SZwKdTjFNy21jO/FCLSd3Z2CDu8JDkHXmESOb2AwFkjm7yekwQ3wL2yBY4K3mYlVitpa1aowYofMIzWqduhAZ1TA9em70FKuZl9Fxo7dN7Bcz839LCjDxvjfcBEnruO4iIGX+W9DgjWtItd6zM4q08hzn5LvaMkdPUWQzWGZ+czuUKvoQSuas2T78OiOGMCJE1/BbI/WUd1T8D4HkZQX1+LikSWhMkaRN4M2Oa4VDDIg2FdT3/N3XmHktWtFPIYLuz2sR1q8n/mk0Co8njwwoC+zVJxoIgzspUnwCSXfexTpEANHbfyPGTP9nXZhqGApW6R7behJi+Y4K8jZg56liOl+bCOIbSANuho1+k8SOnMoSz68uX+J8rM+NkYotvQDljDW8njR0tqGZnKrTSMXJ1aXNMviLrUedmzfBka9UuCPk23dbH5/5smdWTINPAqjQ85gV1M2j0gH2z6jGQzoWcHNe5KgXBk8Is4obnMkunLBA1mwJHX98sx9q9U7vA2vvBQlFwRXMB8XkN63qDy1KVNVMBEMHm1v467AcYB3g 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: 12 Apr 2024 19:53:35.8697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31b4120f-18cc-43b5-9756-08dc5b2a3d9d 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: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6191 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 Fri Apr 12 19:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628299 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2045.outbound.protection.outlook.com [40.107.101.45]) (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 1295F1514C9 for ; Fri, 12 Apr 2024 19:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951628; cv=fail; b=TgAHjGIaRtfxtkDoZCFJ6mI2TxTqqsO22LCfRM00gisErDIU66JdSaFvQNxiXv/s3nUx5bS6fIv7kxThNLdOE6mmhAhPuL7RerNfSAtxx9j+XB/YmU4QZOFXLA7S5WMjfCrzB1RQ50x+tlKcN76B2VgiaJvACujv5x59UUd8IcQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951628; c=relaxed/simple; bh=HPYjyXfNUmk2nHk+KPJTRzC7UvNurvtd92mJMhs5zYw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TbmCAhMwn/wEidy1g2n28UoY+PCWohoF3nkKrbfsmNXmY+ePRQbMVJ8nMjDebOlPMBDqDyrpN11qRx9oD311cuSxpNjN4puHtmpkqsH9OLh/u7/dUhMazNaWf+b3kUCfQPJCujPX/opSJOARfQKhF1XDgyIeSDZxb24YNaWqUWs= 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=GB85p03z; arc=fail smtp.client-ip=40.107.101.45 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="GB85p03z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VG/nwzG6DyBFpolQPLUPuPigWHU/o3ubG3LON834bFm3/Y+5WqMGXjzKJqZp0Qg8n5mFtLAAXmPHp5fMKxxv4fo5m09QCznW4h4gnQk20I1D8mtSiIrxMuaozmTSuvBUIZ6GiDz51W45Dn9ZxK/509LiPoZYcM9a6p6W1OlwE1XeDwP92tGMD6M/d82qID+a6FfN4OBx1tIOU1PltA+4VUTx1qZGpozQzf8Ytap+GtqxCQFR6NaydivR8p37QOHBosB5C8kHkkTFwo/mU3H7t4GOEQWGeGYyGF1h4Jv/6NXwM1kqWfWZ5knfbD6c5Rr+vHJFIheFR1Jd5m0fWx58NQ== 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=099NzkwAeIvGIsUsKioHl7MCA6XWKyda1w++1p2bVhg=; b=kuglZDttfYtDWWy3waEcc3ujSFINR/EHMWPJsK6ObYllksg8sEQlCuQ+0dIHA1hQv46fTddqL5Sop9aOuWis/8+f4c7MDtLLHT3aVlCZ/6B9EhITor8sMK7JzGWbg1qNNS2MJGqpNzQq11dHqY4r1352E9BfnZFVcwMJE9WzTmfgYreNPBS2CEu9SqtEorCWWJrEJh7oO7+iXjEPVvs8dK3pN7rYPQVIEBI99ZeFdYTE9nC9It+AUJEkkYs792NS/DtZWTiQNvCZI9YXqcR5l+qRVKL4a6iDEKH3paolvod5qG5pMur2Bf8x85jkpdAyfpp1hYpsLtrmR5wBbI/7Jw== 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=099NzkwAeIvGIsUsKioHl7MCA6XWKyda1w++1p2bVhg=; b=GB85p03zkROnCnjATOeAaUfF4z8E+9n002WQi0ye/nygZoekOl/epaYgNcZcsXznUzoumfa6jtZ9qFxJGw9g6CcWdhc89wjfkix/Ar9H+Kz1FA77i8LDBbRYIkG8ScXfsIrPPAVI5Utb3oV1mHyGYgFWc9bbhEyG4eZe518abZRZGQ8AD8D8QWNOqFS0Le4EphW542kYM0WjrhYBQ6YTxOMhMdtUvXtyT/bbC1qML820B509ZnvEeBMWHhgP6QFEzXRCoO7L//CMLQwlfN0OEqfcvrwgUPm5txWOuA9YiJRoPZT1geh4QeoxKsKtnZl5sFgZBdO+Eop1MkereWz6ag== Received: from PH7PR17CA0004.namprd17.prod.outlook.com (2603:10b6:510:324::15) by IA0PR12MB8328.namprd12.prod.outlook.com (2603:10b6:208:3dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:44 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:510:324:cafe::b) by PH7PR17CA0004.outlook.office365.com (2603:10b6:510:324::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 19:53:43 +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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:43 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.986.41; Fri, 12 Apr 2024 12:53:25 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:24 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:23 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 2/6] virtio_net: Remove command data from control_buf Date: Fri, 12 Apr 2024 14:53:05 -0500 Message-ID: <20240412195309.737781-3-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: CY4PEPF0000FCC0:EE_|IA0PR12MB8328:EE_ X-MS-Office365-Filtering-Correlation-Id: 9580a99a-f3b6-4f7f-5f69-08dc5b2a41ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PfjlHTB1yLU30UGigOBfKy3d9Izrl9QWB/eQy46c3onnN757Aoy087noYAxMq/2ew4ZUgLHPcUCCgVMDTItAwfHZWBkl95KX49MHEqrloPkEZJKg4tcPfVWF0fmCiKzj4izJQYHYFdDIploWkiZ3/Px8CAMFAe0WGfNtNQaQuLCCqekUkZHFmWL9V6eG26EWanuY3J4EvQIbDR30n41LsJ7YFiM6CVihmoQkFohv31ZHAe07NbjoW+SxVVFasHckCDHSfypDUdJNcosYX55f6TQlIwAF0UeUcPuGhlhiw2Krid3WnJJDtb9DrB8RthpnWc2Pozo8k4BhBLXWJs4rjNOJz9uj9I/XD8LGnOhST9ge9WB7id67cPeoL1hBPsHvWWTfE5Zr7eyqovYxMe04RUbjUg1c4gvkzl/9rrGtW3gV/SOWanbpVRVi+yPu2nrPZrTMJz6F/lu5yeSgD4NTsoHXTXQ8IHm23BSuioDvXUQy0jPwacUCxEPXMimkEyIPcIRT2CB9P8WOc1ZZMqpdUSP5qiM7mj2xXiwvtz4/YcPGFZ+95EJBId0yV43lYO+kU594Ufvey9XWNf0DNlmPCpfG55KqeYpwZU6/NhbJHm16B6wB34euB5SCi1l8/2ntODHJaEBmX7KK8el5Jww2+gPWFoSBii873Uxp/WYBYk7UZyNtIzGCh1rPTFLK7dF3YSA/b5BXkrOgRttJIXQNoskjBDel0tZ4qOMnsipen2r/aNWqmb2nVHCjXb9muO2O 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)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 19:53:43.1322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9580a99a-f3b6-4f7f-5f69-08dc5b2a41ef 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8328 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 Fri Apr 12 19:53:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628298 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) (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 9574C14F9F5 for ; Fri, 12 Apr 2024 19:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951625; cv=fail; b=d54JPKGanUkjXQqPjEaXR230JmS/OvRl7MyaQam6R48UozDrBJAhlS1Kh1VfIshzVynekuOJvMlPC67ykSLXhmTl53UHHGXtEkOEfWOGIVuo2HGDfFTm1kKP2nZvIqhuFOVfxJ/O9932oXqggBttcuCyRTUyP7A+5qKFspSxbLc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951625; c=relaxed/simple; bh=WmPsRBnTOg1ctT36GzpjwQXmPj051/5hr411BDH7YQE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F7v3ZGCNBIo1DyZKABRs37MY25EDMIlMNqGJX2sLU/0JkgkGRepoh+HoUqjwaCv9ljBPsAXkSk0V+a2+yQ6u59d8Vtd6fCRFSC0K9KL8kXGaKY6mzLTPc7O2i81D/vsWut7HtsTLRAfq3wx3H1MgcHqFVjG7/Wcsxzs/LOj7g5I= 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=BJsuvrYr; arc=fail smtp.client-ip=40.107.93.45 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="BJsuvrYr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=er6+koJXCeD0iEKZmZTUwIm6TFb04sl6oVIgpJ40SV8B03ZYDptfLuTlcgtPTBTVd1cKo0pAHZ0RaQcf9hlAmfBKWYFld5lGTDuO4oYabzg4CXOeFo0UxHuiAATo88USJlDPpZ8FU/WeIjda3wCK7sdDBh88VRxe22a2VecqoB2OU9ngOIasYlf9SFi0R+/5gssW4x+d7W7KW1EZV6gS6h2J2wcda5dmJlC4oi+qUNkWL2abCMsqKiDM+UPKua0kw4/680+2Flsg9tkYDmlnos7w96xdjoZsNsZ5WPGFBAwpG5A39ySrQt+dfMN4fqhu40tDxN3YjIzrHPmoJojzKQ== 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=89qsJLn15bSs44o/Ud6PIu1rDWCaTAaoFaPLRQmXOtY=; b=WYnkS+nfCUMOse/gAaomsDTy993S+5uRJH4DTgO+M4Gz0Lke9SCYMABebwLp/V8rwJplL3acChvwwv5KiQsdTY6wYNbQu94gncbN06aON57VyOmLq3Z/Q+03VLTDMHUv69xZ5v5HsN+JgsaWLWvEWfHA7Lld4MahJTpISD/uVu49Fq4XUSLsRKhut8V7TcYYH3GckNp+whLtp44FnHfEBXZlRkTRR3kA1akIN7n3tIqwpm+y3hI06X1d4jkuAv1GxDABhkgCxmqNY/R11oNWUldPV1w85OrW86CiEV9kUteT1ubABxj7mmNQw1ULq6v9yN+l/wzdmWxMe1Q8G7MlnQ== 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=89qsJLn15bSs44o/Ud6PIu1rDWCaTAaoFaPLRQmXOtY=; b=BJsuvrYr+a9BUhCi+p7F7QnTD8ekxpninRHjx3P+FF+bknJhvGMW8nVGzuHodbYomlabOZU2R28aR4w1OC61jwUM2DwD54bb6Q0xkwxmPYZ5uyGN4U1Ej4OTYIrAiXt8cgCxY+giG8rMHEAgYWrLbj9W7LWOUKLVE8Yr4jlj2RecGPHPuKiQUQ76B5iurnlSP8biAZXsjRMwo6bWZCiqFX2rvzFLq3piCkXVeQpqWU96lvHj5M9grIhyyAtd0WiESfcz4QpEY1DjuldyJjhdekaGhPdwPxW3Ikh+vfWV3/gw/P1zAB1J0piHCNLJpIUhNEbJbgneonoPDwv4QOYRVg== Received: from DM6PR07CA0079.namprd07.prod.outlook.com (2603:10b6:5:337::12) by DM6PR12MB4467.namprd12.prod.outlook.com (2603:10b6:5:2a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:41 +0000 Received: from DS1PEPF00017099.namprd05.prod.outlook.com (2603:10b6:5:337:cafe::47) by DM6PR07CA0079.outlook.office365.com (2603:10b6:5:337::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.27 via Frontend Transport; Fri, 12 Apr 2024 19:53:42 +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 DS1PEPF00017099.mail.protection.outlook.com (10.167.18.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:41 +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.986.41; Fri, 12 Apr 2024 12:53:27 -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.1258.12; Fri, 12 Apr 2024 12:53:26 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:26 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 3/6] virtio_net: Add a lock for the command VQ. Date: Fri, 12 Apr 2024 14:53:06 -0500 Message-ID: <20240412195309.737781-4-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: DS1PEPF00017099:EE_|DM6PR12MB4467:EE_ X-MS-Office365-Filtering-Correlation-Id: 59053b20-b24e-4b25-178e-08dc5b2a4126 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7kZ/pYutc8Hl+JZIZON0dRXWm3r0tKKTSKITNZlM12ic7Wakc5JsLo6R2+zu8h/qaGwXwq2HmlO8+CyfGFnByVGd/xTZ/PlEw0mz3gQ42+L+cOf97P1XslmIMUtRdXF55ZbVvsP/LlIv5fYN98vicGfRgJb22M3J76nQTalTaZMrPwXk1/uieZTZeJgSy2jlua8W55vsp0RduWCz7mVfLEg1pvFTD9DbRaAIGOT0EV4ekYD46iB//v9QEVe8R/rRp+WUqdercLdDyb8WsTpG7baF6g3JXZyPYUqkvWE9+ZlgflyGCgGsJ1tbILy4ui0dUc9OO9zsf3LCVnnXUzAVXepzJKtKEYD7tAcEVWIV8lSWR4BC2melLPHJ+ctFaXz+tniqzraa90Td1/SS4n+0+QTUGd4ptBrjCkXO3xeYDtUHa2aoUGHQ6FEvJrjSpjtrVExCDtc5l2G+RoRZI32jrhRCc11O2oO5lRcHr7HhlkWOIPv+cVAqOsrkT5WJJLLtnkuOlGh4Y7IJXYNmXBaxg6u7XSpTO3UwwfURG14O3s2yGj6eVEQ5nePP2/32oWAyX5Q2qirgF6km6GsP8iPm+RNHnczL6dNW6dYANeh2GB/arrBMNPUxqq8vERV4Dpsjrt2kIIIh+/1xqY4ILw36Ssw74vLl9Vp5GJT215s0zXZUoLdWODSqFd4pVIx1Na84Fc+PchEw2gKt2/3tJP1pb+pcxBHsi0/xq/SM7sHC55VDw9m+pgKpnvcw6oNIGvl4 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: 12 Apr 2024 19:53:41.8131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59053b20-b24e-4b25-178e-08dc5b2a4126 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: DS1PEPF00017099.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4467 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 0ee192b45e1e..d02f83a919a7 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; @@ -4818,8 +4820,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 Fri Apr 12 19:53:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628300 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2079.outbound.protection.outlook.com [40.107.101.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 CBBA714C5BD for ; Fri, 12 Apr 2024 19:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951630; cv=fail; b=PtMi4wglbXkd9kSMjyfSeR7GksnUiqgR+n3ZMB/q0VTJLnWOPqPiPp8rdLPcUURhhIfFJpi74iiPDhDGMGr7AtCYxB2al0oxJ9PIFYQ1DL10jEm+SFm5/8vHsJNpCSWmSS9C9tNcUBAmQBR8ee4v5ZXR9L8VzOQHDiN/WQjFw1A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951630; c=relaxed/simple; bh=OzbVviY9qdq/q9nn2z4N74fmYCUXrXKaDn+z+niDbpg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oK6EgI89NL9p7IZ0jhW1kMDPqKQAuQWB2XsDevtmsNWwyz6I6tVRmy5K6Ut0gv14mjv1v3XE59I2te0mIwnQN05IcXtga3dMaSfvO6ITe3qfEhIzcAoEmfOBc3r4lPDwxdJTlYnsCv7h7YNhJjKC/gELNUNQYhdbcMxunljz8Rc= 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=Yj/ON2Pr; arc=fail smtp.client-ip=40.107.101.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="Yj/ON2Pr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MwomnGkta5t0KW89u7AtjTKq9vfNvbWbLXIgRcrnv6OLbMTUmAROepGHSGRAbkmYlW9rIyvc8Oel86MEUhimPSqMZnEeHHvOJ1j3o+yeI9CU0LwBmNyU+o6Z0Iui1KjqHMDZQ3tMbXqKtpQUrn7tSJvVMUiVDh4iLOf+gf+j80qjVOhZfzCYtbsZG2tJkPjbGLCq6e7iBnd/cMVYaWd5pRDAvHt3YkDgaJB4lMg/4xXbhh4vnJxkUY/xmKFPcHbzLOTtJ2VyvXv7F/qbS99eOXJvVKER9azlpHAaBdWQLE3Jia7crzNaDvSpQA5q2Petdl7f0owlqBK+FrkqBWbZ9A== 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=OP+3hkxZHHuP0fO0l2C52Hy5CFloKOKwdnnbVvuvvVk=; b=NXY8bt+npseBQ0TTaaLe4VG8G5KGxSc+tMDXHLLwgp44kmQByfslnMRMlxFPkA3VBSTYLeFwcW/Bhe5a8c6sD7nKpSd8xT6sI/1z6/NUh89hOhud3tWn0/MJxclCiHZTMP0w0VA71HzWtwuXYKgjM0cP1szFbEVwfQZ7/i9lWdH27hYGCnf3vQJR9Hgw62i9A/uCrIiqGRfJQFj81kv4kIrDZSrBxOTT38KhqXevp4qoZ/iRaPIQXLjpon4R+fXgpkOQX6UQFr2t0CamEFBHQCaegGiTQmIuYatE2sLRGX9m5/+SA262S/v3m7VOL99xMMMXIieIRtK+H6ATujkY8Q== 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=OP+3hkxZHHuP0fO0l2C52Hy5CFloKOKwdnnbVvuvvVk=; b=Yj/ON2PrZoSnxYC7hGLbwx7caWj/0CQZ4Y6Ir0TSIaqVhDa2jY7E+WhVKUKjnPhWLuGzWyPnRLJb6ahiXOs+LGSH/HA0qHjeqnGK9T7Wn2t5rGPu5A92w6VEpMr2dhcMYcOeNTZNUi1P3kct7ALu/r02w6ZE8gh5NsBJs2/d7lkkEOFhWhtoazyY+3wfMvQKOWi/F8rEm5UL77xESf653ZbEIgvZxh3TKCJRdFB+h1iA/Jhq8TBCLwBO+XG0XYw/V2WWgf3iKhrFuU14zzwqDqR22QSfiB/4apMNIJYC0zD8SqEF/UBSGY+9IdlyFNQHsV/OSzBSCB724FFMBxWETA== Received: from DS7PR03CA0342.namprd03.prod.outlook.com (2603:10b6:8:55::14) by SJ1PR12MB6098.namprd12.prod.outlook.com (2603:10b6:a03:45f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 19:53:45 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:8:55:cafe::54) by DS7PR03CA0342.outlook.office365.com (2603:10b6:8:55::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Fri, 12 Apr 2024 19:53:45 +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 DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:45 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.986.41; Fri, 12 Apr 2024 12:53:29 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:29 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:28 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 4/6] virtio_net: Do DIM update for specified queue only Date: Fri, 12 Apr 2024 14:53:07 -0500 Message-ID: <20240412195309.737781-5-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: DS1PEPF0001709D:EE_|SJ1PR12MB6098:EE_ X-MS-Office365-Filtering-Correlation-Id: b8672098-08d5-460e-a659-08dc5b2a431e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LO+BvGFz9uxVKngyDKSav58UrkYE79W81/1AFIgAzBWhgco7jYqtPGVHHAMIcnt4m6f7IX8qDmyXIwCudd74O9gdGGWOeFxkslWrgOTNe54G/2qibgZ9XGPA9fDXKrNY92LKSmp1SkmgpYDBaQIGqzmO56tBFv0SFdXgUVYE7aPgdqJPb6P9YLlVB6XzvQo8i+uK5C+y/0zigtZzZh718J1yiuvA2u8aZ3aZBMfAUGKucZdgMgKF0xq9AWslKJmfS9KvhtBpfnBXKJjk5SfAjKjnSRhZI3mmbJn4Y+nEV9ZKHTqFh0VI7J9OveDH9KGZhnfw6Kwm2btIBAzD0byx7QOFVDBAfCnK8rn26Xc4Jf6VEM5hDcVvPc4GIhxX+GQwJcDhLBSglyWx01deycC+y6Lgq1vpzCMQ+Ib1RrgqziN9aruJKf4pE1+DqRJiowjfEO1i/iZ2goGeFT6mmwqKFyVZ0O10v29KGBY80zVlsU1il8kgjBHxqZhbEwWSGDfSfanWJnP/+raiA0p5o+vrm68/ce9+tr7XDVERH3U/nZE+hWGAJCciYEpTMA+nzdc8OuPR7NdHXPJneVDQXryL2Z6kA7Itro81kl1wpPWU8O8S7NT9ZrvS59QPFBLkWmeYw06xESQlvgfVLTkUtmhry3xI4lnyxLUrYFBrkN/iQMalWwelO1ftAzE7dUfIF8x+diZJiGoxG/xU0srNKtOgKLR6PwNBWlze0jSELff2FARfD4uIoaSI5f83EPNPVp8k 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)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 19:53:45.1041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8672098-08d5-460e-a659-08dc5b2a431e 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: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6098 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 d02f83a919a7..b3aa4d2a15e9 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3596,38 +3596,28 @@ static void virtnet_rx_dim_work(struct work_struct *work) struct virtnet_info *vi = rq->vq->vdev->priv; struct net_device *dev = vi->dev; struct dim_cq_moder update_moder; - int i, qnum, err; + int qnum, err; if (!rtnl_trylock()) return; - /* Each rxq's work is queued by "net_dim()->schedule_work()" - * in response to NAPI traffic changes. Note that dim->profile_ix - * for each rxq is updated prior to the queuing action. - * So we only need to traverse and update profiles for all rxqs - * in the work which is holding rtnl_lock. - */ - for (i = 0; i < vi->curr_queue_pairs; i++) { - rq = &vi->rq[i]; - dim = &rq->dim; - qnum = rq - vi->rq; + qnum = rq - vi->rq; - if (!rq->dim_enabled) - continue; + if (!rq->dim_enabled) + goto out; - update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); - if (update_moder.usec != rq->intr_coal.max_usecs || - update_moder.pkts != rq->intr_coal.max_packets) { - err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum, - update_moder.usec, - update_moder.pkts); - if (err) - pr_debug("%s: Failed to send dim parameters on rxq%d\n", - dev->name, qnum); - dim->state = DIM_START_MEASURE; - } + update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); + if (update_moder.usec != rq->intr_coal.max_usecs || + update_moder.pkts != rq->intr_coal.max_packets) { + err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum, + update_moder.usec, + update_moder.pkts); + if (err) + pr_debug("%s: Failed to send dim parameters on rxq%d\n", + dev->name, qnum); + dim->state = DIM_START_MEASURE; } - +out: rtnl_unlock(); } From patchwork Fri Apr 12 19:53:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628302 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2051.outbound.protection.outlook.com [40.107.223.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 5B31A1514C1 for ; Fri, 12 Apr 2024 19:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951639; cv=fail; b=ew7qqwFN3chzxbMRj+QyUE72wo98D10ow/opbmpfuMYQipH1SrzbUpvwqurcqpr/3+yt9QvOjotUE7SBOCuwBUVymJxTRkRuE5Vdd5q8rEThBjoyGjJseCNYUAfDNWIFJe6w4WIGUYhBrjgciJ3991Ul0/mCXdRNaZ9zFyXB1qw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951639; c=relaxed/simple; bh=8pcnRCurkizZR26hfLlf9fFwsldUByUaGZ4yy5/rQf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BkLFSLP2xDwTQy8Bksdelq/IYXIgWlaQ3oej7nNoJXpCxbnjARgyeC3bLhT4MZpWm+DDjAp6oK3fzhKohcpWKR5qHQB8KGktT6MaWHrnTs4ZuSCEr+HkomrO1WsSV5W0cyuCoKoEVKj0TeUhACw6kPTwu44LuXeVmBOFmRL0/sA= 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=YxRgBCHg; arc=fail smtp.client-ip=40.107.223.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="YxRgBCHg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mwDm7Al7cUQCjbLJFqQTD9AhTGKyw9JzhNiKjf46TGmlRdQg4B5E3qstIRqhTpRv4nCjlUBJADwJtSBezbUn+oGqo7WUYXC5M8Db+0V977z25Ws50ChSGsvGcn0jMkVzbn8SNmm5COq3dgSDlfnAHpo69AUFNk07VLoceumFXiZegIiLJsya52ic8J6CwtNLkl4mJWzPJeyPU7yBffsdY4EBoT8Bq15tHtaLLRG+nOpKRQ/SmE+54rcA+I5Nfxsj/R0yUDw/O5tylR/2lylO9MAjt7slBk5ByaK7tP7UvbIOMB+oVIU3kEp1ojIcrMHUzfgnchMeZRVuiOktp7klRg== 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=pHNBfbwuTgXLlRrsQflFCuy1BWFOpKYHOHEc/wgybaA=; b=jF7Ly6ZhGBSE4V7xnCrZsVcSIE1AjlThX5pMNCZbKwy7ukpKXOsslMePMAqMNxGfc3EVpWfe/itufBGMw0liu4kX6jx/4oxt7oSjHTNkJ72BwB3ZNZRcUjmwSVRSsTgZnQ4+V9w2Wv/SFp68y2biK7QG5hZu7GxKiZc/RphQt7sw8snrSkU6xZniXK3TjeoeNqO7BLbYtbmYFMZkHtYrPPohIsTFY7MB787y7bWBUzbBRR31HIWRi+JcDrt5nn85uwao+qK6u8600W5IdEwj6HKKrG5KeYRTs7Ss4wxzqekJI9jEEGa/uJrVUJlC9Sv8KleayBxCCgaKZBXv56quTQ== 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=pHNBfbwuTgXLlRrsQflFCuy1BWFOpKYHOHEc/wgybaA=; b=YxRgBCHg8f7ZWXgIAcdISE2ZXurlUPl/do+Jyb/OaD05B4OFf90rhWnBWVuQLC4z5rCQXwkzMxDky2ck+C/vGKRrlGKjryy89oe6aWRK4uQD5wFJcYKp30ZiVbNMBj8tmISqvn7CE/3JVw+fpN2u11esRD71iN202pH8uU4lPPgKAVCb2he4iGG3UpN+H+phW2k406uQlrwYfnQBpcU1LhcNrf1WPFp1ZbqGFI44tK2/+oZEWG5TT+G4h4ScV0r4aZmC0rQULT0ud7HPKv9nH3D+yXIYZz58+l3pZ9sBynYCdVNKI1ifLuktgQekjaGO/tKOSboW99+Mo6vEEPjeQg== Received: from BYAPR07CA0072.namprd07.prod.outlook.com (2603:10b6:a03:60::49) by LV3PR12MB9355.namprd12.prod.outlook.com (2603:10b6:408:216::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:53 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::9c) by BYAPR07CA0072.outlook.office365.com (2603:10b6:a03:60::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 19:53:52 +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 CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:52 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.986.41; Fri, 12 Apr 2024 12:53:32 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:31 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:30 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 5/6] virtio_net: Add a lock for per queue RX coalesce Date: Fri, 12 Apr 2024 14:53:08 -0500 Message-ID: <20240412195309.737781-6-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: CY4PEPF0000FCBF:EE_|LV3PR12MB9355:EE_ X-MS-Office365-Filtering-Correlation-Id: 66ccd1ec-4f1b-49f4-e5fa-08dc5b2a4776 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zrLnreiSPYW0x1hwAxxYCa8gzHLuskvpDLNvnWOImNsx8z1VdeykgjM598CEU/ESLuZ/tqIjp68osrEJGbXO7zsvqOnQnvaZskYS9b+iSi75ruH5CJ2ckh06NiQ9VJDjRMZXAd9zExZFyxwqgB0o0WRmR/pNA05xOjGU3dR8Ll2lmTd3qWyoua8211tCwJNFkCRohu8ef/2BAhLIfiTLzqYkOFeHVHRb+FIHhutBvmjkZvGf0YILGOQors4Wn1UPJHM8PQvQirDkoUQIQ5WrziSb/f3sNtDmVqWL5XWT+Dmybn1QYB9KJi2RTFQxWkpsIdcdpVb/4tQDdNTT1DhXF2Ee2hm4AI+HtZoKevC1rOzxDbG/ZaD6pI5eSaBfQlKLMoKsr6Ke6KfB8EvA1b4PpbqcuNlrSWxZGFzUUVr8GFxA1RbKpyIKkxJ3w7ykwjyq4hWili5OEmgyUeOT9TT7HqPqJOnnzGL9Uwh9xtRTfQD/1P6dOuTFkTMARbM1NikY8CQlxvmtwwZSuVjd4sWdqmfpSykhD54GGzxb17eYGYqylD33zEQ7qLGYyDS97kbd+ZUczmR0+Js9yj2t+uihgOPihsYm0oaTbVlyOF2FFB1eWKV8k+pz8+eoa86tUs4zzulgS8/0d0kAGXnrBSoLKsbeXWSGa1/Hjc6HrlfcjtXhygDAZPbYCOW/RPRkYoRRGy1B2VGKrMmdfnHDR06Y/UAsmLfXG0Q/9NgNcyeXHSaJAxPyBiJpL2dWZcLOuSrJ 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)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 19:53:52.3933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66ccd1ec-4f1b-49f4-e5fa-08dc5b2a4776 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: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9355 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 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b3aa4d2a15e9..8724caa7c2ed 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; @@ -3606,6 +3612,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) if (!rq->dim_enabled) 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) { @@ -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; @@ -4501,6 +4509,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 Fri Apr 12 19:53:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628301 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) (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 058801509B8 for ; Fri, 12 Apr 2024 19:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951636; cv=fail; b=a2v0T5uC7bO7KGeeR4PP+M+22HUcTtE2RPTonqo6WN6FUyceD4FB6+/tvtKpjpyCHLmCUnhoVgx4GyCmXITI9IfKItH3QujGd1v78Qq7fmoBLMv60rX6G1WJ6GuGZihZcXTZN1svPHQ6uEBgW33/n4qJHctbgSlLP5fPE5oiVg8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951636; c=relaxed/simple; bh=BbXNpU3wDZjmT+nE6mp6aUfmMKT5DlxpaeH4Sap/9Xc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XkYihJ/FR3DcMAitdO7X+5GzOlrT0RetC1nHHO55xYjKd6oeDiRhxm4VbWM5jy9sRg86TrFrLtfYjXFvjqHC1J+f/rNUlWiSrmYhqg76KlcCZPJzb/ZdI0r62B1x327loAm88FQ7SxB/SqQ7vPqb62M2L1F1g+HF4q0QbyjWjH8= 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=nTxMtBM7; arc=fail smtp.client-ip=40.107.244.75 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="nTxMtBM7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F0rpL+Y4OaFhOZ3oqY7pINsLYidi0h5i6jtDo4qw5MP5bfuPlq4XcB4PR9204m2RzFK9Thh+yRYd58g0MVtW2OztUZDwQssRVhu2MIAMZaxUWsNrpkdSiun+N82XDjB4e0Ee+mASpI5ff7MTJz4q192RLvH5ZPUs2o1yR1QyZbxYmRwhedz1WkL4/nWaWXj1SDIyQXoQMee+6zUFOI3wUuLZ8x9Qr9U0LqTQWDKg7dEn0HzmAFeF8shHSizCjOLxiIf7vT6HpCekWH5gOBuYQrYEBDfRDm/bIA/VgeTmIB5ovb95D7vj33EtU+p9NUbM80at7QV7Ry9z8oP7Lr89pA== 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=2q7aN8Mh1+f6qOM5b5AwyBEn6o/XwFHfSQiAPIiwRDQ=; b=Lt0oxDRrmmG0M3ktQTcv2HdIt6i9dIYlchEhUQTlbechwbFUw8ceKgDz5B39DKJ9OejtKSP4pf4tc7pRETa7elBuc3iQ9l2ueo2txPIUYwV1RsfY4cmAOxROMeImKVSqgsN3qlFtfEA3Lxn5F0rCOK/XXcLOE/9d7uu8RHd8R9D4kyBrGeom24Q2O1HIFXUybAh0tW5reDU/szlQewvroGTLvZCbJ8biAgfbw6z0SCx6fvIhFM6EGXMABSfaPb3rc1G/JG2JxZIEpv14Dm8TCpC3VoK19p2lfPuiW7HsdT6eoK0hCxmfWpt3RGE6X6gBF8PwgKaX575JD8zp0P3w8w== 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=2q7aN8Mh1+f6qOM5b5AwyBEn6o/XwFHfSQiAPIiwRDQ=; b=nTxMtBM72TAEs2zPGnrG/VCrLMcRRcLbVI8RIg1+9vZx9ONDn8siGwXFts+Fr8dd3jy+99jQUO9w0GfS2ZFklHSVkkLGj0OwCglSkzJfi3vaD9Yni84GhhYuxbQZdz7w7x9SFssAs/YA+KXTr4lj1qb1Nrs7vp1fGnAj55gwDCdbQOIBHUVUsx0ARXvWzV7oOLuJjtnDMhtLzr8wVv79QdU4V23Co5OUBQm3YQdO6njw+RCNAOdugd/TjIQ1xReLS23tBsJQno4qt99FS+ivVn/PdtmhDIl+KqE7Ec0BwheizLJyN+iJi4yfs1Wh3qa+LCgkEKPfgIuT859faMyoMA== Received: from BYAPR04CA0035.namprd04.prod.outlook.com (2603:10b6:a03:40::48) by SN7PR12MB6742.namprd12.prod.outlook.com (2603:10b6:806:26e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:51 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:a03:40:cafe::45) by BYAPR04CA0035.outlook.office365.com (2603:10b6:a03:40::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 19:53:50 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:49 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.986.41; Fri, 12 Apr 2024 12:53:34 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:34 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:33 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 6/6] virtio_net: Remove rtnl lock protection of command buffers Date: Fri, 12 Apr 2024 14:53:09 -0500 Message-ID: <20240412195309.737781-7-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-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: DS1PEPF00017096:EE_|SN7PR12MB6742:EE_ X-MS-Office365-Filtering-Correlation-Id: 0faf6d56-984b-449e-767e-08dc5b2a45fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JGl+HG/ZbT8z2F5FERxQC061YQ7j6c26EEpcc5BeY0o5shivibKQ2xuEs0vdJPDUe6KfPMJg/4P2XA7Pm5D5NpxGwiyj1BNtfCMugxQ6aV2RELAeokSwds55BG9Zb1QECOaBSZTcJb9RS0irtv3dOhD6HBPh9U53BHqwM3CJRWIozm9AKKwGxtMrTWFP78JbdNSFYk/CESyzawL1zFj16+GgSsiBpuvnqb5f8Mwy+OUMCq4/z4al7/U4E1yX59fhm3h4s0YkV27AQdk/iA1/GKSKXUjmTWdL/sWou3pi5w+pChK/WCkW+1QZCWt1PAzHkZb70UduI86EyY79onWAw+O3zgLTa2Amy2FpatdbcKYSnladetFnXYNh7zmU1NG9LSBmM9+pfrI0nDRtW+TSQ20fg6X1OVdzMV5ImFX9EZqCxQUFdZKLo5TfVOBHfVJB4iMCorriz9aG+BoEiYJYDUev9F//5NMC5vew3en2muvoqcxpncdy28BvdCyZRO9emwUB1l8yh1ykMOfBa+IZfVfLU16ilpvHUVLRsFcyzrGX1CdMgn22QFpyjA4t0hIBoHRBlNx2z0eDvIaREnMgeL1hZZKXfuEX3wJYWTLh7mfZwGOxacpW/IVyRksCA8Ap8BnA4GCFk+3a1ZrpdG19ZtSIE7Yfg6vzH3+voKII1rjD12mPVbMapCKyBNbBBIQV08+f18WXx6evenzQ01muB+6ynd3CcPT3BCrTL4TFPD+UxJBKVIJg3GfrTlKEgwRK 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)(82310400014)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 19:53:49.9288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0faf6d56-984b-449e-767e-08dc5b2a45fc 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6742 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 8724caa7c2ed..8df8585834f0 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) @@ -4093,7 +4076,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); @@ -4915,7 +4898,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