From patchwork Mon Sep 18 16:02:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 724162 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1774123wro; Mon, 18 Sep 2023 09:06:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEujyCMPVE8MuzF8ignnZYXf74CMWqVIbFwouKFoMIZo4sMPEBSRPEg22B0WPmxNsRveLaE X-Received: by 2002:a05:620a:28c1:b0:773:a770:bd9d with SMTP id l1-20020a05620a28c100b00773a770bd9dmr11562205qkp.16.1695053182120; Mon, 18 Sep 2023 09:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695053182; cv=none; d=google.com; s=arc-20160816; b=YG65UYTRvsShCeQ6Y3Ie2GBZOnOjVaB/QIa/DHiLoHXctF7V3APdEKsBDPyUWW5BDr kV28wRcFVS89kxH99Mx4rUsbC0WLnF4gnCnGZjwpXZXc1N5WbHzfRiKHMGRTIC/0eXnG qBe7ilbyMPJadj6VA7SnSY4Y3Ngj+/tKv8rHaLz3PcJJDJ09Fc0LxjQGV1kpxOdK2qS+ rFJkS9jSfrKq5+P0J+5g7wRgK7Dd7ZsKNcCn7BOvQiMgDXGZ8LLgmWFpx4Aj5GCmiPLK 6KgsuIZPUEZPOoPs56IQoMnli35QuKnofdUYP97kn3X/JE49BU9d6w9G7nXGmqL9hZtT shgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PkWYWSxfkqk4N63ErKsmSMdZBfBTpiMgD55n/Z94pZY=; fh=AIYNAcrfQPdTp+tiOBYg2bCy2NfWRbXD73JV9SLWbpM=; b=J3ol2CvFJf6g8etzwlpZmMh75zb7/SqsD/kbc7qgXHMZcvgaqvAXoHK4kyUBXTu4WL f9rMoA2unYAKHGjK17gnvqcYPI0lr338/KXknqgMidEBS6BZs0uuAGuVg/1VHj+5HrXc 19L/vuKr7ozzVeU053XX9zv3kXPWO/bLjloFQWaUNKwCau0CoGmAORHw/grlPJb0LTwC QlxycVPjXNr4LGGxapeJ7J0uMRstEg7WonsR2a+E/ABaGtkPgYLT6xgL8T+RAS8jpRWQ R8sR1Mwh0TK1rBpEwt9OWsXkqar46PC7V/IqOBqsRrJmxcEXgI0LEOwuTpjuhcEOeKXF Giqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FzpzEtCc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t19-20020a05620a0b1300b0077079bf7f41si6120170qkg.218.2023.09.18.09.06.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2023 09:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FzpzEtCc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiGjX-0007hc-0Y; Mon, 18 Sep 2023 12:04:23 -0400 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 1qiGil-0006Rx-Po for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:39 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiGij-000424-4x for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:35 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so78621911fa.2 for ; Mon, 18 Sep 2023 09:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695053011; x=1695657811; darn=nongnu.org; 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=PkWYWSxfkqk4N63ErKsmSMdZBfBTpiMgD55n/Z94pZY=; b=FzpzEtCctgoRwBb5doYXBYNxMzfvh6ANplCexRclHNpMLcN+5jI74oHdDIZroOSuAg 6gAhOgtM6Fby/GXgFakU5I5ofxJbzTsdoOQ0zrrdl2Wz8L33MysodTMvM8j8HA6faI7g 2LVuvFG5u92WPEC1+zWVNxGf5p7tc8knu6w77H1nRdtfn1j44F6d7rkTzQITSkHQZy1F PNMyQaadCZoMlgou5OycbaeV3ywU4lEV4L1VBfzdt/SLBz1wh4aTREzu2h1L0fDkbvC/ IzeAyXTRxqEtyvJEvjR9wVFBDNMK3ytzWaAXAPgloGvXhUnQFjuE9hKjkMG1T4pvv616 R29Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695053011; x=1695657811; 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=PkWYWSxfkqk4N63ErKsmSMdZBfBTpiMgD55n/Z94pZY=; b=SsEzs6MFmwcEHGIqqDE8Q37PdOHWo4L2q4oXovkYsBZ4DcD4Q476pnHSXHcKnqffOi 8ntyDnbbz4l5ZNO8SNg4qOvf4bmksU4GrfwNX7sESJJnI+pC+XTLWlsd/DgyNEGfFPvW GWuTfBddagBvYzeocNLXoWXJYybdFY0qLwqmdEhto2KSgcxctn0xjAP6gYWT4MOovOvl 0zGhz3NPqROGpa8g9FGc1RS03PzOe91f+UVqMyOTC6utMSWWEikxYr5sRlaZpoFT3L9m ePDfit8yQ1l7OIsFPT60OUla+frEH33tdrhSSIrO2d+BJIiXiwcd1TiKSj/hQHiOLzp4 mo3w== X-Gm-Message-State: AOJu0YylZTcuFUfGJrPv6zfxsngNFE/jK8yaPE7pAt78Sz6btmb+epIb EnX0K/5pwWCx9rbAFkrDH8JiC6INptFa8Jkv+qJ17C3H X-Received: by 2002:a2e:330c:0:b0:2b6:d13a:8e34 with SMTP id d12-20020a2e330c000000b002b6d13a8e34mr7309381ljc.46.1695053010845; Mon, 18 Sep 2023 09:03:30 -0700 (PDT) Received: from localhost.localdomain (static-212-193-78-212.thenetworkfactory.nl. [212.78.193.212]) by smtp.gmail.com with ESMTPSA id o15-20020a1709061d4f00b0099cf840527csm6708419ejh.153.2023.09.18.09.03.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 09:03:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Max Filippov , David Hildenbrand , Peter Xu , Anton Johansson , Peter Maydell , kvm@vger.kernel.org, Marek Vasut , David Gibson , Brian Cain , Yoshinori Sato , "Edgar E . Iglesias" , Claudio Fontana , Daniel Henrique Barboza , Artyom Tarasenko , Marcelo Tosatti , qemu-ppc@nongnu.org, Liu Zhiwei , Aurelien Jarno , Ilya Leoshkevich , Daniel Henrique Barboza , Bastian Koppelmann , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Alistair Francis , Alessandro Di Federico , Song Gao , Marcel Apfelbaum , Chris Wulff , "Michael S. Tsirkin" , Alistair Francis , Fabiano Rosas , qemu-s390x@nongnu.org, Yanan Wang , Luc Michel , Weiwei Li , Bin Meng , Stafford Horne , Xiaojuan Yang , "Daniel P . Berrange" , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Jiaxun Yang , Richard Henderson , Aleksandar Rikalo , Bernhard Beschow , Mark Cave-Ayland , qemu-riscv@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Nicholas Piggin , Greg Kurz , Michael Rolnik , Eduardo Habkost , Markus Armbruster , Palmer Dabbelt Subject: [PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize() Date: Mon, 18 Sep 2023 18:02:39 +0200 Message-ID: <20230918160257.30127-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918160257.30127-1-philmd@linaro.org> References: <20230918160257.30127-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org While create_vcpu_thread() creates a vCPU thread, its counterpart is cpu_remove_sync(), which join and destroy the thread. create_vcpu_thread() is called in qemu_init_vcpu(), itself called in cpu_common_realizefn(). Since we don't have qemu_deinit_vcpu() helper (we probably don't need any), simply destroy the thread in cpu_common_unrealizefn(). Note: only the PPC and X86 targets were calling cpu_remove_sync(), meaning all other targets were leaking the thread when the vCPU was unrealized (mostly when vCPU are hot-unplugged). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/cpu-common.c | 3 +++ target/i386/cpu.c | 1 - target/ppc/cpu_init.c | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index a3b8de7054..e5841c59df 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -221,6 +221,9 @@ static void cpu_common_unrealizefn(DeviceState *dev) /* NOTE: latest generic point before the cpu is fully unrealized */ cpu_exec_unrealizefn(cpu); + + /* Destroy vCPU thread */ + cpu_remove_sync(cpu); } static void cpu_common_initfn(Object *obj) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index cb41d30aab..d79797d963 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7470,7 +7470,6 @@ static void x86_cpu_unrealizefn(DeviceState *dev) X86CPUClass *xcc = X86_CPU_GET_CLASS(dev); #ifndef CONFIG_USER_ONLY - cpu_remove_sync(CPU(dev)); qemu_unregister_reset(x86_cpu_machine_reset_cb, dev); #endif diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index e2c06c1f32..24d4e8fa7e 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6853,8 +6853,6 @@ static void ppc_cpu_unrealize(DeviceState *dev) pcc->parent_unrealize(dev); - cpu_remove_sync(CPU(cpu)); - destroy_ppc_opcodes(cpu); }