From patchwork Mon Jul 11 21:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 12914297 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 4FC28C43334 for ; Mon, 11 Jul 2022 21:13:30 +0000 (UTC) Received: from localhost ([::1]:37094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oB0if-0005Xc-EP for qemu-devel@archiver.kernel.org; Mon, 11 Jul 2022 17:13:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0h2-0003Sx-12 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0gz-0004aw-C8 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657573904; 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=xcNVwgQ9IZol65+g6ClDaFHZ7+0gJX3iogcnux754+Q=; b=flpZ+3xYqEATq7T20xjfjSDF8N8cZ89IsqVjI6dJjBgUmgiYOpVzTOeeKtoQCZQEhcdDKn ub0hdLLEh1I5StGd4Y27wvI1J8CR+yQGEkQx1TwS8ANo8uCIJ0ZQc1u8FDea5KgHAsqrHd rc15JtD46HnGkboN5TWssKUHGXMrm9w= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-cLAAYnOgM6aO6x8RXjazvQ-1; Mon, 11 Jul 2022 17:11:37 -0400 X-MC-Unique: cLAAYnOgM6aO6x8RXjazvQ-1 Received: by mail-oi1-f200.google.com with SMTP id m2-20020aca1e02000000b0033a087dd9c1so1186166oic.8 for ; Mon, 11 Jul 2022 14:11:37 -0700 (PDT) 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=xcNVwgQ9IZol65+g6ClDaFHZ7+0gJX3iogcnux754+Q=; b=rFjhU/C4AlKhDjafnkpdnBdjT5Ko1jDk1S1WdL/V6sxFzX5tiRjAokFsevQ2DfA6rb f9Q6p+mR/1UP6XNt4rXuxbmbuqL82EuKUEyvdTgaGm6S4OgJ0HRLyD9nWto3yVUc0kWK i7QS6A2ki08OPoCZ+mxX2YCkInUd2OFxPJVfwqqdNRkOrsBBlRSYp7WdAO5SLINLJZL1 K2tS0u0cdufEn0wA3iSMZxEnv+rI4fTJ/hHW7wWkNVC+DAjzvMunqnwCucdJf/t36QpO AztkM/J5X1oBvDrzB1qCiH6ah72r0KPekYkGtO8WbbCPxu5MtCX3xUKXSSz/dIUE2JCL F+Wg== X-Gm-Message-State: AJIora//zsNvCuCmJNVQR4o9791C1W/L2o082S/VxNp/A9g8y/Z2mZ8R J7p2PkfhYCJ8D3dQwzHoDJ50QXayyyCWZj+A+QHXPKTLMDgSFpnavFvK042RtHzkUfrbnKo0Fsj mHqrEY3r2qBYlG3Y= X-Received: by 2002:a05:6808:1308:b0:337:a84c:ccb4 with SMTP id y8-20020a056808130800b00337a84cccb4mr195504oiv.218.1657573896940; Mon, 11 Jul 2022 14:11:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOat4JoENWl4Mt+K4QK2rb/px/NxtfQwDUU0/HNoGPax5WkNTLhvj141XYLg8R5a1o2J/jLA== X-Received: by 2002:a05:6808:1308:b0:337:a84c:ccb4 with SMTP id y8-20020a056808130800b00337a84cccb4mr195499oiv.218.1657573896794; Mon, 11 Jul 2022 14:11:36 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7f0:d647:bb68:29a5:e512:2c8b]) by smtp.gmail.com with ESMTPSA id q7-20020a0568080a8700b00339eb701c6csm3140343oij.41.2022.07.11.14.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:36 -0700 (PDT) From: Leonardo Bras To: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v4 1/3] QIOChannelSocket: Fix zero-copy flush returning code 1 when nothing sent Date: Mon, 11 Jul 2022 18:11:11 -0300 Message-Id: <20220711211112.18951-2-leobras@redhat.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711211112.18951-1-leobras@redhat.com> References: <20220711211112.18951-1-leobras@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=leobras@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If flush is called when no buffer was sent with MSG_ZEROCOPY, it currently returns 1. This return code should be used only when Linux fails to use MSG_ZEROCOPY on a lot of sendmsg(). Fix this by returning early from flush if no sendmsg(...,MSG_ZEROCOPY) was attempted. Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX") Signed-off-by: Leonardo Bras Reviewed-by: Daniel P. Berrangé Acked-by: Daniel P. Berrangé Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- io/channel-socket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index 4466bb1cd4..74a936cc1f 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -716,12 +716,18 @@ static int qio_channel_socket_flush(QIOChannel *ioc, struct cmsghdr *cm; char control[CMSG_SPACE(sizeof(*serr))]; int received; - int ret = 1; + int ret; + + if (sioc->zero_copy_queued == sioc->zero_copy_sent) { + return 0; + } msg.msg_control = control; msg.msg_controllen = sizeof(control); memset(control, 0, sizeof(control)); + ret = 1; + while (sioc->zero_copy_sent < sioc->zero_copy_queued) { received = recvmsg(sioc->fd, &msg, MSG_ERRQUEUE); if (received < 0) { From patchwork Mon Jul 11 21:11:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 12914298 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 C2652C433EF for ; Mon, 11 Jul 2022 21:13:34 +0000 (UTC) Received: from localhost ([::1]:37296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oB0ij-0005fx-KA for qemu-devel@archiver.kernel.org; Mon, 11 Jul 2022 17:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0h5-0003cQ-Gj for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0h4-0004bZ-0F for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657573909; 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=4EnfjwoFu5gXzhfioZUD23J5aySyG4aYgh7E7ECoRy0=; b=PlR86hOxAigvdMxffGvF0HlOreOgA3mNveX0qjTloFvrMs/ckjuWYFsLmUIWJXlFjiXFWm VykliyqfjJetsHenT5x/ZsL2Ta1QZTSZM2FIgy8RAbfDXUq9ntxmwDsL6UA5LtgRJJZNk0 XVciybKGnD96A95bEgrXfHOg5/PDL1Q= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-bMybbfg6OQiTJDXwVH9fFw-1; Mon, 11 Jul 2022 17:11:40 -0400 X-MC-Unique: bMybbfg6OQiTJDXwVH9fFw-1 Received: by mail-oi1-f199.google.com with SMTP id w1-20020aca3001000000b00335750b9a50so4342014oiw.10 for ; Mon, 11 Jul 2022 14:11:40 -0700 (PDT) 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=4EnfjwoFu5gXzhfioZUD23J5aySyG4aYgh7E7ECoRy0=; b=gOv2UMMkAmCEGF+7l6yEzUtQBV0alDmq11c4Im+lSyAtDAu4mHySJOEJ+UMjH9IOaR EGge98Aych6loADfZzYZ7+mDLQ7dGuOvzpX4tIDBnKxfZUwASNiBjiOibpX7kTwtg3HY BaJg/THeI0mrh9hnI9pPpzdWdSkq/CUdUrF4peyZv/S8aByo81XY2hcLvo0om4rnqvnM +A3rW81d2pmGEHQDBXVj/K8+azSDbWG/VS08V5PcczhDvXltDv/p7Xod1SFg9rxLlbNn uUAQMMU5BvbIFqyfbXJDJ0i/VYZv/1tufbe2yLNQW/37AZtp6hhyMh7tAEV00rhL1Uwn Rv5w== X-Gm-Message-State: AJIora9topofxMfNxCH3JgeDucs00s6+80nMUVBw5wWaeUGPNR4Bbq2Y 0754fiFVD3bw4utmL3O4hQppgOR/oX/2wc7JgaHh4PcLMELz1qhsOhzym9ief2teRIlqdOGwzPo o883AMYAUlymRfKU= X-Received: by 2002:a05:6808:114b:b0:337:ab89:d5be with SMTP id u11-20020a056808114b00b00337ab89d5bemr185811oiu.299.1657573899890; Mon, 11 Jul 2022 14:11:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5gqwUJYmDwpxwZiAs7Ksc92L+1ljVheFBGg2v2npqOgSwfuTGBCb55aVPvQQ+PDRKHMgWjg== X-Received: by 2002:a05:6808:114b:b0:337:ab89:d5be with SMTP id u11-20020a056808114b00b00337ab89d5bemr185800oiu.299.1657573899723; Mon, 11 Jul 2022 14:11:39 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7f0:d647:bb68:29a5:e512:2c8b]) by smtp.gmail.com with ESMTPSA id q7-20020a0568080a8700b00339eb701c6csm3140343oij.41.2022.07.11.14.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:39 -0700 (PDT) From: Leonardo Bras To: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v4 2/3] Add dirty-sync-missed-zero-copy migration stat Date: Mon, 11 Jul 2022 18:11:12 -0300 Message-Id: <20220711211112.18951-3-leobras@redhat.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711211112.18951-1-leobras@redhat.com> References: <20220711211112.18951-1-leobras@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=leobras@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Leonardo Bras Acked-by: Markus Armbruster Reviewed-by: Daniel P. Berrangé Acked-by: Peter Xu --- qapi/migration.json | 7 ++++++- migration/migration.c | 2 ++ monitor/hmp-cmds.c | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 7102e474a6..4a03e8f173 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -55,6 +55,10 @@ # @postcopy-bytes: The number of bytes sent during the post-copy phase # (since 7.0). # +# @dirty-sync-missed-zero-copy: Number of times dirty RAM synchronization could +# not avoid copying dirty pages. This is between +# 0 and @dirty-sync-count * @multifd-channels. +# (since 7.1) # Since: 0.14 ## { 'struct': 'MigrationStats', @@ -65,7 +69,8 @@ 'postcopy-requests' : 'int', 'page-size' : 'int', 'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64', 'precopy-bytes' : 'uint64', 'downtime-bytes' : 'uint64', - 'postcopy-bytes' : 'uint64' } } + 'postcopy-bytes' : 'uint64', + 'dirty-sync-missed-zero-copy' : 'uint64' } } ## # @XBZRLECacheStats: diff --git a/migration/migration.c b/migration/migration.c index 78f5057373..048f7f8bdb 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1027,6 +1027,8 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s) info->ram->normal_bytes = ram_counters.normal * page_size; info->ram->mbps = s->mbps; info->ram->dirty_sync_count = ram_counters.dirty_sync_count; + info->ram->dirty_sync_missed_zero_copy = + ram_counters.dirty_sync_missed_zero_copy; info->ram->postcopy_requests = ram_counters.postcopy_requests; info->ram->page_size = page_size; info->ram->multifd_bytes = ram_counters.multifd_bytes; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ca98df0495..a6dc79e0d5 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -307,6 +307,11 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) monitor_printf(mon, "postcopy ram: %" PRIu64 " kbytes\n", info->ram->postcopy_bytes >> 10); } + if (info->ram->dirty_sync_missed_zero_copy) { + monitor_printf(mon, + "Zero-copy-send fallbacks happened: %" PRIu64 " times\n", + info->ram->dirty_sync_missed_zero_copy); + } } if (info->has_disk) { From patchwork Mon Jul 11 21:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 12914299 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 AF4A8C43334 for ; Mon, 11 Jul 2022 21:14:56 +0000 (UTC) Received: from localhost ([::1]:41360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oB0k3-0008OR-NT for qemu-devel@archiver.kernel.org; Mon, 11 Jul 2022 17:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0h2-0003W6-RQ for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oB0h1-0004bO-8y for qemu-devel@nongnu.org; Mon, 11 Jul 2022 17:11:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657573906; 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=b1cZnN6gjKaE1lxGysABJPYP86zhw9qlbCgi9BNOBrc=; b=GfF36Ka93UBppMzXX5N7BE+CANrreBrGHJIb/K0nSydYmfopUV08kartFbtUdqZE+x6VJ+ 8ehe21yiuY8xgJHcasV7Byp6Q86WZ6OeCOEog47XWJPFq79J99xh6V380sfwRaAkxzW+OI CXZA/Dn/zdSzAQonsNoXS4yI5808y1A= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-0mJMWzvQPh-xYhEPwVIazg-1; Mon, 11 Jul 2022 17:11:43 -0400 X-MC-Unique: 0mJMWzvQPh-xYhEPwVIazg-1 Received: by mail-ot1-f71.google.com with SMTP id n21-20020a9d7415000000b0061c30887d34so2064888otk.17 for ; Mon, 11 Jul 2022 14:11:43 -0700 (PDT) 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=b1cZnN6gjKaE1lxGysABJPYP86zhw9qlbCgi9BNOBrc=; b=WcOkKxChPJSmPJ1H4u/fb3hpX2QjlxmnxZFYVB1FSnd26LcwGi/YUi1z+8bQOEN+JC p28QfczZRKuwzM3b6x52FLz4N/PFmi5tpGVoCUocTAB1kAC5ms1DV9jx3ShjOPkNv3FN X6qD+M088XymLQq0qfJ3JTerWdrRaF0mO/56OqQDQoOlzKysUfoVDeU88mibt0oUMSEU SCiKxpHj+JHFY1wH3MRQNMJ5HSk/cLazX39PrZyyiXN58CodCeZt1wt3SWRo/C1Uxzjb 85lcAG7p14KCUpSfX5wg/YAkEOLkIj0+W5ZThoW+onuquBnFc4POvVAS4p4blB7gHoUP 300A== X-Gm-Message-State: AJIora/u//BffhCAVM4DSl5tvaLvYnVoCaUT2ZpkAB85DWPBDPbPmO2P 2kppWapDtWjmqfiYDFVPIkMb7Yyg7JCxf61mRWkmX0ICYp3s1Hv7t59rVWRmiW6avpvwNzirSip uLhXpJqCt5zi28Mg= X-Received: by 2002:a05:6820:1886:b0:434:7842:bd6 with SMTP id bm6-20020a056820188600b0043478420bd6mr4409632oob.23.1657573902847; Mon, 11 Jul 2022 14:11:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tscn8KYRhYFpcbTafZI6lg9h9WmOd/UTR4IrHVxRveJ/fMyulCUX8gd1Zq8mIQGht+SqJoqQ== X-Received: by 2002:a05:6820:1886:b0:434:7842:bd6 with SMTP id bm6-20020a056820188600b0043478420bd6mr4409620oob.23.1657573902638; Mon, 11 Jul 2022 14:11:42 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7f0:d647:bb68:29a5:e512:2c8b]) by smtp.gmail.com with ESMTPSA id q7-20020a0568080a8700b00339eb701c6csm3140343oij.41.2022.07.11.14.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:42 -0700 (PDT) From: Leonardo Bras To: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v4 3/3] migration/multifd: Report to user when zerocopy not working Date: Mon, 11 Jul 2022 18:11:13 -0300 Message-Id: <20220711211112.18951-4-leobras@redhat.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711211112.18951-1-leobras@redhat.com> References: <20220711211112.18951-1-leobras@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=leobras@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Some errors, like the lack of Scatter-Gather support by the network interface(NETIF_F_SG) may cause sendmsg(...,MSG_ZEROCOPY) to fail on using zero-copy, which causes it to fall back to the default copying mechanism. After each full dirty-bitmap scan there should be a zero-copy flush happening, which checks for errors each of the previous calls to sendmsg(...,MSG_ZEROCOPY). If all of them failed to use zero-copy, then increment dirty_sync_missed_zero_copy migration stat to let the user know about it. Signed-off-by: Leonardo Bras Reviewed-by: Daniel P. Berrangé Acked-by: Peter Xu --- migration/ram.h | 2 ++ migration/multifd.c | 2 ++ migration/ram.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/migration/ram.h b/migration/ram.h index ded0a3a086..d3c7eb96f5 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -87,4 +87,6 @@ void ram_write_tracking_prepare(void); int ram_write_tracking_start(void); void ram_write_tracking_stop(void); +void dirty_sync_missed_zero_copy(void); + #endif diff --git a/migration/multifd.c b/migration/multifd.c index 684c014c86..3909b34967 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -624,6 +624,8 @@ int multifd_send_sync_main(QEMUFile *f) if (ret < 0) { error_report_err(err); return -1; + } else if (ret == 1) { + dirty_sync_missed_zero_copy(); } } } diff --git a/migration/ram.c b/migration/ram.c index 01f9cc1d72..db948c4787 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -407,6 +407,11 @@ static void ram_transferred_add(uint64_t bytes) ram_counters.transferred += bytes; } +void dirty_sync_missed_zero_copy(void) +{ + ram_counters.dirty_sync_missed_zero_copy++; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */