From patchwork Fri Feb 10 06:31:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135413 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 CCA8DC636CD for ; Fri, 10 Feb 2023 06:32:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQMx6-00056t-6N; Fri, 10 Feb 2023 01:32:08 -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 1pQMx4-00056Y-8c for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:06 -0500 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQMx2-0007g5-C4 for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:05 -0500 Received: by mail-oi1-x22d.google.com with SMTP id n132so3684081oih.7 for ; Thu, 09 Feb 2023 22:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2OC0+N8bmkMf5K9Lhs0x8cPe/2V5a2HvI4ivvTW8fNQ=; b=n597P01IaHyqihMvnik1HEsUlM0SUZbZm8N5pEs0Bk7U/VHMpZB2qtSjH0EAyTKS85 aQbytKjU5a9dFfdhSwR64BF6822y5foMLJaE/TbKNYSWh5FbYNg1u0xokn7pZvXKG66X LhyZteZTEtosdjGN9rQ0WSrOGpF4ierSUGbZZBYcuzc0uMd58xx0oGWrapfbUBFocAzI nkDiJXMTjEQ+DkWKODx9QIkkN9AxM4PFEHrReNIISNrixUXWH4CdZ2G0AS4JSreK3a/p hmKeIu0vCLkHaTQDgzZuTf5kO9L+/KvwaZpgSfzmkvCqRrTIVLnz18mJYRmlJLZ25d11 T1gg== 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=2OC0+N8bmkMf5K9Lhs0x8cPe/2V5a2HvI4ivvTW8fNQ=; b=nnn5goKlg0jPntMmZUFrSHK56/4sI/nAJxm6N37h7qArz4ln8gd0jw1AkvktMH0/su bKpG2Hz/o9X6XB9Em0JjaDinI/CX+0Wh/2NYnHE46SGW/ApI37D8tTe995OeGgwQStfO iab03tdAXvLB31TQ5R1nQmKTMmfg+pP19i+i/VOvPSW80g6GcN7+DuhHAoqq70dmF1zO +7t91GjIEjSm7ODHBpgs5PZYuzFWXSZokhdDXxdq9ux2++bV/u9Mt/VjUgl16eVw6gIj KtTZbY0rh75Dpf7GaIMIA6fkQFlwiFC6yo50kdBa6oW7jP0m1fNHcc3PC4g18oZr9cHi e4uQ== X-Gm-Message-State: AO0yUKVYE1PrzeKqay95HLM+4iglHlxyqG9N63d1FMROILErY2305pRl cm/ZTDE93yq+P6oZVWbct3s= X-Google-Smtp-Source: AK7set8xYPA4UEnWre4Tc1FzVOF+TO81RZetBAA2crW4cshUrFUDVVjy3QEJ6iAGpPgjmq8ELqbVmw== X-Received: by 2002:a05:6808:3cf:b0:36e:bb55:d51a with SMTP id o15-20020a05680803cf00b0036ebb55d51amr6522550oie.52.1676010722617; Thu, 09 Feb 2023 22:32:02 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id h18-20020a9d6a52000000b00688449397d3sm1686285otn.15.2023.02.09.22.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:32:02 -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:31:42 -0300 Message-Id: <20230210063145.530952-1-leobras.c@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=leobras.c@gmail.com; helo=mail-oi1-x22d.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 --- 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:31:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135415 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 7EDF4C05027 for ; Fri, 10 Feb 2023 06:32:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQMx8-00057l-Pg; Fri, 10 Feb 2023 01:32:10 -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 1pQMx6-00056u-C1 for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:08 -0500 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQMx4-0007gD-LI for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:07 -0500 Received: by mail-ot1-x329.google.com with SMTP id bv2-20020a0568300d8200b0068dc615ee44so1274290otb.10 for ; Thu, 09 Feb 2023 22:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b0JhpVPOTJNunW/+RFyMjuxpZq9yWKqBvO16ePPxhWc=; b=XeXVMLFl/DFm1/l89eR+Uq12dUEsUWTsxCgOMFt7M1xr5ofJ7GcP8TbJAjZZY/witF k7S3mSFUCAC/d7USas5mSxf3jCaq2CNQeER2uNArWeYYfeAWT7ivGRJ4pdfxLxLfIxIF PsZJpdw5kdZOKr6DfOLgy7DzigOtOcnQRhHbC0MwuWb38yibN6T0oSN/zqio33asQvHY JLnoR7QdLx5i3y5GPbJfbS77JbemxR9y2mH+R/MKUR/gwFuXA5Kdx4mXZV8upkYiPxtW BMyAHVHQD3LN7PN1XZhxaDJ/hWK2rXzY3gVPetnAduoYWCnwwHQE2MxTucjUp7Kh8iRu NDug== 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=b0JhpVPOTJNunW/+RFyMjuxpZq9yWKqBvO16ePPxhWc=; b=0sZMSXVYiZKntIUwv5CO/GxZ/82oHBzW93/LzGaXZ8uFwejY1BkDu4iELnT2nvL6ro 6OQ8gNaAg9ijAGFwBgHKV2K+lbCl/gvHvJ4+Px/jFlIaEL50eoAYF/fNP649zQwitpiO XIZGWT8ZlvHjavpMz1/zJHmC0deYKGFSxtvGt/ZI+miLWreUDrg971UrFyRlDRmkJhtY 4MXVia3JHjGudx8AbUZ5x2oAI6IDwmaozjst4o/A7nIz1RZVfpKVCG/NMwnW+0eaHe01 OqCHVVtHu+neFVHRHkrGeINY76V05/QbYjdxYp/fC63IHfemv/o54pTruGiEkrmgI263 uVAA== X-Gm-Message-State: AO0yUKWiQnO1ZPw1XE2dKUd0BEwiSDhIMrZq01a8ZDrXaGbq8rtf4BmD OTcsvnCi+pQPUPlGSmMyWZc= X-Google-Smtp-Source: AK7set/UUa3NmF+czS02gsUIk+R1uf1Uz6g7mU+Uc8kmoiULGyxlyrsyZRdpfl0UeoCUgoFwaLFNLw== X-Received: by 2002:a05:6830:923:b0:684:d3d1:6df8 with SMTP id v35-20020a056830092300b00684d3d16df8mr10548377ott.29.1676010725111; Thu, 09 Feb 2023 22:32:05 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id h18-20020a9d6a52000000b00688449397d3sm1686285otn.15.2023.02.09.22.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:32:04 -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:31:43 -0300 Message-Id: <20230210063145.530952-2-leobras.c@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063145.530952-1-leobras.c@gmail.com> References: <20230210063145.530952-1-leobras.c@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=leobras.c@gmail.com; helo=mail-ot1-x329.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 --- 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:31:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135416 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 9527EC05027 for ; Fri, 10 Feb 2023 06:33:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQMxA-00058F-EQ; Fri, 10 Feb 2023 01:32:12 -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 1pQMx8-00057k-Ls for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:10 -0500 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQMx7-0007gR-0F for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:10 -0500 Received: by mail-ot1-x32a.google.com with SMTP id g15-20020a9d6b0f000000b0068db1940216so1285391otp.5 for ; Thu, 09 Feb 2023 22:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LVKjVnaIscpJ3VchybK9zAWnObdNbO6GM/i6OX7DY8E=; b=DWlRUyZUeDFI+QrwqjQ0ow3GgdafvHr9s6Lk9+rmPZe3EL3Qn0cEV+Xd5ePjiYHEpQ xbWxH1PayDw76xyIa9bnIJs5deaXQSVm/dwqJpEPIrAW3HmJuIS7EHtHf8Wpdg8H4jPb N9pECzVQFwSaxRB+TPMmstG0923r3trWMUHpQclzXHaVdc3vf45vIghqfxdqV9fR7fPn B+XVcGXPuNfDk7QIOQlS0AOttPB7q18LeRm2xdHHjS8gNb0M6fa1AFC1MWgPKsb4LKv4 Os49T/nz2oCDqBR+pMV/NfQfNvyg/tf4iOUHTLwrLe+pNZsXQhiKFDDJjSqZLlq3wUYl vOxA== 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=LVKjVnaIscpJ3VchybK9zAWnObdNbO6GM/i6OX7DY8E=; b=VRwmamv92Mt/zSTTmAd5bPHKilL4mK/H4brq04EtRJF+wiETCiRpmpZ8eiJaRquoHy KAYQnrhzam7Gh5hTWW75nBobdT6zX4RhiZWmJW2mwcgDUtkC3ww554474qwcDYpak5NI oUpzWhyA89NSeg+Zez7hcGdFXPYgyG8mZ81p/wcdTBOjmeJvkRF6PEmnxZnri2Vl/77X EQzLu37r1sowvSYQk2OBIeHvmjqvH9ytK4DKdKvkEXqCkgGu5XQZG7SaZDtpSYdNfq/R u8L6I8lGGxhl0TONyWkqSBtO+jj3Dhv3CfoZOEECyyTPoR8bKkMopKo1F1jGeSfLyiQx gsHg== X-Gm-Message-State: AO0yUKVZ7qioLGrxK9ITsjmP7+Lp2DugZRV7UzzjYHRXXRhAoTT/GrXX WifXqT3fHtkdEnLDewD1nWo= X-Google-Smtp-Source: AK7set/uHMzvCETM2zhGNx+83Yf0cQc+QInTsqRto28+Epv9/hcAQCPWWLxXiGFEj64SeYij90E22Q== X-Received: by 2002:a9d:734c:0:b0:68b:daba:9b2b with SMTP id l12-20020a9d734c000000b0068bdaba9b2bmr7227397otk.13.1676010727534; Thu, 09 Feb 2023 22:32:07 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id h18-20020a9d6a52000000b00688449397d3sm1686285otn.15.2023.02.09.22.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:32:07 -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:31:44 -0300 Message-Id: <20230210063145.530952-3-leobras.c@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063145.530952-1-leobras.c@gmail.com> References: <20230210063145.530952-1-leobras.c@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32a; envelope-from=leobras.c@gmail.com; helo=mail-ot1-x32a.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 --- 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:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13135414 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 980CFC05027 for ; Fri, 10 Feb 2023 06:32:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQMxB-00058V-OS; Fri, 10 Feb 2023 01:32:13 -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 1pQMxA-00058H-Pm for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:12 -0500 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQMx9-0007go-0m for qemu-devel@nongnu.org; Fri, 10 Feb 2023 01:32:12 -0500 Received: by mail-ot1-x332.google.com with SMTP id e12-20020a0568301e4c00b0068bc93e7e34so1284872otj.4 for ; Thu, 09 Feb 2023 22:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mXEp5jWBg4NiAYsAQR30zI95FNc3mrLr6WgCN46h/78=; b=YhobdxKQs/yyvcWhJrjjme6xD2zCnHikhySoRJ9gtuqgjuWQ5NLY/zE/mMl72wKjMX Fl4STzqg1pzGZtGy8Eb0yO2stPAwFBgdnzXuJPmx0quQ5jWU5Zr4agVuBHfoVi/Jr6OB 4TsxUGZBy7rF3u3p29GzboI9IfsbVh/IWznl8G44rMdEb2TX9VuCH7yMe8kIUEhw+vgT aLU2eDjFunEb80SwV3r48Lou1LNE5i8csGbZtWHxGDdoUzrEmZf6Lbuor7OORpzbDPtw LEmn88tEqABhw4hMfL0kfelr3mujqmuWEKgTh8jJxChoxUGuuWBEuKr2sWdmGfUEmIxR cNGA== 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=mXEp5jWBg4NiAYsAQR30zI95FNc3mrLr6WgCN46h/78=; b=PbjvYWjsxFBF53HOp4lzXHjjsP6fwFfz8y3cHtSzpGkTffpipCiISKZclQQyzWwzmJ Nzjt2wkdVa3wPovUM+S+0Jx8oiKSqzy4GeTUvUykpHiEaJOpLJfXCpuh12zyahzZ7bQD UHcG/NEb10md22Y0eJaziIpr3Jzb+1EbOqLVyjez0klx3LeWpJqtkVbzpTZu8CHBFpvq 3+FLQbBc88kHSzK7XKJdehsgCLx+rhBRst44w8eokYDgT9ycAOeAxVUVnwJcHofrRSbV RylDrCUoaNMjXPdZztRK/xRodt0yY8NsJDe9m0up7OOh58A/VWlI9f9LUERpM4vwbN86 Q4Xg== X-Gm-Message-State: AO0yUKVHrVWpOyPuj3Y9hf22FKAbe+QLnRrfOuBD8wi4wd53KofApe4k yb9p2Bb9cMx8JYBUHNFdiMR8aOwEm+8= X-Google-Smtp-Source: AK7set9b0GSrCeSUddSCpjoh5mps/6pDUqzA3AgP4/uYxxuKLJLT68PFmzQ9OD4cMfKNSyad35j5mQ== X-Received: by 2002:a9d:7654:0:b0:68d:72c8:10a9 with SMTP id o20-20020a9d7654000000b0068d72c810a9mr7885023otl.9.1676010729969; Thu, 09 Feb 2023 22:32:09 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:9aa9:fdcb:7dec:9680:8417]) by smtp.gmail.com with ESMTPSA id h18-20020a9d6a52000000b00688449397d3sm1686285otn.15.2023.02.09.22.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 22:32:09 -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:31:45 -0300 Message-Id: <20230210063145.530952-4-leobras.c@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210063145.530952-1-leobras.c@gmail.com> References: <20230210063145.530952-1-leobras.c@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=leobras.c@gmail.com; helo=mail-ot1-x332.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 --- 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;