From nobody Mon Feb 9 16:34:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517860771392363.62791582974126; Mon, 5 Feb 2018 11:59:31 -0800 (PST) Received: from localhost ([::1]:54980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimvH-0006uc-CH for importer@patchew.org; Mon, 05 Feb 2018 14:59:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSb-0004no-0B for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSZ-000586-83 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSZ-00057w-0U for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:47 -0500 Received: by mail-wr0-x242.google.com with SMTP id i56so30829121wra.7 for ; Mon, 05 Feb 2018 11:29:46 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=x5MYHsc7NtHgb7srTO4LKsshNaqbEndMQs6j3A3SvY8=; b=EeXuhem/l40tZysXtCE6Syu0Z84IaA01GqhnWXWbNn6ByGWEKWEmWkhg13qzt3ySwf TR3p5y+pEady1Dquiz6Zsro1fMdGHk6txTt69LH0QQaSjRFc0+Lvr2WOvQJsqz8j3kMx jBRsK/NFW+xdqC6E1ioIG8huOri++Ji2uoGtN88w+QvfckhMCZozOATSg94nzuZAnwy+ NK0xnywEa6OCVcfb6eCKBScpjVgAiNWQL8q/zasbWA+4j8iwyilUR0CvfhuO7vGinPLB LHBoD4vmhpzgqTPjxRL0gfovyVsTMenkQaQTLbdzeg1ffy6oCftA/Y/X+vFuLX/LKquD Cblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=x5MYHsc7NtHgb7srTO4LKsshNaqbEndMQs6j3A3SvY8=; b=F/+hOreRWB3nvAZrtex+67P+/SEpfH4Y48vx5wNOLDoopzurQ7NqjZVukkDenDXo0E iJ32IMCTRXwMHDJtZWhH6hkZ9x3UAOgmuT595FFBIMAr5/idESLQGIhQSegzSaKECyov 7z6pILlFN6+nnS+dSf6yPFRCrgQUvAZFnQ4vboBwBWps00zUodvce2DknitHrDLU2Q9C HnQeXra3hDYF47O823VgWmvB3aIPQrQ4ayMFiRLTHVXqoyAfiIz6aRXHo9v2tRfkv0Sr sG8yiYgceTfzFFP1X4xDwMKrqwbNNJmg4Ylp/P2DLHd5JRL1zUWDOGaf+BBgv/8Naq6F 4Qgw== X-Gm-Message-State: AKwxytdjwM4+e2I8pVhBYc8k4i3vkqBypARJo0YFLeS7YRmuC3hi0+l8 hXo+muG86haISEzPWplROnrUgCDz X-Google-Smtp-Source: AH8x226bcHOCTSv1fonGuVqL4Q9QMiR8QZWWx4sJosG2g3LwaNU4kxhv36JlG6raxybL4B2ot6fZfg== X-Received: by 10.223.176.174 with SMTP id i43mr29130937wra.77.1517858985653; Mon, 05 Feb 2018 11:29:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:49 +0100 Message-Id: <1517858941-5538-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 35/47] cpus: join thread when removing a vCPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If no one joins the thread, its associated memory is leaked. Reported-by: CheneyLin Signed-off-by: Paolo Bonzini --- cpus.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cpus.c b/cpus.c index fe127ac..8d8bb7c 100644 --- a/cpus.c +++ b/cpus.c @@ -1752,19 +1752,14 @@ void resume_all_vcpus(void) } } =20 -void cpu_remove(CPUState *cpu) +void cpu_remove_sync(CPUState *cpu) { cpu->stop =3D true; cpu->unplug =3D true; qemu_cpu_kick(cpu); -} - -void cpu_remove_sync(CPUState *cpu) -{ - cpu_remove(cpu); - while (cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } + qemu_mutex_unlock_iothread(); + qemu_thread_join(cpu->thread); + qemu_mutex_lock_iothread(); } =20 /* For temporary buffers for forming a name */ --=20 1.8.3.1