From nobody Sun Sep 28 16:36:39 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756328473; cv=none; d=zohomail.com; s=zohoarc; b=c6QPRO/Fmyu2Y8fr5ARt1waAAvulCMUH4VYZwv0GPMX9vAhCssPKC1y2SZ1if4OHvwJm+n4ukylTOnyY3FRy/+IQeQcRHzTKDprOvuK/spDB5G20j0F2LH+N5u9BV2MYC7VFEdd+qAfQNIKVcuu3kS3UTBYrFYcPf7OO8nmR5nA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756328473; 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=LWSJYlk138FmAFVvxr4mdnjck2zH0Iu2R9tmAoocuGM=; b=JiRB98QvgIl0kC0SeI+t33Jk7dXXcT7RQd3WcdzxSXOADiLqe7UOGOuy0J2hQ+nlAvAjWpOpRWRJCcKqo529XDirV8cJ/D9GRIi47SL/G+gCrEnk6GFnij4jlMBDn8in3VH4e9pBj6fMtWrvbCC2rkB2ZNPdpiCPnCc4T4i/ECw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756328473484782.17782525992; Wed, 27 Aug 2025 14:01:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urNFz-0006sP-70; Wed, 27 Aug 2025 17:00:35 -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 1urNFd-0006iu-Da for qemu-devel@nongnu.org; Wed, 27 Aug 2025 17:00:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1urNFX-0006rO-7M for qemu-devel@nongnu.org; Wed, 27 Aug 2025 17:00:09 -0400 Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-s1_5xZwVPLKBQ71b0HpkYA-1; Wed, 27 Aug 2025 17:00:04 -0400 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-71d605339dbso3010507b3.2 for ; Wed, 27 Aug 2025 14:00:04 -0700 (PDT) Received: from x1.com (bras-base-aurron9134w-grc-11-174-89-135-121.dsl.bell.ca. [174.89.135.121]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e96e5530a32sm1389846276.17.2025.08.27.14.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 14:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756328406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LWSJYlk138FmAFVvxr4mdnjck2zH0Iu2R9tmAoocuGM=; b=JEFdfcYujQTCEfl8hxb/qZ+FiXKjGt99cyDqqYl26dDsWanwmj5zMQb67LiHoITcHuCs9c lurzh2ziYebVUHyRikFKeUuwrWExcxakk7w0Oo5Urbnc5F5npyvJbZRdQuQAgamPcGBzGy pGSxO62/oKrXcyQTJBqPByytaWUyQns= X-MC-Unique: s1_5xZwVPLKBQ71b0HpkYA-1 X-Mimecast-MFC-AGG-ID: s1_5xZwVPLKBQ71b0HpkYA_1756328404 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756328403; x=1756933203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LWSJYlk138FmAFVvxr4mdnjck2zH0Iu2R9tmAoocuGM=; b=Et2hHt3zautpasWgBYWDbZKcebA5YEASGK2SfZv7CJXhr/g08qO8uT/SDAKif+uvHD YyJ7EdgxVncOMQjb+Ji6HD/cJuF3pWOnI8Yso0rH7Hh/tu993SiUqfFSZZI5wzjLca2R SG6EQPu/ape+SRst0BFYVvvrNfSAxikKORIbEKicksoo3M6XJTkTvM4vPUq8/uk6Hxg7 /btSv3/ldw9OChYjhuOkNVogh9AKoPMuW09eY+0YDSx/v1lQP9fjVecXhWXQTfj1pR7l JP2zw75lOz/rQLirLbeIE6iAIjZc4EclTtOaNo5A6+9AMorPR5bf95wE79czxLpLRrVR 0K/g== X-Gm-Message-State: AOJu0YwGZtcWqyFgBN7J4O8c3sK0taEmhZgTrmfFe5pfNr6gNYdYgpeL uc39UqDvdnohjRXV+VU+vjkkfjsfwKkeh/k1t3/cSfyHFxzqN7zjZIUeR81J6+qckdxvaxRwGe+ Y7J3vq+S4WG0JYkXStnmPQB4YsEiwoMnw1ZKPhG4NixH0/VlSyRBlUxmLk4QqIiQtg3IulpFGKC OITCEd7xcyHo3vpOXsirUMEMTOlwNembb3HEV0GQ== X-Gm-Gg: ASbGncukBQ5uU8GunxYL4adu+j6Yniicjl5hMkrIyVjZ1KZA9P4ZKeqh2X4dhALyW/3 18JdiVGC4gzl+4BgfqP1PsUfSBCmA35KHWHGKZ1HCng3XEbXjvusQqN2+4o57bix8UIUX1tEeJI nWEM9KNLXOTsclUFIfXpdTA4tbaj4A7+KHORx3uMaUV37qSdqmvbao+T976Ev3C40Da+XxiZ7L+ YalX6kJXdirolDuIV9CbHLfTD/Qxd8JkooUkNtbmWn5jWSKXd/aomzmZPR2TAJ/BZEBUv0/IrzQ JCVpulh0j2fxksZAGwQmsf4rTXTDkLiuPqPyy49VrcIVtAMZFPIGQQJoKcdOyQT2REvZh5DoBR0 1PDqqsXsGRLqBmgcnIvg= X-Received: by 2002:a05:6902:110e:b0:e95:34cf:9b55 with SMTP id 3f1490d57ef6-e9534cfa905mr19201920276.12.1756328403472; Wed, 27 Aug 2025 14:00:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkpx0budwaHrDidhF7vzeiefKfIffbE7jmdijfNTP7rqs5nhQI/GsOctMgsj45yLrZwawenQ== X-Received: by 2002:a05:6902:110e:b0:e95:34cf:9b55 with SMTP id 3f1490d57ef6-e9534cfa905mr19201850276.12.1756328402854; Wed, 27 Aug 2025 14:00:02 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Dr . David Alan Gilbert" , peterx@redhat.com, Kevin Wolf , Paolo Bonzini , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Hailiang Zhang , Yury Kotov , Vladimir Sementsov-Ogievskiy , Prasad Pandit , Zhang Chen , Li Zhijian , Juraj Marcin Subject: [PATCH RFC 6/9] migration/rdma: Remove coroutine path in qemu_rdma_wait_comp_channel Date: Wed, 27 Aug 2025 16:59:45 -0400 Message-ID: <20250827205949.364606-7-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250827205949.364606-1-peterx@redhat.com> References: <20250827205949.364606-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 @redhat.com) X-ZM-MESSAGEID: 1756328476061116600 Content-Type: text/plain; charset="utf-8" Now after threadified dest VM load during precopy, we will always in a thread context rather than within a coroutine. We can remove this path now. With that, migration_started_on_destination can go away too. Signed-off-by: Peter Xu Reviewed-by: Li Zhijian --- migration/rdma.c | 102 +++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 61 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2b995513aa..7751262460 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -29,7 +29,6 @@ #include "qemu/rcu.h" #include "qemu/sockets.h" #include "qemu/bitmap.h" -#include "qemu/coroutine.h" #include "system/memory.h" #include #include @@ -357,13 +356,6 @@ typedef struct RDMAContext { /* Index of the next RAMBlock received during block registration */ unsigned int next_src_index; =20 - /* - * Migration on *destination* started. - * Then use coroutine yield function. - * Source runs in a thread, so we don't care. - */ - int migration_started_on_destination; - int total_registrations; int total_writes; =20 @@ -1353,66 +1345,55 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma, struct rdma_cm_event *cm_event; =20 /* - * Coroutine doesn't start until migration_fd_process_incoming() - * so don't yield unless we know we're running inside of a coroutine. + * This is the source or dest side, either during precopy or + * postcopy. We're always in a separate thread when reaching here. + * Poll the fd. We need to be able to handle 'cancel' or an error + * without hanging forever. */ - if (rdma->migration_started_on_destination && - migration_incoming_get_current()->state =3D=3D MIGRATION_STATUS_AC= TIVE && - qemu_in_coroutine()) { - yield_until_fd_readable(comp_channel->fd); - } else { - /* This is the source side, we're in a separate thread - * or destination prior to migration_fd_process_incoming() - * after postcopy, the destination also in a separate thread. - * we can't yield; so we have to poll the fd. - * But we need to be able to handle 'cancel' or an error - * without hanging forever. - */ - while (!rdma->errored && !rdma->received_error) { - GPollFD pfds[2]; - pfds[0].fd =3D comp_channel->fd; - pfds[0].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; - pfds[0].revents =3D 0; - - pfds[1].fd =3D rdma->channel->fd; - pfds[1].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; - pfds[1].revents =3D 0; - - /* 0.1s timeout, should be fine for a 'cancel' */ - switch (qemu_poll_ns(pfds, 2, 100 * 1000 * 1000)) { - case 2: - case 1: /* fd active */ - if (pfds[0].revents) { - return 0; - } + while (!rdma->errored && !rdma->received_error) { + GPollFD pfds[2]; + pfds[0].fd =3D comp_channel->fd; + pfds[0].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; + pfds[0].revents =3D 0; + + pfds[1].fd =3D rdma->channel->fd; + pfds[1].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; + pfds[1].revents =3D 0; + + /* 0.1s timeout, should be fine for a 'cancel' */ + switch (qemu_poll_ns(pfds, 2, 100 * 1000 * 1000)) { + case 2: + case 1: /* fd active */ + if (pfds[0].revents) { + return 0; + } =20 - if (pfds[1].revents) { - if (rdma_get_cm_event(rdma->channel, &cm_event) < 0) { - return -1; - } + if (pfds[1].revents) { + if (rdma_get_cm_event(rdma->channel, &cm_event) < 0) { + return -1; + } =20 - if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED = || - cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVA= L) { - rdma_ack_cm_event(cm_event); - return -1; - } + if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED || + cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVAL) { rdma_ack_cm_event(cm_event); + return -1; } - break; + rdma_ack_cm_event(cm_event); + } + break; =20 - case 0: /* Timeout, go around again */ - break; + case 0: /* Timeout, go around again */ + break; =20 - default: /* Error of some type - - * I don't trust errno from qemu_poll_ns - */ - return -1; - } + default: /* Error of some type - + * I don't trust errno from qemu_poll_ns + */ + return -1; + } =20 - if (migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCE= LLING) { - /* Bail out and let the cancellation happen */ - return -1; - } + if (migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCELLIN= G) { + /* Bail out and let the cancellation happen */ + return -1; } } =20 @@ -3817,7 +3798,6 @@ static void rdma_accept_incoming_migration(void *opaq= ue) return; } =20 - rdma->migration_started_on_destination =3D 1; migration_fd_process_incoming(f); } =20 --=20 2.50.1