From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C20E0C433F5 for ; Tue, 23 Nov 2021 18:03:54 +0000 (UTC) Received: from localhost ([::1]:50092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpa93-0006oc-Vm for qemu-devel@archiver.kernel.org; Tue, 23 Nov 2021 13:03:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpZxJ-0006g9-W8 for qemu-devel@nongnu.org; Tue, 23 Nov 2021 12:51:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpZxF-0006ti-JK for qemu-devel@nongnu.org; Tue, 23 Nov 2021 12:51:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637689900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wc/hHgbIzi02f5RiowHdBt1n+v0t3deScK2+D5kW6JI=; b=WORuv5gV/V2pPjGItFM9C5bgSV44/j75spPj9Q4M7XFUfLaduXZVxaJ7+vEp0+Psi80lja tnkep41qpP9JtxUaVYvWjXCDmVCfgh7cRePyqir9prs+aAhm90xUG9AYUNFd6JkkBISUnx 3o1PXpyXIq/5I+Hm7tKZJsEWSuCHVl0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-GokJsKggNASkdHxOKWCing-1; Tue, 23 Nov 2021 12:51:40 -0500 X-MC-Unique: GokJsKggNASkdHxOKWCing-1 Received: by mail-wm1-f70.google.com with SMTP id g80-20020a1c2053000000b003331a764709so1582448wmg.2 for ; Tue, 23 Nov 2021 09:51:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wc/hHgbIzi02f5RiowHdBt1n+v0t3deScK2+D5kW6JI=; b=d+w9hFjxRTDifImLdIx2bqjjVtRg0g+3FzwXnTSgdW8YZJBpc9HfyWE0gyAKgfIIb6 PGkpYZb+2GobRJRqOrcmb/RF4NPs0NMKgH28IoX99CERtTWG/J7Ig4c7yC/73+o7H2Ld KoL9CrE7DFPL5hyb9ns42wbwSH2EyWr4T5FfC3gCAlD8WLXrU6AF8Ntq+TkWX8qq4una CEkgu1Pm721WSCOEML7XIUPmJcz6rN7+TLoqIXS8H6Os1K58Ge2OfUWMoJGVU4UMfnux AuZdoyLhBD8eR2D2p8O9ZwirdQ8tdEqLL0K5pm2+C6jYAY0VqQfiWnnRLLssq3PJP8qT b6Vg== X-Gm-Message-State: AOAM5306oDj6yev/NgAtA6ZBunGEt8TYll+WeSx5tLV7DVxt+PxQhkjn E7HKIIRxfH60v4aTSrgaOfPmX9qg7/De1TUuiByLAEOjvLWP6t+3Sm6ODHkTjLE2iNi6Kq11raI ZeJqilT1ZqywLstMYt2Zf4cU4eyNQPJs/J2cnHlavzMk4F33QCvkcg6m2rffGCa9fWJ0= X-Received: by 2002:a05:6000:1a48:: with SMTP id t8mr9586195wry.66.1637689898238; Tue, 23 Nov 2021 09:51:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKq04oGM5uBY7RNptXkd14NE96VVJKXn8BivHr7O4bllXl3SBuiXABli3KsYml4l5nfZtO9Q== X-Received: by 2002:a05:6000:1a48:: with SMTP id t8mr9586159wry.66.1637689897985; Tue, 23 Nov 2021 09:51:37 -0800 (PST) Received: from localhost (static-233-86-86-188.ipcom.comunitel.net. [188.86.86.233]) by smtp.gmail.com with ESMTPSA id l22sm1744743wmp.34.2021.11.23.09.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 09:51:37 -0800 (PST) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH 15/23] multifd: Use a single writev on the send side Date: Tue, 23 Nov 2021 18:51:05 +0100 Message-Id: <20211123175113.35569-16-quintela@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211123175113.35569-1-quintela@redhat.com> References: <20211123175113.35569-1-quintela@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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, SPF_HELO_NONE=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: , Cc: Leonardo Bras , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Until now, we wrote the packet header with write(), and the rest of the pages with writev(). Just increase the size of the iovec and do a single writev(). Signed-off-by: Juan Quintela --- migration/multifd.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 71bdef068e..65676d56fd 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -643,7 +643,7 @@ static void *multifd_send_thread(void *opaque) uint32_t used = p->pages->num; uint64_t packet_num = p->packet_num; uint32_t flags = p->flags; - p->iovs_num = 0; + p->iovs_num = 1; if (used) { ret = multifd_send_state->ops->send_prepare(p, &local_err); @@ -663,20 +663,15 @@ static void *multifd_send_thread(void *opaque) trace_multifd_send(p->id, packet_num, used, flags, p->next_packet_size); - ret = qio_channel_write_all(p->c, (void *)p->packet, - p->packet_len, &local_err); + p->iov[0].iov_len = p->packet_len; + p->iov[0].iov_base = p->packet; + + ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num, + &local_err); if (ret != 0) { break; } - if (used) { - ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num, - &local_err); - if (ret != 0) { - break; - } - } - qemu_mutex_lock(&p->mutex); p->pending_job--; qemu_mutex_unlock(&p->mutex); @@ -913,7 +908,8 @@ int multifd_save_setup(Error **errp) p->packet->version = cpu_to_be32(MULTIFD_VERSION); p->name = g_strdup_printf("multifdsend_%d", i); p->tls_hostname = g_strdup(s->hostname); - p->iov = g_new0(struct iovec, page_count); + /* We need one extra place for the packet header */ + p->iov = g_new0(struct iovec, page_count + 1); socket_send_channel_create(multifd_new_send_channel_async, p); } -- 2.33.1