From nobody Sun Mar 22 16:04:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016559; cv=none; d=zohomail.com; s=zohoarc; b=NunHhO0Gz9Z/LgVp/p3tHbLH/3QPd/IGj+b78G4Jq+2BNqOi76PoYraADo1CBRRzDwcf+W+CFG7Uink7P7xtnc6ODtTCb1Sbr62dQjhSNt61JmHcN0+GS1FNaZgBXkPwtCVRmjsggsibk/Sj3Pf7Xc3EV5+OYFMst+lU1WYyU5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016559; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6Tfha/Vo501llrdOlIhu+ARsJApYqvEGj9lM2fvEUW8=; b=hKvuMW4M0PDbLjaO7TlisAQUJEhYv0+XJPZ3uaTyZSpSk9IUKLWm9Rr5SvnmTRemeR4yEhE0Xfmd3BVRNklnt3dOoEPp+IHdoROpZSFyvDbNNhtnluHOi9X1E/5fm8pu1WBd+hsyn0FFdT3Ggn17p6lwZo6rt9o042BhO/zyVps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016559049217.30254846112848; Fri, 20 Mar 2026 07:22:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aio-00031p-M9; Fri, 20 Mar 2026 10:21:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aik-00031W-K4 for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:02 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aii-0007UE-8F for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:02 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YgqW2601043; Fri, 20 Mar 2026 14:20:44 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9ths-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KECGLx030539; Fri, 20 Mar 2026 14:20:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb4bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:43 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jv016730; Fri, 20 Mar 2026 14:20:42 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-14; Fri, 20 Mar 2026 14:20:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=6Tfha /Vo501llrdOlIhu+ARsJApYqvEGj9lM2fvEUW8=; b=b7UkA9NdSekd+p05fb8Pz zWPxU6NJvufuT4FRC6/7JCrma1iLn/DlDVOUQiN89cKWkaWfBw0jNbKw3sjqwsH3 Yr5I09L5N+9FdFwOflkZ7ohSgXd8Coz0BIOqKPOgBd+azLOqwBqvuP7tmUdzzuNG BInEFCp8LKX0UB6FyezEqso8CbJeE/vij0cOuqh7iBxAZMvKvhPotJ5/ERymJl1k ymqRtbn28WLjMfEiDmg0Z7fdmLaIJgoW3nsPAytRAjzAjjjmrcWdWclIUcQo6wu7 IS8WZIVorVS9CuwazeOpyLyP7ryuQ6ld+lwKpraz1J55CdjAtDeVBdy+YvaHlCdr w== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 13/14] virtio-net: detect pending Tx work for VQs mid-migration changes Date: Fri, 20 Mar 2026 14:20:14 +0000 Message-ID: <20260320142015.3856652-14-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: wQDeG2q5OHHnuZKdANF8J9E1PqO_WmSt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX4mmqkJ8VZ4j+ SzevoOjpCoAI2/JWWsdIb5xrGAVbB5JfkpHoVtOzPXzDpExt1B1Tp1rJT1j1I3iaxLdDAefH3C8 FIucKRIT76GPHME+XT4p9OosVqw81NPO6ho+k6/ZzFvfVU8uCOroNpSN4ZmTiSR1jwpqk6uBl+1 MmAYxNC3jSbiHUm8aUcP6iNfHOzMV8oI7NXDyD+trUWTD8EPXNhtRvTEsHxFaDrMnj7BiiVYZ9A wK76Gmm4TqKgOHM1MPvXMD4h/XVGJkynYLmfJgjn7HQHZLcjxWo+aRVQRTnmyR9YWfWhKmA7iya q5Z04slLsNyecb4Tqs/1VICrnjqqm781MLNExVLOT5+9YQ9G0opS4BZKNGzTPowceXtSdi5wagd gj07EFxMTwcWnlrDtH+qFAan185k3abwOHA8BrnEXUmYcmoC5d1eOZRrk3E2OQx27CU/WvDyB7A qls8wXVyQNgj6X5PEsg== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57bc b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=PoidfZ1iDD9ysA-sajAA:9 X-Proofpoint-ORIG-GUID: wQDeG2q5OHHnuZKdANF8J9E1PqO_WmSt Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1774016560863158500 Content-Type: text/plain; charset="utf-8" Track per-queue pending Tx work state during early migration time. This includes a snapshot of pending Tx state for active queue pairs, checking for deltas at the end of migration, and freeing the snapshot buffer during device unrealize. With this final delta signal in place, drop the temporary always-true fallback in virtio_net_has_delta and return false when no deltas are found. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 26 +++++++++++++++++++++----- include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3ee49a043a..483a43be4f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3943,6 +3943,14 @@ static int virtio_net_early_pre_save(void *opaque) vnet_mig->mq_early =3D n->multiqueue; vnet_mig->queue_pairs_early =3D n->curr_queue_pairs; =20 + /* Tx waiting snapshot for active queue pairs */ + if (!vnet_mig->tx_waiting_early) { + vnet_mig->tx_waiting_early =3D g_new0(uint32_t, n->max_queue_pairs= ); + } + for (int i =3D 0; i < n->curr_queue_pairs; i++) { + vnet_mig->tx_waiting_early[i] =3D n->vqs[i].tx_waiting; + } + /* RSS state snapshot */ vnet_mig->rss_enabled_early =3D n->rss_data.enabled; vnet_mig->rss_redirect_early =3D n->rss_data.redirect; @@ -4254,6 +4262,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev) n->migration->mtable_macs_early =3D NULL; g_free(n->migration->vlans_early); n->migration->vlans_early =3D NULL; + g_free(n->migration->tx_waiting_early); + n->migration->tx_waiting_early =3D NULL; g_free(n->migration->rss_indirections_table_early); n->migration->rss_indirections_table_early =3D NULL; g_free(n->migration); @@ -4412,6 +4422,16 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has any active queue's tx_waiting changed? */ + if (!vnet_mig->tx_waiting_early) { + return true; + } + for (int i =3D 0; i < n->curr_queue_pairs; i++) { + if (n->vqs[i].tx_waiting !=3D vnet_mig->tx_waiting_early[i]) { + return true; + } + } + /* Has the VirtIONet's RSS state changed? */ if (n->rss_data.enabled !=3D vnet_mig->rss_enabled_early || n->rss_data.redirect !=3D vnet_mig->rss_redirect_early || @@ -4439,11 +4459,7 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) } } =20 - /* - * Always return true for now until we're able to detect all possible - * changes to a VirtIONet device. - */ - return true; + return false; } =20 static bool virtio_net_needed(void *opaque) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 88074a0976..dbbacc83bb 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -180,6 +180,7 @@ typedef struct VirtIONetQueue { * @guest_offloads_early: Guest offloads snapshot. * @mq_early: Multiqueue state snapshot. * @queue_pairs_early: Queue pairs snapshot. + * @tx_waiting_early: Per-queue pending-Tx snapshot. * @rss_enabled_early: RSS enabled flag. * @rss_redirect_early: RSS redirect flag. * @rss_populate_hash_early: RSS populate hash flag. @@ -201,6 +202,7 @@ typedef struct VirtIONetMigration { uint64_t guest_offloads_early; int mq_early; uint16_t queue_pairs_early; + uint32_t *tx_waiting_early; bool rss_enabled_early; bool rss_redirect_early; bool rss_populate_hash_early; --=20 2.51.0