From nobody Sun May 5 07:26:45 2024 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=1559811160; cv=none; d=zoho.com; s=zohoarc; b=A8HJbP+W67uRXckYhdHbzIltZBvHbDoZEK3cE2LlJ45WYYnsq4OJ3o+MbmkQBZkUC7rm55sLtdxFUaPqZt6AIxXpN3qT7gYaUKOUFtddHWAQhlLrhgxlko8yQUt4/mnRypO/G0Dy3ZQG/0c5IjDH/j/KOtTYyfJncwWiqnQ16qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559811160; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CQc4t8s3iV7ITRJebA0uCrvhpQZOZMQdF7tI1LiJEtw=; b=VzWCu+nagNSc+4WYaa/sLhdeGD+yub86GeE1Rr0CAxOvobDmJjgXmp7gZoJElc42rXTGJQBFSGDCo7jixPMflVSdlx4+JTriKwSV8ifGQoB9535MHpHFRNNG2n0RXugNObGbOcgzt1zCijPzxW1txik2w7eXVvN3IGcevcfp7kI= 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 1559811160250478.339637771801; Thu, 6 Jun 2019 01:52:40 -0700 (PDT) Received: from localhost ([127.0.0.1]:56704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYo8V-0003IX-67 for importer@patchew.org; Thu, 06 Jun 2019 04:52:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyf-0003Zd-JU for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsH-0003UA-LV for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:54 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsH-0003TJ-Cg for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:53 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:52 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:51 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:34:56 +0800 Message-Id: <20190606083501.2087-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 1/6] migration/multifd: move MultiFDSendParams handling into multifd_send_fill_packet() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Currently there is only one user of multifd_send_fill_packet(). We enlarge the responsibility of it to adjust MultiFDSendParams. Signed-off-by: Wei Yang --- migration/ram.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index bd356764ff..a4e7587648 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -787,9 +787,11 @@ static void multifd_pages_clear(MultiFDPages_t *pages) static void multifd_send_fill_packet(MultiFDSendParams *p) { MultiFDPacket_t *packet =3D p->packet; + MultiFDPages_t *pages =3D p->pages; uint32_t page_max =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); int i; =20 + p->next_packet_size =3D pages->used * qemu_target_page_size(); packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); packet->version =3D cpu_to_be32(MULTIFD_VERSION); packet->flags =3D cpu_to_be32(p->flags); @@ -805,6 +807,10 @@ 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->flags =3D 0; + p->num_packets++; + p->num_pages +=3D pages->used; + p->pages->used =3D 0; } =20 static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) @@ -1097,12 +1103,7 @@ static void *multifd_send_thread(void *opaque) uint64_t packet_num =3D p->packet_num; uint32_t 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; qemu_mutex_unlock(&p->mutex); =20 trace_multifd_send(p->id, packet_num, used, flags, --=20 2.19.1 From nobody Sun May 5 07:26:45 2024 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=1559810635; cv=none; d=zoho.com; s=zohoarc; b=L0tCLMaZtx/jcswYYpv6NAzNSHhx3raZGnqByjRjks6xYYv9WxQMQLyEiEIaWZCXGBMEPN1FwOoK0KvIJyZcMaEpMmPVjOP0up3a5ppxXKSJ7+xiZaQIfxOb5HtofJTLVHkiNUPWzDDVDJBdN3ZODsjY1v8qKF4ReGngPD5kASc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559810635; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KN3EvPqcRqPK/zBM+39auMx2kh5hghjW7+Z6KxLKvog=; b=TojIbMsHZIAp9WZECT+GxrgcgEB2IDLCb9UvbC7OCCwAVCrhxIhH11nhOa1G8v85LgQBmbLUOnIT1qusLGhg3YZDMi6Y85gqp57Gk+r0P8HsPNf+VTGvlHGZP1wNMKh8kO4ApXYsQB1MJpPH/yGv+goYdnxu8tDrLaFT5qgp5lE= 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 1559810635638875.825893055646; Thu, 6 Jun 2019 01:43:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:56562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnzw-0004V7-3h for importer@patchew.org; Thu, 06 Jun 2019 04:43:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyD-0003ZF-Na for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsI-0003V1-4h for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:54 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsH-0003TJ-Sd for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:54 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:53 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:52 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:34:57 +0800 Message-Id: <20190606083501.2087-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 2/6] migration/multifd: notify channels_ready when send thread starts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 a4e7587648..f9e53ac413 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1093,6 +1093,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.19.1 From nobody Sun May 5 07:26:45 2024 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=1559810901; cv=none; d=zoho.com; s=zohoarc; b=Hf80jphpNBzbnZfnv8BJoR10qP1MwKfMyf/d2HvvmPx17wgt6nfjTnwLR3WWQdTFMeZO0DvHrcEOztdLrUeXFgoy16O+YrODhfNUNw96vYr1DRx+jTpbVzu9h9LbjEWw5xMP6vnHr/Ks3Ue2KfMa+XOFr4x9xlMY6aVP4rFdOGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559810901; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GTH4V2Qg6cn1+2FbaHX6i574+zTKpuuUZfn0Iy31mIA=; b=FA+7jEEG7rw4G8nsY0CGI4Y6PeDJuDsP8lsYBtlbINIhJTylp8CjTnkoYJJVaCy/ZdulGRy/fRZUo8ryzCMxHvMJItTwdyacJUOobm1M6lSoNXUXlI2lRJB3SfFQlQmI6Chm9nZJ5kPnZbXqMKQNVZcNnQFOfwNxZ+w0qOvf1MQ= 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 1559810901896421.8883772576215; Thu, 6 Jun 2019 01:48:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:56636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYo4H-0008DD-P3 for importer@patchew.org; Thu, 06 Jun 2019 04:48:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyf-0003mZ-6q for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsJ-0003W5-Ie for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:56 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsJ-0003TJ-Ap for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:55 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:55 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:54 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:34:58 +0800 Message-Id: <20190606083501.2087-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 3/6] migration/multifd: use sync field to synchronize send threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 f9e53ac413..9982930392 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -640,6 +640,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 */ @@ -1065,8 +1067,7 @@ static void multifd_send_sync_main(void) qemu_mutex_lock(&p->mutex); =20 p->packet_num =3D multifd_send_state->packet_num++; - p->flags |=3D MULTIFD_FLAG_SYNC; - p->pending_job++; + p->sync =3D true; qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); } @@ -1129,10 +1130,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(&multifd_send_state->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); + 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(&multifd_send_state->sem_sync); } else if (p->quit) { qemu_mutex_unlock(&p->mutex); break; @@ -1196,7 +1214,7 @@ int multifd_save_setup(void) =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); - p->quit =3D false; + p->sync =3D p->quit =3D false; p->pending_job =3D 0; p->id =3D i; p->pages =3D multifd_pages_init(page_count); --=20 2.19.1 From nobody Sun May 5 07:26:45 2024 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=1559810759; cv=none; d=zoho.com; s=zohoarc; b=IiINRK4/swZIIxmqbgRB8mao2MoHO1OPOFMYCHYxPL7yg1XIdR01x8Mygcx3p5W0QZhmZFlF9wEPkAJ+PuMerz5ZtHQrXv+Fd9l2LgkdiyLryhs9Ndy4dXIDnBtorlcrbb9HDROGEf/WGcXaopikyPnTV3puOKW+zlUxf6cBKwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559810759; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=n8Esa07dEbsqW1/Q4zP/T/i7/Rzc5eZIu/l1aFg++rg=; b=gW7Y1PnnZM4MjGOVmxTW44vs+PoeER/46ThkSFfuTYiLrrfLp9quOjICLVSJmhKyxN3g5Y/OQcg1CFpHoHQsbhS/nxTIP7ZF/y3qRlfvHP4U3X/YV3lbpGbi2my2/uEFgq49n6Ucek3RWFKk1xxVnHilpGwLDj9Axb5Dn3sW4cI= 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 1559810759594100.61987858650764; Thu, 6 Jun 2019 01:45:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:56584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYo1g-00061M-Hv for importer@patchew.org; Thu, 06 Jun 2019 04:45:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyf-0003nJ-60 for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsL-0003Wm-2G for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:57 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsK-0003TJ-PI for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:56 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:56 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:55 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:34:59 +0800 Message-Id: <20190606083501.2087-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 4/6] migration/multifd: used must not be 0 for a pending job X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9982930392..3e48795608 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1118,12 +1118,11 @@ static void *multifd_send_thread(void *opaque) break; } =20 - if (used) { - ret =3D qio_channel_writev_all(p->c, p->pages->iov, + assert(used); + ret =3D qio_channel_writev_all(p->c, p->pages->iov, used, &local_err); - if (ret !=3D 0) { - break; - } + if (ret !=3D 0) { + break; } =20 qemu_mutex_lock(&p->mutex); --=20 2.19.1 From nobody Sun May 5 07:26:45 2024 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=1559811039; cv=none; d=zoho.com; s=zohoarc; b=anEkpSJRo/ZQbNfVqaoM0joi5rYUTHjLwWBGD5NxWQ2alaaMTpmpJA9Vh0ur0vnNVXkQXAcCqYqsr6DdvgdkL5ajPRjYm7vT3TMvy9ru/eVVYs8raQuw7pLQ8sUfnBxUdtAZShG5RNQcq7YW0CpAhLgsD9CwyRJWOcM5ybKjusU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559811039; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=biwtfZxC44ilGWMbQwpamWU2JyJiztquFClKXvy04W8=; b=bAJVYjk6sgWBuMkZAajs7QBJYbCANdiA/nC6sl90f2PYQ59kMxlRhyPuwJCoIXe2iZAbxmDh21S2BVRX2aBwTq8cbdzgil7CSGIf9WTb1k3QZC6pTF94F3IMEqN5MIyOs9LTbIu/pemKAyhC0W4elCh2JzPy98QmvL4VKiFA8Jc= 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 1559811039671728.4501612573231; Thu, 6 Jun 2019 01:50:39 -0700 (PDT) Received: from localhost ([127.0.0.1]:56654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYo6T-0001QS-IJ for importer@patchew.org; Thu, 06 Jun 2019 04:50:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyf-0003nK-5M for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsM-0003YH-Fa for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:59 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsM-0003TJ-80 for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:35:58 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:57 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:57 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:35:00 +0800 Message-Id: <20190606083501.2087-6-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 5/6] migration/multifd: use boolean for pending_job is enough X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 3e48795608..831b15833b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -645,7 +645,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 */ @@ -942,7 +942,7 @@ static void multifd_send_pages(void) =20 qemu_mutex_lock(&p->mutex); if (!p->pending_job) { - p->pending_job++; + p->pending_job =3D true; next_channel =3D (i + 1) % migrate_multifd_channels(); break; } @@ -1126,7 +1126,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); @@ -1213,8 +1213,7 @@ int multifd_save_setup(void) =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); - p->sync =3D p->quit =3D false; - p->pending_job =3D 0; + p->sync =3D p->quit =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.19.1 From nobody Sun May 5 07:26:45 2024 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=1559810804; cv=none; d=zoho.com; s=zohoarc; b=FbxlHkPT8gGQhzsF8naypqomCPJlIfqIALEJ34FBSsYgH1XCgEdYze/ZSzmu0LBIbH/nUSFihqo1aE3tvngYf1fLESqKSsdIx0HFamobmY5/O6w6p2pCEbFoFMMm3Ai4UX9CVgHMVH5lcQgm1PblN5Eym3dfPe4rbVxa2/GUJbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559810804; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OoULRJeT2XZYg2oe+fKuvIjjwiZqU85yGT6ZA4g9n0s=; b=EnvjTPujLZG3pGBjtv8I98iVUEsdSvrusJiI+HONX+R8cNU9nuQF2uEgstGC0kpfDZEiI41SxrfzkoeiiMepdlXQrMqpwltD6sHcyNs1pjN2D+GfJ0edk1Lc286/zDZcuT9c0YBwgAKWR8FIW8FOnoT9uSXnIw6jsvafld57P6c= 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 1559810804408282.47886153930233; Thu, 6 Jun 2019 01:46:44 -0700 (PDT) Received: from localhost ([127.0.0.1]:56620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYo2l-0006t4-50 for importer@patchew.org; Thu, 06 Jun 2019 04:46:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYnyf-0003m0-3y for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYnsO-0003az-Au for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:36:01 -0400 Received: from mga14.intel.com ([192.55.52.115]:4990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYnsO-0003TJ-2o for qemu-devel@nongnu.org; Thu, 06 Jun 2019 04:36:00 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 01:35:59 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 01:35:58 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 16:35:01 +0800 Message-Id: <20190606083501.2087-7-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190606083501.2087-1-richardw.yang@linux.intel.com> References: <20190606083501.2087-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 6/6] migration/multifd: there is no spurious wakeup now X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The spurious wakeup is gone. Signed-off-by: Wei Yang --- migration/ram.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 831b15833b..2490631d52 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1153,9 +1153,6 @@ static void *multifd_send_thread(void *opaque) } else if (p->quit) { qemu_mutex_unlock(&p->mutex); break; - } else { - qemu_mutex_unlock(&p->mutex); - /* sometimes there are spurious wakeups */ } } =20 --=20 2.19.1