From patchwork Fri Feb 10 06:36:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135419 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 15774C636CD for ; Fri, 10 Feb 2023 06:37:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQN1d-00007E-Qy; Fri, 10 Feb 2023 01:36:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1b-000071-Qc for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1Z-0008Oz-Ss for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676011004; 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; bh=SpJDOYOVmyUfceCLTAVLc5sGZEYkikb7PzS/WP4DK/k=; b=JNg1uoepBWjOQoqWh2vLUYa7T46DJpgoRgPr54qA/S3msgnmlAOWrJ8v4ZLC+/ECgdj7OH 1frFSQHcNqwcItYTALHFQcQ1OKsfVo1lZOCW8Ru1XJdO0KVPX1Ju1Q3gBgA/T4lHu5NgPu /7+NarsGlQs1etu8oAR19V79LuhlYQk= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-341-SCRNLl1LNASQ48qI3_orqQ-1; Fri, 10 Feb 2023 01:36:43 -0500 X-MC-Unique: SCRNLl1LNASQ48qI3_orqQ-1 Received: by mail-ot1-f72.google.com with SMTP id m47-20020a05683026ef00b0068bbc172013so1870081otu.12 for ; Thu, 09 Feb 2023 22:36:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SpJDOYOVmyUfceCLTAVLc5sGZEYkikb7PzS/WP4DK/k=; b=DaroD4RalqKOpsnLOeVx5iuuozHbd2+GtZ2FcYGbqoQinrrrbES+NW+A4ApHIYzk3y JPs4CVxQGoB/Y4dYRpS4uR3OZYiOVPgfiIMS6dnApxbDpSBRdGtLupjNv2fznzfh1fjw M6nVdKhjlT6q6k6ECn0r+g+lORBpJ128mRGbz087BRxXpv25TN3d66s1WbaksCqwkaWB TSuQhPQ7sPjlo0+LEHvRDEKgJ1LAdHbzN0kjbuxsq6kYanBdv4F6hEIjq5v8dfk2+8Bu /s9cKOAuWSN0/Vp2Ch5SB/dW2XpHHrZl0H0mR3hoYyOKj2IHxkX9WKM3vGe4qeZ4P71D UxKA== X-Gm-Message-State: AO0yUKW0Ncg1KnnmT+H6QKuCPws2PIUm9vQMF03hlZuB6Gk65sEzRRQC sVZjREt+xAnZ+FHgqMWpO8rEOaUp1I+uccQ7RSNVu+2xLXU9e+k7I5l0lF0Dn98k+o6j8bSwtJx 4Gz0iPk+1Nn0i2bw= X-Received: by 2002:a05:6808:aae:b0:360:d307:c23c with SMTP id r14-20020a0568080aae00b00360d307c23cmr813971oij.25.1676011002359; Thu, 09 Feb 2023 22:36:42 -0800 (PST) X-Google-Smtp-Source: AK7set/w/NSnxFIdP+CC7xY29XV9x46Cb+b9haZbQuYmgwJiEB/MU6HdmTSn2EZyTOFbjZzyvUQVnw== X-Received: by 2002:a05:6808:aae:b0:360:d307:c23c with SMTP id r14-20020a0568080aae00b00360d307c23cmr813963oij.25.1676011002000; Thu, 09 Feb 2023 22:36:42 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id d8-20020a05683018e800b00670679748f9sm1705285otf.49.2023.02.09.22.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:36:41 -0800 (PST) From: Leonardo Bras To: Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v1 1/4] migration/multifd: Change multifd_load_cleanup() signature and usage Date: Fri, 10 Feb 2023 03:36:28 -0300 Message-Id: <20230210063630.532185-1-leobras@redhat.com> X-Mailer: git-send-email 2.39.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since it's introduction in commit f986c3d256 ("migration: Create multifd migration threads"), multifd_load_cleanup() never returned any value different than 0, neither set up any error on errp. Even though, on process_incoming_migration_bh() an if clause uses it's return value to decide on setting autostart = false, which will never happen. In order to simplify the codebase, change multifd_load_cleanup() signature to 'void multifd_load_cleanup(void)', and for every usage remove error handling or decision made based on return value != 0. Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- migration/multifd.h | 2 +- migration/migration.c | 14 ++++---------- migration/multifd.c | 6 ++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index ff3aa2e2e9..9a7e1a8826 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -16,7 +16,7 @@ int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); int multifd_load_setup(Error **errp); -int multifd_load_cleanup(Error **errp); +void multifd_load_cleanup(void); bool multifd_recv_all_channels_created(void); void multifd_recv_new_channel(QIOChannel *ioc, Error **errp); void multifd_recv_sync_main(void); diff --git a/migration/migration.c b/migration/migration.c index 7a14aa98d8..ce962ea577 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -543,13 +543,7 @@ static void process_incoming_migration_bh(void *opaque) */ qemu_announce_self(&mis->announce_timer, migrate_announce_params()); - if (multifd_load_cleanup(&local_err) != 0) { - error_report_err(local_err); - autostart = false; - } - /* If global state section was not received or we are in running - state, we need to obey autostart. Any other state is set with - runstate_set. */ + multifd_load_cleanup(); dirty_bitmap_mig_before_vm_start(); @@ -649,9 +643,9 @@ fail: migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); qemu_fclose(mis->from_src_file); - if (multifd_load_cleanup(&local_err) != 0) { - error_report_err(local_err); - } + + multifd_load_cleanup(); + exit(EXIT_FAILURE); } diff --git a/migration/multifd.c b/migration/multifd.c index b7ad7002e0..174726982c 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1022,12 +1022,12 @@ static void multifd_recv_terminate_threads(Error *err) } } -int multifd_load_cleanup(Error **errp) +void multifd_load_cleanup(void) { int i; if (!migrate_use_multifd() || !migrate_multi_channels_is_allowed()) { - return 0; + return; } multifd_recv_terminate_threads(NULL); for (i = 0; i < migrate_multifd_channels(); i++) { @@ -1067,8 +1067,6 @@ int multifd_load_cleanup(Error **errp) multifd_recv_state->params = NULL; g_free(multifd_recv_state); multifd_recv_state = NULL; - - return 0; } void multifd_recv_sync_main(void) From patchwork Fri Feb 10 06:36:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135418 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 A7F01C636CD for ; Fri, 10 Feb 2023 06:37:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQN1h-00007z-EI; Fri, 10 Feb 2023 01:36:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1d-00007G-QC for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1c-0008PH-Db for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676011007; 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=9bV/z5jl1WDXfSp1c5JG+u1MzXkIYXzcWvCvitMlANY=; b=AWaVm+RLzj3NpmbDs0DxhG4lfXmkQZetj+FYmL8nuMz46vDNiJZfBlblsLZtMFmo2FAB+1 ElCCknrVkd+PfgWYGMeaBMeVwCvzFpqtFq0NaHQMFWZ94CybcPxVq3zqnnFrdt/zo/lxrO ifCWhpI5H0RRqocYq/YNq0OQU3knWCo= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-63-NJy80ixKNjmM6Up1XB-PqA-1; Fri, 10 Feb 2023 01:36:45 -0500 X-MC-Unique: NJy80ixKNjmM6Up1XB-PqA-1 Received: by mail-oo1-f71.google.com with SMTP id r21-20020a4a83d5000000b0051a1b4e72a5so1813367oog.4 for ; Thu, 09 Feb 2023 22:36:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9bV/z5jl1WDXfSp1c5JG+u1MzXkIYXzcWvCvitMlANY=; b=rOjc/0KWNogLrdzdM3mYSWnxMSIG43fWLU6oil3FECMGDMEXr4Pzg4gMaqUDZjSpBr LaQTMYtpoSL15tLX7rJw4DzaPbaTAkBXI6ejrFdz3XfA6KFoRrdB+b1CNPk9rYq84G3e 4vr9MLDsAeZTdPL7UEjuf5XbIg6MCBSpSefIJEMVvSANq/FKf2nBKk3hSNP3BmS4EuMl W6y14gBshXV6Rt0jxvs6Li+psa4G6PXqw0FfRZ2gW2NxzSdQztR+vj76WZ+rGDWrsWBz 9K5fGydeguUKJusVdHA+GLFpx9W6b2MKUFvh1ALe2w5NBSCLA7NYPe0YyCvVvrV7/zBp QwAA== X-Gm-Message-State: AO0yUKVhrE4ga2Yu251x3sf7itGmfGJ8PvPdxLSF1C54TzPQIeMGjL6k Ii1wKU0bPjp+Bk0cck3blE9upAQUPYnokIexBvqmF6QwvPW0YdP8KiSiHIUifh7AWJUUhT/JE1m DK++mgKBi2wh4xaC9HbGQ X-Received: by 2002:a05:6830:349e:b0:68b:d4ac:1ca0 with SMTP id c30-20020a056830349e00b0068bd4ac1ca0mr10053497otu.29.1676011004692; Thu, 09 Feb 2023 22:36:44 -0800 (PST) X-Google-Smtp-Source: AK7set8Ta0osLw6MggkHn+Q4WEZvk9QnWdvHrLmjFTgCRt4biQes9DnvVFuYHKxcPRvcZD5VLs1Q4A== X-Received: by 2002:a05:6830:349e:b0:68b:d4ac:1ca0 with SMTP id c30-20020a056830349e00b0068bd4ac1ca0mr10053479otu.29.1676011004408; Thu, 09 Feb 2023 22:36:44 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id d8-20020a05683018e800b00670679748f9sm1705285otf.49.2023.02.09.22.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:36:43 -0800 (PST) From: Leonardo Bras To: Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v1 2/4] migration/multifd: Remove unnecessary assignment on multifd_load_cleanup() Date: Fri, 10 Feb 2023 03:36:29 -0300 Message-Id: <20230210063630.532185-2-leobras@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063630.532185-1-leobras@redhat.com> References: <20230210063630.532185-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Before assigning "p->quit = true" for every multifd channel, multifd_load_cleanup() will call multifd_recv_terminate_threads() which already does the same assignment, while protected by a mutex. So there is no point doing the same assignment again. Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- migration/multifd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 174726982c..1a445b36f1 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1034,7 +1034,6 @@ void multifd_load_cleanup(void) MultiFDRecvParams *p = &multifd_recv_state->params[i]; if (p->running) { - p->quit = true; /* * multifd_recv_thread may hung at MULTIFD_FLAG_SYNC handle code, * however try to wakeup it without harm in cleanup phase. From patchwork Fri Feb 10 06:36:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135417 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 7308BC05027 for ; Fri, 10 Feb 2023 06:37:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQN1l-00008c-3j; Fri, 10 Feb 2023 01:36:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1f-00007n-KN for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1e-0008PX-7S for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676011009; 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=xOojtREP1MzNlGpZt0CnT4fjGRQk/mcDIz9qijD/FCs=; b=cQM7yXu0iX+mHzGVsrtlm1HqacPVTTmp7pIhZukpssZZfpCHxb/Fdw5VpgDBwvw9qYc5zM IxtoCmdE/e7jrO1Wawc0HsPZQy6Wo1K4iCIYFYqDG7zBEpZKqfjJb2I+OKzP08P1LExSrM Mp6wJa7D+PqIVAm61lU5Uc5ES9JBGYE= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-648-tySgreBjPt6BgA5lS87LfA-1; Fri, 10 Feb 2023 01:36:48 -0500 X-MC-Unique: tySgreBjPt6BgA5lS87LfA-1 Received: by mail-oi1-f197.google.com with SMTP id q14-20020a056808200e00b0037ab5869804so1266667oiw.22 for ; Thu, 09 Feb 2023 22:36:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xOojtREP1MzNlGpZt0CnT4fjGRQk/mcDIz9qijD/FCs=; b=1W12gm/9xZRcdMXEfVZ/tnLaqu3rgqE0MFH1UUa9yN8GxitEvSy/h0VYzPEqAWEGBN 46QdUaxFBX7ru+8CDFVtHs9FeJZrJYtnjnzge+7A7s3uejdUj9ZS2jw9Xw5IQlf1gEEE NLyWr7gdUnLlTixqM57nbPkOP2kQrXQ6ramxtBd6HOaqVxzP9voP3eo/DuhiG/EuJJ4t dSsxB+gqYwSjyllANm95c37eUzEndDi4HNtsf93oxqTSfQbCiOrJr15kvKJBzsHLv+xG wpgN8VzVxT0n+9CGwYllMCpbVUo8FPegcQo85itAF6M4JAeSTM+0vNVHVD8k/iHjUuoS MuGw== X-Gm-Message-State: AO0yUKUNnCDgGKoyZS8Ab/JyX0/T+laP0dGVJPxoZsKSIW61KkjDmE3h LWNzfincilMeKBAvdVot5YJD4oQ2Kb6ium9OfyTxl4JeZusxXPmxTDnyugU///BQiaLblmBdvJ1 jSX02LOMOJRRTS+s= X-Received: by 2002:a9d:6642:0:b0:68b:d9d3:d8f with SMTP id q2-20020a9d6642000000b0068bd9d30d8fmr7983353otm.3.1676011007192; Thu, 09 Feb 2023 22:36:47 -0800 (PST) X-Google-Smtp-Source: AK7set8HDSL+yFvnSNkQERxTRJPMUeVvsHjdOXcwS7vc4UUbvwtIqwP6YQ14UA08ks3+KKde8fEj2g== X-Received: by 2002:a9d:6642:0:b0:68b:d9d3:d8f with SMTP id q2-20020a9d6642000000b0068bd9d30d8fmr7983348otm.3.1676011006951; Thu, 09 Feb 2023 22:36:46 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id d8-20020a05683018e800b00670679748f9sm1705285otf.49.2023.02.09.22.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:36:46 -0800 (PST) From: Leonardo Bras To: Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v1 3/4] migration/multifd: Join all multifd threads in order to avoid leaks Date: Fri, 10 Feb 2023 03:36:30 -0300 Message-Id: <20230210063630.532185-3-leobras@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063630.532185-1-leobras@redhat.com> References: <20230210063630.532185-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Current approach will only join threads that are still running. For the threads not joined, resources or private memory are always kept in the process space and never reclaimed before process end, and this risks serious memory leaks. This should usually not represent a big problem, since multifd migration is usually just ran at most a few times, and after it succeeds there is not much to be done before exiting the process. Yet still, it should not hurt performance to join all of them. Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- migration/multifd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 1a445b36f1..7e37a459ed 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1039,8 +1039,9 @@ void multifd_load_cleanup(void) * however try to wakeup it without harm in cleanup phase. */ qemu_sem_post(&p->sem_sync); - qemu_thread_join(&p->thread); } + + qemu_thread_join(&p->thread); } for (i = 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p = &multifd_recv_state->params[i]; From patchwork Fri Feb 10 06:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135420 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 CADE1C636CD for ; Fri, 10 Feb 2023 06:37:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQN1n-00008z-30; Fri, 10 Feb 2023 01:36:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1i-00008M-MW for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQN1h-0008R4-4N for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:36:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676011012; 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=5UwJ9b39de3kWLNGDPpuJ2S7kcq/Gr53SpasXFfxTJA=; b=jU+sTCRded7ZXWFu7qc0vrVrdlzc83vbXoLytkiQXzAIlmXZFMDD4ZIc3k+ujOpJO4UGGo 609kDPq2S40Q0U0SwDxGUYhHjXQCFeZUi1hgNaIo2CY2inl8+pqYMUOJdjPwTNp05NDjWQ 9gppwbumKecRaqJRjRNwzFOH+m3h7hs= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-375-4OxZW_KjMCebqu5-Wxhfbg-1; Fri, 10 Feb 2023 01:36:50 -0500 X-MC-Unique: 4OxZW_KjMCebqu5-Wxhfbg-1 Received: by mail-oo1-f71.google.com with SMTP id r21-20020a4a83d5000000b0051a1b4e72a5so1813434oog.4 for ; Thu, 09 Feb 2023 22:36:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5UwJ9b39de3kWLNGDPpuJ2S7kcq/Gr53SpasXFfxTJA=; b=ymtD400wJOO06FpIAvN28ViRFd5H7PKsrmZ6QKHm0uihHNr9ZdJFD22VMtdefQwjaP obaQsmXem6F6zhZhibX505unIF5OwBw3jWesA/TCsKWN5KW8bw1ujHX2pqy5mUHsY6iG I8d6tOFEwmMkynpo2Ai8YfhULaqI3wseBP+1nHXPAvHoBTLGeRlQEkt8c6QIeer1es0o zYhiouAca9eN8Wmw6Q+vR8dEammStATcXTY8vB2TE6j3L/CA9C8QPphcgYDviidG3lZY Xcf3qnYl3QoR4rVWMVptRDLgIJEpPdGJtnxtZoHJ8WyO7VMdHkqw6GZX7wn2dYpMLR3s 76Tg== X-Gm-Message-State: AO0yUKWBglIhiKKFSIMCEL9P1rSGtDBZW1JXsb/E2TRJuIa5dB3Ka0kL ihrDYENwZPeKnqpuSpHdXJrxiryOHlhAEl5rSAJxsdYvwHYVDeO+qJe75mmQRHe/X6TJuOSPB3a OR6PncG28AvCjXMw= X-Received: by 2002:a9d:4797:0:b0:68d:a0e5:d31f with SMTP id b23-20020a9d4797000000b0068da0e5d31fmr7648534otf.3.1676011009603; Thu, 09 Feb 2023 22:36:49 -0800 (PST) X-Google-Smtp-Source: AK7set92UP0XPpmJlT2QJEOtU1HHmgtxLkDDrXQYhtAnndKiXHRwLnWjgxb+QN/aK3Z/3zhDHr29gA== X-Received: by 2002:a9d:4797:0:b0:68d:a0e5:d31f with SMTP id b23-20020a9d4797000000b0068da0e5d31fmr7648528otf.3.1676011009357; Thu, 09 Feb 2023 22:36:49 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id d8-20020a05683018e800b00670679748f9sm1705285otf.49.2023.02.09.22.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:36:48 -0800 (PST) From: Leonardo Bras To: Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu Cc: Leonardo Bras , qemu-devel@nongnu.org Subject: [PATCH v1 4/4] migration/multifd: Move load_cleanup inside incoming_state_destroy Date: Fri, 10 Feb 2023 03:36:31 -0300 Message-Id: <20230210063630.532185-4-leobras@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063630.532185-1-leobras@redhat.com> References: <20230210063630.532185-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Currently running migration_incoming_state_destroy() without first running multifd_load_cleanup() will cause a yank error: qemu-system-x86_64: ../util/yank.c:107: yank_unregister_instance: Assertion `QLIST_EMPTY(&entry->yankfns)' failed. (core dumped) The above error happens in the target host, when multifd is being used for precopy, and then postcopy is triggered and the migration finishes. This will crash the VM in the target host. To avoid that, move multifd_load_cleanup() inside migration_incoming_state_destroy(), so that the load cleanup becomes part of the incoming state destroying process. Running multifd_load_cleanup() twice can become an issue, though, but the only scenario it could be ran twice is on process_incoming_migration_bh(). So removing this extra call is necessary. On the other hand, this multifd_load_cleanup() call happens way before the migration_incoming_state_destroy() and having this happening before dirty_bitmap_mig_before_vm_start() and vm_start() may be a need. So introduce a new function multifd_load_shutdown() that will mainly stop all multifd threads and close their QIOChannels. Then use this function instead of multifd_load_cleanup() to make sure nothing else is received before dirty_bitmap_mig_before_vm_start(). Signed-off-by: Leonardo Bras Reported-by: Li Xiaohui Reviewed-by: Juan Quintela --- migration/multifd.h | 1 + migration/migration.c | 4 +++- migration/multifd.c | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/migration/multifd.h b/migration/multifd.h index 9a7e1a8826..7cfc265148 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -17,6 +17,7 @@ int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); int multifd_load_setup(Error **errp); void multifd_load_cleanup(void); +void multifd_load_shutdown(void); bool multifd_recv_all_channels_created(void); void multifd_recv_new_channel(QIOChannel *ioc, Error **errp); void multifd_recv_sync_main(void); diff --git a/migration/migration.c b/migration/migration.c index ce962ea577..9f69447320 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -302,6 +302,8 @@ void migration_incoming_state_destroy(void) { struct MigrationIncomingState *mis = migration_incoming_get_current(); + multifd_load_cleanup(); + if (mis->to_src_file) { /* Tell source that we are done */ migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) != 0); @@ -543,7 +545,7 @@ static void process_incoming_migration_bh(void *opaque) */ qemu_announce_self(&mis->announce_timer, migrate_announce_params()); - multifd_load_cleanup(); + multifd_load_shutdown(); dirty_bitmap_mig_before_vm_start(); diff --git a/migration/multifd.c b/migration/multifd.c index 7e37a459ed..9302c9f6cf 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1022,6 +1022,13 @@ static void multifd_recv_terminate_threads(Error *err) } } +void multifd_load_shutdown(void) +{ + if (migrate_use_multifd() && migrate_multi_channels_is_allowed()) { + multifd_recv_terminate_threads(NULL); + } +} + void multifd_load_cleanup(void) { int i;