From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572053233; cv=none; d=zoho.com; s=zohoarc; b=X7u2+ER4ciZRk/g8/ZmI7NfxWpteU9KN3khFzVd4qKS6nDRDS/3VNXPoCfMSSJM5vfd2Klu9Tc6qc3mgDEFEjaL/sW8Or+FL810An9RitPthZ+SMtQx7zKHCm6TmPHGaXU5T3uLS0KeVJGrwQ5Xwokjy5tdBfhkTI0DV5wXMQXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572053233; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=m2kJFXdJZp8KQJR5455NW8s6VePy7dWlfKHk/huu9sE=; b=CW6R7FQZMhLp/MDgNtbAJbz2Zog1iMfmXPS1wsfGnujRmDC/hEehdkRt/DI3IbkkLzB9v1rLIqMxt/6JOer4GYvMlukU7KLKeg5C0Alz4ls1ft5rELLbHp0Rv2+laBc0PC3dJHchHq1pejgeXp6Y5iPQTpyhIVYyPgxXUS25iCo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572053233633291.804043510875; Fri, 25 Oct 2019 18:27:13 -0700 (PDT) Received: from localhost ([::1]:37828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOArI-0002eD-FZ for importer@patchew.org; Fri, 25 Oct 2019 21:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54967) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADB-0002Zz-F7 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADA-0004kg-DV for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADA-0004k9-66 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:44 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:42 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705106" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 1/6] migration/multifd: move Params update and pages cleanup into multifd_send_fill_packet() Date: Sat, 26 Oct 2019 08:45:15 +0800 Message-Id: <20191026004520.5515-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fill data and update/cleanup related field in one place. Also make the code a little clean. Signed-off-by: Wei Yang Reviewed-by: Juan Quintela --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5876054195..35f147388b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -789,15 +789,16 @@ static void multifd_pages_clear(MultiFDPages_t *pages) g_free(pages); } =20 -static void multifd_send_fill_packet(MultiFDSendParams *p) +static void multifd_send_fill_packet(MultiFDSendParams *p, uint32_t used) { MultiFDPacket_t *packet =3D p->packet; + uint32_t next_packet_size =3D used * qemu_target_page_size(); int i; =20 packet->flags =3D cpu_to_be32(p->flags); packet->pages_alloc =3D cpu_to_be32(p->pages->allocated); packet->pages_used =3D cpu_to_be32(p->pages->used); - packet->next_packet_size =3D cpu_to_be32(p->next_packet_size); + packet->next_packet_size =3D cpu_to_be32(next_packet_size); packet->packet_num =3D cpu_to_be64(p->packet_num); =20 if (p->pages->block) { @@ -807,6 +808,13 @@ static void multifd_send_fill_packet(MultiFDSendParams= *p) for (i =3D 0; i < p->pages->used; i++) { packet->offset[i] =3D cpu_to_be64(p->pages->offset[i]); } + + p->next_packet_size =3D next_packet_size; + p->flags =3D 0; + p->num_packets++; + p->num_pages +=3D used; + p->pages->used =3D 0; + p->pages->block =3D NULL; } =20 static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) @@ -1109,13 +1117,7 @@ static void *multifd_send_thread(void *opaque) uint64_t packet_num =3D p->packet_num; flags =3D p->flags; =20 - p->next_packet_size =3D used * qemu_target_page_size(); - multifd_send_fill_packet(p); - p->flags =3D 0; - p->num_packets++; - p->num_pages +=3D used; - p->pages->used =3D 0; - p->pages->block =3D NULL; + multifd_send_fill_packet(p, used); qemu_mutex_unlock(&p->mutex); =20 trace_multifd_send(p->id, packet_num, used, flags, --=20 2.17.1 From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572050889; cv=none; d=zoho.com; s=zohoarc; b=ellX1N50mFEjRcLs5gCFXFw6sPvM4uS+fKevMMRvnbXAblB9XY3Ng93K/ZdJ3c96ejSU28OuqTi+fxuagY7lfxGkapDu89xaRd8GJQYKYQGWAolJSyVZbWWlETAUM81wOnUMpmAhH1hPxIJqLZ5A5KG67wMTnb9OK2m9j7lSG+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572050889; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=//aqCDZwicj/ytKlyu7wNZBc0Db52+2suePd3SvnVak=; b=hyF5VINdYLJZzCNHhtd/PWvmvAP8QWRNTQLIHDR1jjGlgh7YllPmFAE3KHzoBOhdDuoUqT7eUOmDJWJ1RknkZJJm1AxTRBKPnh75J53qXaq9vw+dekVWnxqHmKPAuCCeUnTM5f7yoeLk3Xcx0mJpgGNHPWiKhWugUwzF4FNFoOY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15720508895302.3568831105837944; Fri, 25 Oct 2019 17:48:09 -0700 (PDT) Received: from localhost ([::1]:37626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOAFU-0004xc-2X for importer@patchew.org; Fri, 25 Oct 2019 20:48:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54975) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADB-0002aS-SJ for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADA-0004kv-Ra for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADA-0004k9-Jt for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:44 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:44 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:43 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705109" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 2/6] migration/multifd: notify channels_ready when send thread starts Date: Sat, 26 Oct 2019 08:45:16 +0800 Message-Id: <20191026004520.5515-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" multifd_send_state->channels_ready is initialized to 0. It is proper to let main thread know we are ready when thread start running. Current implementation works since ram_save_setup() calls multifd_send_sync_main() which wake up send thread and posts channels_ready. This behavior will introduce some unpredictable situation and disturb the semaphore value. This is a preparation patch to use another mechanism to do send thread synchronization to avoid post channels_ready in this case. So this patch posts channels_ready when send threads start running. Signed-off-by: Wei Yang --- migration/ram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 35f147388b..25d477796e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1107,6 +1107,8 @@ static void *multifd_send_thread(void *opaque) } /* initial packet */ p->num_packets =3D 1; + /* let main thread know we are ready */ + qemu_sem_post(&multifd_send_state->channels_ready); =20 while (true) { qemu_sem_wait(&p->sem); --=20 2.17.1 From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572050892; cv=none; d=zoho.com; s=zohoarc; b=HBa2Fpi/JNM9OZY+xXQ4/VF8NLHRYX+6jX8/nNrBlGfGwHgluRlFMDpO4tY0VUUkOZLuuc0t9GiD98Dh6OJxyBdi3y9kl5M907Bl912s4sMT1FfB6UKjWbXIYLdnzB9krgu6bOrtN2wSnKdJNFAeg8LPZ9sL7sSZBMSuFisCDqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572050892; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9CgwPzYFxVsheEVw+IBtFUtgiLsn2YVpLGRXpszQK5I=; b=BfIOk5K5I6VQ7hYGTLv4TQW5lOeMaC1EVoLAcVW3l/GLYW/CQuLXUZordF/2Jh/ZtPmWfFNGZTmfSAzokWwzHsnn74JIsmd1KylhuH0BqH6HSnx7Mya3w9znj7IQUmiLk/9p9MtIjStDGggBBefYeisYlNvtS2wWHQ3L7awDmN0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572050892195306.70043682810524; Fri, 25 Oct 2019 17:48:12 -0700 (PDT) Received: from localhost ([::1]:37628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOAFW-000550-Ak for importer@patchew.org; Fri, 25 Oct 2019 20:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54994) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADD-0002cd-BN for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADC-0004lS-7D for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:47 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADB-0004k9-WE for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:46 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:45 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705111" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 3/6] migration/multifd: use sync field to synchronize send threads Date: Sat, 26 Oct 2019 08:45:17 +0800 Message-Id: <20191026004520.5515-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a field in MultiFDSendParams to indicate there is a request to synchronize send threads. By doing so, send_thread will just post sem_sync on synchronization request and channels_ready will not *overflow*. Signed-off-by: Wei Yang --- migration/ram.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 25d477796e..62072b7a35 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -641,6 +641,8 @@ typedef struct { QemuMutex mutex; /* is this channel thread running */ bool running; + /* should sync this channel */ + bool sync; /* should this thread finish */ bool quit; /* thread has work to do */ @@ -1074,8 +1076,7 @@ static void multifd_send_sync_main(RAMState *rs) } =20 p->packet_num =3D multifd_send_state->packet_num++; - p->flags |=3D MULTIFD_FLAG_SYNC; - p->pending_job++; + p->sync =3D true; qemu_file_update_transfer(rs->f, p->packet_len); ram_counters.multifd_bytes +=3D p->packet_len; ram_counters.transferred +=3D p->packet_len; @@ -1143,10 +1144,27 @@ static void *multifd_send_thread(void *opaque) p->pending_job--; qemu_mutex_unlock(&p->mutex); =20 - if (flags & MULTIFD_FLAG_SYNC) { - qemu_sem_post(&p->sem_sync); - } qemu_sem_post(&multifd_send_state->channels_ready); + } else if (p->sync) { + uint64_t packet_num =3D p->packet_num; + uint32_t flags =3D p->flags; + assert(!p->pages->used); + + p->flags |=3D MULTIFD_FLAG_SYNC; + multifd_send_fill_packet(p, 0); + p->sync =3D false; + qemu_mutex_unlock(&p->mutex); + + trace_multifd_send(p->id, packet_num, 0, flags | MULTIFD_FLAG_= SYNC, + p->next_packet_size); + + ret =3D qio_channel_write_all(p->c, (void *)p->packet, + p->packet_len, &local_err); + if (ret !=3D 0) { + break; + } + + qemu_sem_post(&p->sem_sync); } else if (p->quit) { qemu_mutex_unlock(&p->mutex); break; @@ -1221,7 +1239,7 @@ int multifd_save_setup(void) qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); qemu_sem_init(&p->sem_sync, 0); - p->quit =3D false; + p->quit =3D p->sync =3D false; p->pending_job =3D 0; p->id =3D i; p->pages =3D multifd_pages_init(page_count); --=20 2.17.1 From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572053307; cv=none; d=zoho.com; s=zohoarc; b=UAXPS/tqsec3yzlERaM4OtCjlF9pj8fXQWFLIhrTbWqLt/tYRssR9tvfF2HnOJBzEW60NkepIApU4ktH3Jl1jPzvW2buVb2GCCiMMef91QoHYa93uWtXLSHwUlldbsnAjy/qcrmNdCzsuOQ0sSz1SDXd+c2aNgifIGR4TrV4xaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572053307; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=rKFmcTVpqbVpem+UR2IePXHzb8dtuFcNudAjkzGirsc=; b=Cia+vekpXbE0wslAZUSOqN3GNNuzcKRcvXN4jmkU9RtkWX/yjzmQ61Mh8HdrYXIfAQfgb7x1sSNB2e0iHyKCnnkvlmvAYnqDDG7TSMHlaIaRvWkMf83jVOmEd90Q4yvMd5Ow1e/1r+NvE1Rm30ib6a12Z1lERrxLK2DyVJmX6bM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157205330767678.06896035933266; Fri, 25 Oct 2019 18:28:27 -0700 (PDT) Received: from localhost ([::1]:37834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOAsU-00082o-JS for importer@patchew.org; Fri, 25 Oct 2019 21:28:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55005) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADF-0002ez-0C for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADD-0004m0-J6 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:48 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADD-0004k9-BW for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:47 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:47 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705113" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 4/6] migration/multifd: used must not be 0 for a pending job Date: Sat, 26 Oct 2019 08:45:18 +0800 Message-Id: <20191026004520.5515-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After thread synchronization request is handled in another case, this means when we only get pending_job when there is used pages. Signed-off-by: Wei Yang --- migration/ram.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 62072b7a35..12c270e86d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1132,12 +1132,11 @@ static void *multifd_send_thread(void *opaque) break; } =20 - if (used) { - ret =3D qio_channel_writev_all(p->c, p->pages->iov, - used, &local_err); - if (ret !=3D 0) { - break; - } + assert(used); + ret =3D qio_channel_writev_all(p->c, p->pages->iov, + used, &local_err); + if (ret !=3D 0) { + break; } =20 qemu_mutex_lock(&p->mutex); --=20 2.17.1 From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572051008; cv=none; d=zoho.com; s=zohoarc; b=Zyt/cn2RGmevAS3YVAy/ADF/WrljAQ5PjpW1g9WZRTDTgd6/wFeaWgfyP6wOGSzrYkiZbr8U0A7ybrwOO/iyW98Sfh+zGQ1fwlWT8+n6dG1pHwWgytbH5babHme4BKJPdAWwCSLExmt8pMk3tNzT5eQ58beIGXKbDeFJuEOEjW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572051008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=yT+VN31RSP1NwFBp+1YIvJsgzmjfWD/cBMNALw+Rujo=; b=V5YqJiJHZwULirfhADXNoph6BztlUHsdRpg6jv7hGFc6vVbeNR2FmyLGCFX7FnKRGiWbXFvf3B9kgUPBGDEnqrtVwbvLoXiirkrtOvWmadcMIw64UT9hpSC1tFbqMdG8DCe8WB93R6UrhXA1yXm7sM74ANW+AYHYYno747LLNj8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572051008533143.21269264151863; Fri, 25 Oct 2019 17:50:08 -0700 (PDT) Received: from localhost ([::1]:37646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOAHP-0002Y3-DP for importer@patchew.org; Fri, 25 Oct 2019 20:50:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55016) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADG-0002hU-06 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADE-0004mN-Vy for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADE-0004k9-NS for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:48 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:48 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:47 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705117" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 5/6] migration/multifd: use boolean for pending_job is enough Date: Sat, 26 Oct 2019 08:45:19 +0800 Message-Id: <20191026004520.5515-6-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After synchronization request is handled in another case, there only could be one pending_job for one send thread at most. This is fine to use boolean to represent this behavior. Signed-off-by: Wei Yang --- migration/ram.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 12c270e86d..fccdbfabc5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -646,7 +646,7 @@ typedef struct { /* should this thread finish */ bool quit; /* thread has work to do */ - int pending_job; + bool pending_job; /* array of pages to sent */ MultiFDPages_t *pages; /* packet allocated len */ @@ -933,7 +933,7 @@ static int multifd_send_pages(RAMState *rs) return -1; } if (!p->pending_job) { - p->pending_job++; + p->pending_job =3D true; next_channel =3D (i + 1) % migrate_multifd_channels(); break; } @@ -1140,7 +1140,7 @@ static void *multifd_send_thread(void *opaque) } =20 qemu_mutex_lock(&p->mutex); - p->pending_job--; + p->pending_job =3D false; qemu_mutex_unlock(&p->mutex); =20 qemu_sem_post(&multifd_send_state->channels_ready); @@ -1238,8 +1238,7 @@ int multifd_save_setup(void) qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); qemu_sem_init(&p->sem_sync, 0); - p->quit =3D p->sync =3D false; - p->pending_job =3D 0; + p->quit =3D p->sync =3D p->pending_job =3D false; p->id =3D i; p->pages =3D multifd_pages_init(page_count); p->packet_len =3D sizeof(MultiFDPacket_t) --=20 2.17.1 From nobody Sun Feb 8 12:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572051138; cv=none; d=zoho.com; s=zohoarc; b=CPYuhBZ5an1ikifE5yKC2lPI4YwFG/gIIClRry7GUV6Vc6D/qKkUe3RwDiHFo7PzyJyAkp26a8ATrEpGWe17nMMI1rKEyP5pmwdFk8hZPJ3gEWMofuSJwR4leUPCCIV5YWV8RaRLK5XwFxGGtbtKPar0pplSz9dItDNTtYsVYmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572051138; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=IRiSW3utrcFjz6kq6M5kC9n6re/8H9Gnwc8ot3oQ8qc=; b=HK5hdIA91SazafcVz5gsSyqF0KYMiV8foijUFUkDxyG/0caBXDD5ojELgIWvAHU2YtVTpTDKUmm0Oqr1kK7SeaEyTTPU5avrSwTqixkYIdfIuIrwVIpt3Gj30scLylYcS0wkI7MusxB6Uyu1jUnf9fNpaUJpwCfMsnZJdAt4FsA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572051138639908.7390800607498; Fri, 25 Oct 2019 17:52:18 -0700 (PDT) Received: from localhost ([::1]:37656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOAJV-0006ej-Fh for importer@patchew.org; Fri, 25 Oct 2019 20:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55030) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOADJ-0002pe-VD for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOADI-0004nf-PA for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:53 -0400 Received: from mga01.intel.com ([192.55.52.88]:5552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOADI-0004k9-Hz for qemu-devel@nongnu.org; Fri, 25 Oct 2019 20:45:52 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 17:45:52 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 17:45:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,230,1569308400"; d="scan'208";a="204705119" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 6/6] migration/multifd: there is no spurious wakeup now Date: Sat, 26 Oct 2019 08:45:20 +0800 Message-Id: <20191026004520.5515-7-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026004520.5515-1-richardw.yang@linux.intel.com> References: <20191026004520.5515-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The spurious wakeup is gone. Signed-off-by: Wei Yang --- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fccdbfabc5..73ace40b1b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1168,8 +1168,8 @@ static void *multifd_send_thread(void *opaque) qemu_mutex_unlock(&p->mutex); break; } else { - qemu_mutex_unlock(&p->mutex); - /* sometimes there are spurious wakeups */ + /* no other case should trigger me */ + g_assert_not_reached(); } } =20 --=20 2.17.1