From nobody Mon Feb 9 22:38:51 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=1676278747; cv=none; d=zohomail.com; s=zohoarc; b=KnfMbrgU9JPFe9GAWVauhx+m4EC1k9Kla7lObsbhamhtH8063XZn7FSLu89Nrha71VClDykus/Ck8D8WmxzNCD0oiM+5s859YhknuRHl9OITapoJ8FdCvCEjQCwAR+CVNpJ3/R2XrU2YWbUXVANhY0UtnSS/rSrOuJn47dZmew0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676278747; 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=dYncBNyX9ejjkJVgkLkB4SbjJNFyAMt+RzxT66SCiauofE8FzUL96bp8bivEW0HDLclZQyWJU4M6jA9VyCDTEHCG/ecu2ZRIJPzGNsRYINyHoYCvHj7KSf2XYy4rn3kPKVkss+Nf9yD9PghiIv+MCwZJFLQMRAFCG9M7Q9VUiP4= 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 1676278747362619.532110785304; Mon, 13 Feb 2023 00:59:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRUew-0000PU-Bg; Mon, 13 Feb 2023 03:58:02 -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 1pRUev-0000PC-HI for qemu-devel@nongnu.org; Mon, 13 Feb 2023 03:58:01 -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 1pRUes-0002sn-Rd for qemu-devel@nongnu.org; Mon, 13 Feb 2023 03:58:01 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-119-eNDc7PJrNiy97BU9_JlOLg-1; Mon, 13 Feb 2023 03:57:54 -0500 Received: by mail-wr1-f71.google.com with SMTP id i9-20020a0560001ac900b002bfda39265aso2203228wry.13 for ; Mon, 13 Feb 2023 00:57:54 -0800 (PST) Received: from redhat.com ([46.136.252.173]) by smtp.gmail.com with ESMTPSA id k2-20020a5d6d42000000b002c4061a687bsm10113885wri.31.2023.02.13.00.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 00:57:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676278678; 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=Mz6YBv4uyKpBbJXSNrfJARer32RDwXRPDMMwhQPDy2goxyZjL294LYopDdOsRduwhyD5pM p3ZuG2sbVHLTB7UaYzMplzudx/nSUAFUeVG18o1jl/bYoEXeayoc1S3e4eEL0k/YHbOxl+ cX7n5Hzq6Xrmzm8EFLxb2fXvKWr/DOg= X-MC-Unique: eNDc7PJrNiy97BU9_JlOLg-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=LmvZGAAfSzw8E8IAnVQe0fgp0QYYgwekohqDNRPZk4E7psWWGVmUJFdIZZOLhhtrFz AQ9CL0XXIZRqKs4JoBbB1+JknZWhYrDSqTGuUWTHmjrVBOtyDf9u9wDI6EbTHwhMum4k zPQZlK4xqDPmQi+B5iFytblsMicaSzav4VLPYBfhLIKr/88O+L4bWiWwa87SbuC03/ji 4Bc7hXAUZfBoT4FJA8ye5x2hNnAWWnVrWguNrK1XUokZVGIPp4pIOkO/fOoy0kzHSr6R 2+5ugMOyHvIzaoyNVAKy3AfWy3hJ+dbtXUdy5shkEyoVTuNZw4vq12IPJiCDilZY99vT 1qcw== X-Gm-Message-State: AO0yUKUGlniRKecRLV1VZfJ/S48JA/YfFFFcScNKhoBG5C+taMUg8gRR PaLxcqHN6bCOHazPt0PVswRH1CH1qgStOeOlEo/KEo24rk18O3JXCvq9T52rF1QHgvfjLZo+eqd SwvQ+v282cUL1pJpDtXrKho7B3AQ+pJEa2qUOXEQCOcPJyKmd1oLJT04Ph75ZQKxrlj8sFPM/la 0= X-Received: by 2002:a5d:6707:0:b0:2c3:db5c:55c with SMTP id o7-20020a5d6707000000b002c3db5c055cmr18739918wru.2.1676278673341; Mon, 13 Feb 2023 00:57:53 -0800 (PST) X-Google-Smtp-Source: AK7set9UUbtPkftD5+GvCNFCySAjJDSckQUfbt9uZjuo/GTd7CY6vi3Kj8LIgQA4BDncOcNFLHQIEQ== X-Received: by 2002:a5d:6707:0:b0:2c3:db5c:55c with SMTP id o7-20020a5d6707000000b002c3db5c055cmr18739895wru.2.1676278673025; Mon, 13 Feb 2023 00:57:53 -0800 (PST) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Yanan Wang , "Dr. David Alan Gilbert" , Juan Quintela , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eric Blake , Markus Armbruster , Marcel Apfelbaum , Leonardo Bras , Li Xiaohui , Peter Xu Subject: [PATCH v5 3/8] migration/multifd: Join all multifd threads in order to avoid leaks Date: Mon, 13 Feb 2023 09:57:41 +0100 Message-Id: <20230213085746.75586-4-quintela@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213085746.75586-1-quintela@redhat.com> References: <20230213085746.75586-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.129.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: 1676278749387100003 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