From patchwork Mon Jul 4 20:23: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: 12905820 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 13C9FC43334 for ; Mon, 4 Jul 2022 20:25:38 +0000 (UTC) Received: from localhost ([::1]:58972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8SdV-0006mO-Tl for qemu-devel@archiver.kernel.org; Mon, 04 Jul 2022 16:25:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbf-0005Jr-VQ for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbd-0004Vd-RX for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656966221; 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=Ox4Xsr5IIBa2MFVKUDBG2RSJB9QVYlygPUGinGBDL2A=; b=Q9HjEKhbav25Kaq29wzcRJjUn62KzDFSbLAHOm5fFQbZ/nz+pF974NZ+LYpkikQaehg2Ve Z083mJjb+M85CrhaaWqdPaBcpZbYBNG7NB9TCzrcrYlZcNICbeoR7Mo1Y55EZbEFIygoZs sqBikl0KXH4nL6LQvXh6HLFsIbGoEuo= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-4tZos8LpMr2rkwJqyIS3Hw-1; Mon, 04 Jul 2022 16:23:40 -0400 X-MC-Unique: 4tZos8LpMr2rkwJqyIS3Hw-1 Received: by mail-qk1-f198.google.com with SMTP id a7-20020a37b107000000b006af3bc02282so9612683qkf.21 for ; Mon, 04 Jul 2022 13:23: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=Ox4Xsr5IIBa2MFVKUDBG2RSJB9QVYlygPUGinGBDL2A=; b=Lyv7skT4HBg7xNvhGJt5UKIlAKYkJEO6yYeyKwaI1TnSp+XZVm99roBd7/mlv3f+Of xgdOuhEksJH4+FMO/pPngYffwRIzLjhIPqQ0Lu91i5TQFhRYH+tXi67xdIsF9qrT07Ue Nnd2NseO2fWuhB0CYKwgozJxMvLI0C0WwAaPCPb7nbcvInmuvciSGCTB3X7NLqrnO4uH P8QII1VrOG3CMGwoe0G85rkNTAevlxX4D6pnjkay7P8o3m+mV8il1iDiRikKOb+IF5Wz CjDzraOUT7FF7tpJFE5Jr/joGrNza7hix0FWGfXkaCx7KNK9/sJzrQw+mnIju1PKPecZ zEDg== X-Gm-Message-State: AJIora/j/t2knuQpFg6sE4vcEZkP2rufJftr00RFiJzDTo/RM+B4ZcqV P4bas0PF0juiupvPkwvBKf3B1kFhCdP0rjazxtNfK+yNs6xIO0WWPcqgWchxHLza08wcopxa4oS o9fhk3M4AWKQKZ3c= X-Received: by 2002:a05:620a:254f:b0:6a6:313:3ccc with SMTP id s15-20020a05620a254f00b006a603133cccmr21605856qko.716.1656966219591; Mon, 04 Jul 2022 13:23:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1smvhwmfEbI6cm52kGTzN7jd8QZvN/woQ1BQh+NL40GhQ3VIqUWwpFN6wypwasjCoauwP41GA== X-Received: by 2002:a05:620a:254f:b0:6a6:313:3ccc with SMTP id s15-20020a05620a254f00b006a603133cccmr21605845qko.716.1656966219380; Mon, 04 Jul 2022 13:23:39 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7ed:cb75:d392:178:9101:5763]) by smtp.gmail.com with ESMTPSA id k11-20020a05620a0b8b00b006b25570d1c2sm9180127qkh.12.2022.07.04.13.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 13:23:38 -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 v3 1/3] QIOChannelSocket: Fix zero-copy flush returning code 1 when nothing sent Date: Mon, 4 Jul 2022 17:23:13 -0300 Message-Id: <20220704202315.507145-2-leobras@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220704202315.507145-1-leobras@redhat.com> References: <20220704202315.507145-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 --- 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..698c086b70 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) { + 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 4 20:23:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 12905821 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 46CDDC43334 for ; Mon, 4 Jul 2022 20:27:46 +0000 (UTC) Received: from localhost ([::1]:34786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8SfY-0001EL-Tr for qemu-devel@archiver.kernel.org; Mon, 04 Jul 2022 16:27:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbk-0005LV-13 for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbg-0004W6-Uq for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656966224; 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=N3mn6fl/G/32+BvijXaoxWngCqJnaEpKVDQ1U6JB3Z8=; b=V4bHmaUfi2PsGV1tPjIC70e0PBWzL4Rs1MxfBjFtEVY6bfTovKa0pvTlv1+M1EvNo2q3Mz Ielh0heDwGHdSXpsBp5pKXetjo/5pj4/4fgpWXlpPsFx3vW2vqn7MO+y8RF8/u2YGB4GPp mYX3wHgBkgqRLVZGNXu9xc4GCVWH/9I= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-FiTrYU6QOACGJyX1Xfc7lA-1; Mon, 04 Jul 2022 16:23:43 -0400 X-MC-Unique: FiTrYU6QOACGJyX1Xfc7lA-1 Received: by mail-qk1-f200.google.com with SMTP id bp10-20020a05620a458a00b006b265587a17so7770137qkb.2 for ; Mon, 04 Jul 2022 13:23: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=N3mn6fl/G/32+BvijXaoxWngCqJnaEpKVDQ1U6JB3Z8=; b=x+id7tZsJcFEbzVgkN2bQdCs1zLoRF4//wxdfhuGoMbpFvz0NuSj8j3C9mPASYggst JChgxaEjT6XYKFmF0XS75CW3nymizP5qX3fCLh9xxTdArszasEh/MHPeREzX7peiQx+/ IzFXIwKXK+2IFIEDjGo81wmBb4GtOZEIjtyGC+OFmr23n6XxDCwrXbHbuM7PFF6By6p9 4PZJJhhx3aHlJFOnlzchtUK/FatLRbmuKyt8HuDfu4JUp5St4C2nERavXoG4/vc9qxZg US9xcH0S9bzV+wjURNiVR0nCDHkGXrpXszMwUgoz+1ON+/SMuxrNj3BvyhsQ2LFA4zad zsKQ== X-Gm-Message-State: AJIora9o+FWkP1yzODLHcMIDvy1P47j4y0qj2vhVmK7FlLgLPXwHmUr5 CqVMPVokm6yhyOlshkNoYyzwFsUbOnaOAgImyiDuRw6YyokrDMSzpECvt7EZtxXiHhnOGPwF6kH 8ycDgGph6eZU750U= X-Received: by 2002:a05:620a:cda:b0:6a6:8e47:8901 with SMTP id b26-20020a05620a0cda00b006a68e478901mr20842480qkj.231.1656966222616; Mon, 04 Jul 2022 13:23:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tdzXsNZ9mFyIMxeiyPcPhx/R4gveMUCnp62gXCXDXzDeNhHQ4Jw/2biTSCEfOF33/zWUYuoA== X-Received: by 2002:a05:620a:cda:b0:6a6:8e47:8901 with SMTP id b26-20020a05620a0cda00b006a68e478901mr20842462qkj.231.1656966222248; Mon, 04 Jul 2022 13:23:42 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7ed:cb75:d392:178:9101:5763]) by smtp.gmail.com with ESMTPSA id k11-20020a05620a0b8b00b006b25570d1c2sm9180127qkh.12.2022.07.04.13.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 13:23:41 -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 v3 2/3] Add dirty-sync-missed-zero-copy migration stat Date: Mon, 4 Jul 2022 17:23:14 -0300 Message-Id: <20220704202315.507145-3-leobras@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220704202315.507145-1-leobras@redhat.com> References: <20220704202315.507145-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é --- qapi/migration.json | 7 ++++++- migration/migration.c | 2 ++ monitor/hmp-cmds.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 7102e474a6..fed08b9b88 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 zero 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..5f3be9e405 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -307,6 +307,10 @@ 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, "missed zero-copy on: %" PRIu64 " iterations\n", + info->ram->dirty_sync_missed_zero_copy); + } } if (info->has_disk) { From patchwork Mon Jul 4 20:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 12905822 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 60CD3C433EF for ; Mon, 4 Jul 2022 20:28:02 +0000 (UTC) Received: from localhost ([::1]:35054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8Sfp-0001QH-IV for qemu-devel@archiver.kernel.org; Mon, 04 Jul 2022 16:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbk-0005Nw-V1 for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Sbj-0004WN-CX for qemu-devel@nongnu.org; Mon, 04 Jul 2022 16:23:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656966226; 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=euVkicUTpPdXceL+38qNTa68fBMg2NyX6ZJ2vMqZGx0=; b=Ep1tiEN31A3xCAUyt/ZmXDGHoviqaeOsxbCMa+uoLaNp4mm5ijW9vtgdBxqPJxuATLHB23 qbBqu+f9Htd4JNiuLuZGJkAXjgaPhSpHYi3weMzdoRYvaqenrDTXjStKRYKRHb+H6WQlXz dgD+VWeO+Id19XUQ/IdJE8sztk7lw2I= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-VBIHVMLTN6Ol2yq7_sqrlA-1; Mon, 04 Jul 2022 16:23:45 -0400 X-MC-Unique: VBIHVMLTN6Ol2yq7_sqrlA-1 Received: by mail-qt1-f199.google.com with SMTP id n18-20020ac81e12000000b00318b16f53e0so7518288qtl.5 for ; Mon, 04 Jul 2022 13:23:45 -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=euVkicUTpPdXceL+38qNTa68fBMg2NyX6ZJ2vMqZGx0=; b=i3APtc64pCkgaA6fjBJ12WHks1QiCVk77gRQzKS/PRR/JxQgukcIqzpLkKP6XRexpy i34QW6zQGjfXDE1HvevuRlIw/ImS4ZdOyEHzvNPeszUXZvGtJRJeLFrdSzUX2/OTv8WF usYedF1GSi70Q2T+lMOTYv0M9KwupSTFFI/gxWkd6PvZoLmPrf1+xqAKGxhJjWR8U+O2 wcvlWhLhGRVTqr6l05JEjsIKjukf/de4Dw2mBHQZZh1SYZUu13i5QAF+oa4Om02oQrCo I5LefF25aLJNb9t7/uX3R4n9HYEbrZKj0UDGpNvpDtYkBf/fX/ifxCfeEjQszEUIoDx9 HjZQ== X-Gm-Message-State: AJIora/pqNhHgGvmPpFbd8psD76Le/mYyViEvmfHXNT3cHr7iH33/EEm jtLfeaYyXbbVCNUHWytIhA5vDegwCCzP3ZDoQW0+6Hx60hxCFHyRm4/kH/Xf8C+4EMaK6k/5SP4 6OiV5bZaqYPNN3ao= X-Received: by 2002:ac8:4b42:0:b0:31b:efb7:7e9c with SMTP id e2-20020ac84b42000000b0031befb77e9cmr25147243qts.566.1656966225299; Mon, 04 Jul 2022 13:23:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sA8p8Eiov8KiscSImT+xvwyvH52XO4s2WVAXTP4BevmPC+dZf89XO+HnKAgXfXhQTbIy7wRw== X-Received: by 2002:ac8:4b42:0:b0:31b:efb7:7e9c with SMTP id e2-20020ac84b42000000b0031befb77e9cmr25147232qts.566.1656966225109; Mon, 04 Jul 2022 13:23:45 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7ed:cb75:d392:178:9101:5763]) by smtp.gmail.com with ESMTPSA id k11-20020a05620a0b8b00b006b25570d1c2sm9180127qkh.12.2022.07.04.13.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 13:23:44 -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 v3 3/3] migration/multifd: Warn user when zerocopy not working Date: Mon, 4 Jul 2022 17:23:15 -0300 Message-Id: <20220704202315.507145-4-leobras@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220704202315.507145-1-leobras@redhat.com> References: <20220704202315.507145-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é --- 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 */