From nobody Tue Feb 10 04:55:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676256829; cv=none; d=zohomail.com; s=zohoarc; b=Jp+6rueOxDO5dtxdtN8M6KB7w7/orvYhTNsNqLy/QYyZ5Qqg4MK+81hbXdUE0WCmLZXVJbiBu1OnD8rYq4+eqRcpZANw4+ybNWnAN7uOxmJ8bUBaUfLNL+TbNktw/X3avgZHvQ7e7z5/5h2nDNx7pWN3ELJxf+n+YgANERIvqXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676256829; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aku3Smvsd7foub2ZcjYodstE9WWFFvGfDbRG9BvKPnM=; b=YpkbMhqCaU6eitO03zRoD24RhTjvZQicpcuEaRED4nxcZ4dz8Sb0Ks6qKXNLe+FL5KVF1KmfYqU4ujZbJRaHTmmkvudv9ugncLzQrzlrAzB26/SDd0xPWmvLQwmzK8iMU+kosrs5G5aysReYTZEGGqEmQNmiwzvehh4a5fmQ0/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167625682959126.912996347143576; Sun, 12 Feb 2023 18:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pROxE-0002Hm-9L; Sun, 12 Feb 2023 21:52:32 -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 1pROxD-0002H3-JW for qemu-devel@nongnu.org; Sun, 12 Feb 2023 21:52:31 -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 1pROxC-0006wU-5u for qemu-devel@nongnu.org; Sun, 12 Feb 2023 21:52:31 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-478-aFAZzmkNMmaKJE6tWKg7nA-1; Sun, 12 Feb 2023 21:52:28 -0500 Received: by mail-wm1-f70.google.com with SMTP id fl9-20020a05600c0b8900b003dfe4bae099so6075832wmb.0 for ; Sun, 12 Feb 2023 18:52:28 -0800 (PST) Received: from redhat.com ([46.136.252.173]) by smtp.gmail.com with ESMTPSA id k21-20020a05600c1c9500b003dd1c45a7b0sm13099849wms.23.2023.02.12.18.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 18:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676256749; 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=aku3Smvsd7foub2ZcjYodstE9WWFFvGfDbRG9BvKPnM=; b=VJ1eXcyL/QEKiI4IAviGrkNbvKJ9DLSFs3hQcZnomTdGxxwmus4Td00ceqcNljRd7LAdqP PCwECCLK/GxUVwDQYji/1sMDY85OVacOEJNmqH9gvUrAIgHDgMBPlHwONxgpxAbYH8VyxT EoeIxjkp6SThD8GVRP7xzjy6wSir5pw= X-MC-Unique: aFAZzmkNMmaKJE6tWKg7nA-1 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=aku3Smvsd7foub2ZcjYodstE9WWFFvGfDbRG9BvKPnM=; b=PUvIzJIBRDLVjIyjpIGcuxwUig10NkJarKPKX7TfeR5FbppaHtyQlHmJ9saUU3gYn4 XnsuXSvpXgysgZE+OH0IAoPIa+E7yX8YYeHK2lLKYXnMFO3/XCMj5M+d8lKDHMFmmSOH dxuYr3GmyE3EYb5DhpCFjgOseGjKfkri+6mlRf9VAEa9RcGiSu9zscv2xQpzbYFlkwma NdV63IMFhdMIwqKTZwk2gxMXP9H66GYMWa9cTffbRA2/EPF4G80MtGvViNjpESopIkOP wP8iua/RjpKjJmle6OUifHb5WuVRpcsbk+YVQdZtoKyAJMDzYYonuvYK7a2mxFTY2cqp dmIQ== X-Gm-Message-State: AO0yUKXiJb/sY25d29HhZer2Mn/C3O1q/RtMndee4bTwSi4hSWBa+VE6 FU6JfipLvJHwf9p0ZW8GNHUx9JSaSddu/BHzQIXpO7d61O7aeQMi+3bbpZhCunpdLI9KDIpB60E 2B/lV9dgTfwhTgAsTh6aYcvCuG9kSTK2ekdIrcyOkHvh70JW6TFeWmhezbgSWeua57tFU+gTK X-Received: by 2002:a1c:545e:0:b0:3df:9858:c03f with SMTP id p30-20020a1c545e000000b003df9858c03fmr4483883wmi.20.1676256746908; Sun, 12 Feb 2023 18:52:26 -0800 (PST) X-Google-Smtp-Source: AK7set+S3+gDNfnn+jOTzy9l1YpKX33WuB9LJ3aeiZkM4Qf3sBxd+W06a96lPgLIX4LtF7uwJNMqAQ== X-Received: by 2002:a1c:545e:0:b0:3df:9858:c03f with SMTP id p30-20020a1c545e000000b003df9858c03fmr4483863wmi.20.1676256746658; Sun, 12 Feb 2023 18:52:26 -0800 (PST) From: Juan Quintela To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Cornelia Huck , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , kvm@vger.kernel.org, "Michael S. Tsirkin" , Leonardo Bras , Li Xiaohui , Peter Xu Subject: [PULL 20/22] migration/multifd: Join all multifd threads in order to avoid leaks Date: Mon, 13 Feb 2023 03:51:48 +0100 Message-Id: <20230213025150.71537-21-quintela@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213025150.71537-1-quintela@redhat.com> References: <20230213025150.71537-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676256831163100003 Content-Type: text/plain; charset="utf-8" From: Leonardo Bras 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. Fixes: b5eea99ec2 ("migration: Add yank feature") Reported-by: Li Xiaohui Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Juan Quintela --- migration/multifd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 3dd569d0c9..840d5814e4 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1030,8 +1030,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 =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; --=20 2.39.1