From patchwork Wed Mar 23 17:17:39 2022 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: 12789976 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 084E2C433F5 for ; Wed, 23 Mar 2022 17:19:46 +0000 (UTC) Received: from localhost ([::1]:53618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4eA-0004Xz-3O for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:19:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4ci-0001zx-8R for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:16 -0400 Received: from [2607:f8b0:4864:20::102b] (port=54090 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4cg-0004TD-Nm for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:16 -0400 Received: by mail-pj1-x102b.google.com with SMTP id bx5so2364235pjb.3 for ; Wed, 23 Mar 2022 10:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RdGe7OSna0pa6P1DCbP+tWeGpoxvWEJQjOuJ7sjX7ZM=; b=LfJoFD5fOViBkuqfE0KI6EMWLe6oYelEsiQii6kQMJ+pxD0zqcY9STqOMnDFSlW73M 92ZYIUVnSjAEyM+0RN1XniYK9pmWDuGBo+SVmGf4sOHKTxRnTx7RfBfiXxSWznfHXIkq 0ct06cT/vEr1W7QFb/EO+MjqCSN9t4/1zOTBHtezxjV3AkxnCTB6PF9fzrALv+p62nuR RTbDk67z0FYbVHfgSJqkxdDjD0ZVlUCIoQNiEBHCeZ0g3oW9bGRNmiBQyv4PmC07JGLY 6pTUzjjLplNCGttiMQwTUmcJa0rxUNYiG8FiTe/ZrvXei+d0TJRUFxqUTgIUFjRYdCGL ZQAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RdGe7OSna0pa6P1DCbP+tWeGpoxvWEJQjOuJ7sjX7ZM=; b=tOk19Fgod21bxo0U4zC3En8vgKLWKyG/s3TZ1xRoS1AxJkPNZNwPUbfXXazHWHyM/B dj4HdXzyheNzmrELRAeVc/NL4CG/iaMsw9g4yMz7vscSe1tmX1ZfvBybw0Wm/3YwESR9 9r2NWPFjhOFrGNeWOJ1YE2oVg0HfIu5zjiJl2uvutjT8k+2r83egogKwbvbOXjuaI1FE UU5PJrAygvoYSUrBzUIATcWBNapW7g8oh5O3LtL7m4fDs+WtYHN5iOr3SmRtSYVzU43Y zgDS6Wamefy53EXzi73ELECrAZwGX7g6JUmfPGtaUnBGAYFL2hnm/NMvjARQWIg9Clx0 h10w== X-Gm-Message-State: AOAM531tNYHPaolzsh2UnZ+Iy/vP9aVWx2hus/RfG4GdvvPlBGNGtJWb eapHuCvHqk3R7Qil8oqALDcn3eIgBME= X-Google-Smtp-Source: ABdhPJw8FuyQ7wLlVvP9x+Z8gtO3cPHdbxET9VHqz4Un8qAadu86lw/vl8rV1uYpDaorpMWUtuAyqg== X-Received: by 2002:a17:90b:1c07:b0:1c7:5324:c68e with SMTP id oc7-20020a17090b1c0700b001c75324c68emr802630pjb.202.1648055893334; Wed, 23 Mar 2022 10:18:13 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id l20-20020a056a00141400b004f65cedfb09sm498798pfu.48.2022.03.23.10.18.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:18:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 01/13] cpu: Free cpu->cpu_ases in cpu_address_space_destroy() Date: Wed, 23 Mar 2022 18:17:39 +0100 Message-Id: <20220323171751.78612-2-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda Create cpu_address_space_destroy() to free a CPU's cpu_ases list. vCPU hotunplug related leak reported by Valgrind: ==132362== 216 bytes in 1 blocks are definitely lost in loss record 7,119 of 8,549 ==132362== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==132362== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==132362== by 0x7E34AF: cpu_address_space_init (physmem.c:751) ==132362== by 0x45053E: qemu_init_vcpu (cpus.c:635) ==132362== by 0x76B4A7: x86_cpu_realizefn (cpu.c:6520) ==132362== by 0x9343ED: device_set_realized (qdev.c:531) ==132362== by 0x93E26F: property_set_bool (object.c:2273) ==132362== by 0x93C23E: object_property_set (object.c:1408) ==132362== by 0x9406DC: object_property_set_qobject (qom-qobject.c:28) ==132362== by 0x93C5A9: object_property_set_bool (object.c:1477) ==132362== by 0x933C81: qdev_realize (qdev.c:333) ==132362== by 0x455E9A: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda Tested-by: Philippe Mathieu-Daudé Message-Id: <20220321141409.3112932-5-mark.kanda@oracle.com> Signed-off-by: Philippe Mathieu-Daudé --- cpu.c | 1 + include/exec/cpu-common.h | 7 +++++++ softmmu/physmem.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/cpu.c b/cpu.c index be1f8b074c..59352a1487 100644 --- a/cpu.c +++ b/cpu.c @@ -174,6 +174,7 @@ void cpu_exec_unrealizefn(CPUState *cpu) tcg_exec_unrealizefn(cpu); } + cpu_address_space_destroy(cpu); cpu_list_remove(cpu); } diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 50a7d2912e..b17ad61ae4 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -111,6 +111,13 @@ size_t qemu_ram_pagesize_largest(void); */ void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr); +/** + * cpu_address_space_destroy: + * @cpu: CPU for this address space + * + * Cleanup CPU's cpu_ases list. + */ +void cpu_address_space_destroy(CPUState *cpu); void cpu_physical_memory_rw(hwaddr addr, void *buf, hwaddr len, bool is_write); diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 43ae70fbe2..aec61ca07a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -762,6 +762,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx, } } +void cpu_address_space_destroy(CPUState *cpu) +{ + g_free(cpu->cpu_ases); +} + AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) { /* Return the AddressSpace corresponding to the specified index */ From patchwork Wed Mar 23 17:17:40 2022 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: 12789977 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 BA213C433EF for ; Wed, 23 Mar 2022 17:20:00 +0000 (UTC) Received: from localhost ([::1]:54872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4eN-0005RH-MQ for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:19:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4cu-0002du-OK for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:28 -0400 Received: from [2607:f8b0:4864:20::102e] (port=42947 helo=mail-pj1-x102e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4ct-0004UT-5r for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:28 -0400 Received: by mail-pj1-x102e.google.com with SMTP id o3-20020a17090a3d4300b001c6bc749227so2492358pjf.1 for ; Wed, 23 Mar 2022 10:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kr2xMtMFIyMaJvHp1QmAibj3cqEfTuMfM82zkP/aCIo=; b=GzQ9UQBsumIhsWs2W2K2ffiFYxEFSk/uJQDwHsoJE62lVsznZpDAk+rbusDkg4/pXh oYRTWwWf3XXjgqFP4meFBl7xIZslLNSKyF5Y1Nkqv7BIN9qrP/HEZc2GPulKuv+eyy0Q CSLUBGrImnHkarTBPYHhqd4Bz5klN6S1366sxNVa10mTmSfYbuDDmi6EMLlX9llM8fg1 Rm4ZEgKbpo0wmx0loAPNkIBIdsbxwIgizQ0MiPiw3WJfDKD7pBaLfqF/gCCtKxZBp7LS gRHq1IcA4FNU/hF6TniJKOWUVqcOHD5j7pUDrlVzfih8abviJtAdwMVwFP6x0OrQ4GyB ud3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kr2xMtMFIyMaJvHp1QmAibj3cqEfTuMfM82zkP/aCIo=; b=AAhPALeN1wz0RbnhJ8x11YDeYE/yRF26jYLbflVAJwyqtP5K0T6lDf3ivCY6V4ODjm IjQuJc75Q+cDVWAkRyYdjvLp0pwmqU30dL2648BBDLxLkTswuiV05wd1rZhK0X4xtQ/f xKI+7zpTlWiiA1ORTlKyvz6wvYrnWvPtM6BAmLIrV8iNXcYVSbdnkQTiFrYkuZ/PQIxA 6TQi90zThXtHGsh9pRdB1veUg9V00p+kSafl5/7X7IBRj1rSzUeuaWyp/EmKHflrWDTL xECjwCCPjvkQVdwgUrlP2N2GzSjBax1uqdMFcJ6QeQClgJ4JbbbpXQYn3bvyIUewMqc3 43Ng== X-Gm-Message-State: AOAM532uyFSGjKUWcprfUa+PDZnBh8H32n1EFOK92NudpNH8/TJoXCs2 xNmdL+LfegJ2zgh4VBSvilcxdVOo1XY= X-Google-Smtp-Source: ABdhPJyp9ousXQMjN1mFJdianu0WkJ5NuwBi+VzVmYIuZ9KnREKdbkqv1O8I5j4eIk26Y9GvJf6XJA== X-Received: by 2002:a17:902:834a:b0:14f:3337:35de with SMTP id z10-20020a170902834a00b0014f333735demr1074863pln.8.1648055905736; Wed, 23 Mar 2022 10:18:25 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id s6-20020a056a0008c600b004f667b8a6b6sm448750pfu.193.2022.03.23.10.18.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:18:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 02/13] target/i386/kvm: Free xsave_buf when destroying vCPU Date: Wed, 23 Mar 2022 18:17:40 +0100 Message-Id: <20220323171751.78612-3-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Fix vCPU hot-unplug related leak reported by Valgrind: ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 of 8,549 ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) ==132362== by 0xB41204: qemu_memalign (memalign.c:73) ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) Reported-by: Mark Kanda Tested-by: Mark Kanda Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/i386/kvm/kvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ef2c68a6f4..e93440e774 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2072,6 +2072,8 @@ int kvm_arch_destroy_vcpu(CPUState *cs) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; + g_free(env->xsave_buf); + if (cpu->kvm_msr_buf) { g_free(cpu->kvm_msr_buf); cpu->kvm_msr_buf = NULL; From patchwork Wed Mar 23 17:17:41 2022 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: 12789991 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 6C823C433F5 for ; Wed, 23 Mar 2022 17:25:28 +0000 (UTC) Received: from localhost ([::1]:43470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4jf-0000T1-BO for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:25:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4d6-0003JO-KS for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:40 -0400 Received: from [2607:f8b0:4864:20::102a] (port=45737 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4d5-0004Wp-6e for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:40 -0400 Received: by mail-pj1-x102a.google.com with SMTP id e6-20020a17090a77c600b001c795ee41e9so1906220pjs.4 for ; Wed, 23 Mar 2022 10:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bDnsp64dy23km8dL17HIpLYraoqdROmh6JM8WZ9QnxQ=; b=TgUmKBfMFNwRucBsohiY5JY8e9ioh62vGGPA59RsGbh//g7DqYEp6Ab52+czdRAyY8 NP7JPeqO100BsBFOc/Ay4dhLNWNwRFNW03vJZd3riU8UJJWvYnCfPYB4pocDoGekJKUT EzAgZEJWkWoFt7AzL3aW+DcXjjEkdSBB2D7fwnNkzE01zFwCOgVJ7C0f1jNlgcaaL4GN MhaEpPpi7sWKWo2nMSg2I6MHW3HNXf4tqK4IqiAVB37OJeIwt+hp+9OnIiguj3TblBIw fUkPOD4SvMNhJbqs6CnecPk4971sAW1ktFQ1pBjZQ9c/VJNicw0UzYoWQqC6arJevJXa g6rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bDnsp64dy23km8dL17HIpLYraoqdROmh6JM8WZ9QnxQ=; b=FD+h+kFeUIhTONhNMaf0Y0Y2kxYL0lpkw2Q5I6WoqA4/ubUu+CgrUdn0thB29Q4TR9 W9upO1OJuemL+QZ39DHp0a9QcApDwbEBECpiGQ7PMwdDpIJ9hCPOkZM91Zh8/vJitFsa 3+haCc2I5ZG8ZgHRTfWPU6WSwD28h9cRspUmBwwlMNdqlCXxNlra9ZslgQKj53QR31Zr YYOz8NsXkYNaKq8IJmtrws0tGvAFFIgHwgYmQoe5UQwI5ESKkperv7Q7wkjf+4Yhgw+j SPFJb3GNVVSspGJTlIgVEqlw3Fs7IIjEvikLWlVa5SCDtkCuxzOs58OPy+GVY9uTS2V4 bQ+Q== X-Gm-Message-State: AOAM531l1BlJXk+jyGFZUViFqGWExly14U6YbiDXqrwsl68MIkgsaHno XbKRfiVVI7PG7rmoOZl+kvQOkZw014I= X-Google-Smtp-Source: ABdhPJySoRv6SjqjiKCV5e8zH/IZey9o/1x0EduXwu4cNLj3RBjr1JlgyWZQVPeGljHAEFYooB4q3Q== X-Received: by 2002:a17:90a:19d2:b0:1be:d815:477f with SMTP id 18-20020a17090a19d200b001bed815477fmr804349pjj.23.1648055917873; Wed, 23 Mar 2022 10:18:37 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id f14-20020a63380e000000b0038253c4d5casm342070pga.36.2022.03.23.10.18.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:18:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 03/13] target/i386/hvf: Free resources when vCPU is destroyed Date: Wed, 23 Mar 2022 18:17:41 +0100 Message-Id: <20220323171751.78612-4-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Igor Mammedov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Both xsave_buf and hvf_caps are allocated in hvf_arch_init_vcpu(), free them in hvf_arch_vcpu_destroy(). Reported-by: Mark Kanda Suggested-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/i386/hvf/hvf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index fc12c02fb2..39fa4641b9 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -163,7 +163,9 @@ void hvf_arch_vcpu_destroy(CPUState *cpu) X86CPU *x86_cpu = X86_CPU(cpu); CPUX86State *env = &x86_cpu->env; + g_free(env->xsave_buf); g_free(env->hvf_mmio_buf); + g_free(hvf_state->hvf_caps); } static void init_tsc_freq(CPUX86State *env) From patchwork Wed Mar 23 17:17:42 2022 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: 12789978 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 801C8C433F5 for ; Wed, 23 Mar 2022 17:22:43 +0000 (UTC) Received: from localhost ([::1]:33968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4h0-0002KI-In for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:22:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4dI-00041q-AQ for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:52 -0400 Received: from [2607:f8b0:4864:20::536] (port=34394 helo=mail-pg1-x536.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4dG-0004Ya-T4 for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:18:52 -0400 Received: by mail-pg1-x536.google.com with SMTP id i184so1682209pgc.1 for ; Wed, 23 Mar 2022 10:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7g63uMCtTkVNfRXBZkshJ0Wiw4mo6s3K6WysQFVeHQ=; b=EMCnSQO4I48BMsxvvg3i3Lpu7MpcHIBM0VPU1LmYCuVl/RlXBQKnI+aX6Rw5+Otp1s 8IIMhkhQPGFAd7938UkWmV4lBtqZCbG9FdGo8U8RK3KvsKQbLGAa0c0IrtuSOjDJjuSV QFauhI8kpDEcO0CLjjNlJcZcwM0mAHerEv/s6+nsiQVem/Cxo3XuGDnC60sV25zy8Fr3 R6tcgTKLH53w67BvarZnpfob+GRcW9FPC96YnIAXa78jP8pjuvS3DMa/3hObSK9vvZeU ObQvhKX5xWReNbdvvifVE7tLNNOUGXQ9hqL23HPdi01BtJXokaAH3+6DQf7r2EYk52H9 xHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7g63uMCtTkVNfRXBZkshJ0Wiw4mo6s3K6WysQFVeHQ=; b=o8I8lDy2yWDgo4r4L6mdCBbB+rmnDZEj+NSgucYOr4vi9g2P/Eir3J/RokmbBU0tMJ rt9EKQi6u9BpxawweBPeNkNt4mpkaWt8wcoH9QZLDOAjExXs6Yh/03K1CT0Nx1itvtce Ztu70Uqdl3azV1viIJAi8cs+jta6nuU6eIpN4TgDRnj6jvkg5uaSB0cH2CLLMvdDoQJq LahJzfksOn50qUH+g2qEArfItuJPiZPxQT+fecnyMk+c78vDprvGLQmcANIiPt1QaZk6 40P7BIU/O1KOtgSq55CMMOSlH2oLtg/h8KA2qUmhHz58N1Wm6Lvh0jbhSRCMBZ/oDG42 azsg== X-Gm-Message-State: AOAM533R83cI2FfeFU+8a2Zdkqk5BYu+rXEQw/AuMLYIbfy483oJXWWD Jow4DxkwJKd1xWuAPJN8d5nZlyq9wjU= X-Google-Smtp-Source: ABdhPJwsqttKPum5jvLljX6MsvisPeyZTYUskQFajfuzSlqwRvUxcgnszNBQqCwAUxI0R7csaGC+rA== X-Received: by 2002:a05:6a00:1d85:b0:4fa:9dba:f1f2 with SMTP id z5-20020a056a001d8500b004fa9dbaf1f2mr956040pfw.31.1648055929515; Wed, 23 Mar 2022 10:18:49 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id y9-20020a056a00180900b004faa45a2230sm455168pfa.210.2022.03.23.10.18.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:18:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 04/13] accel/hvf: Remove pointless assertion Date: Wed, 23 Mar 2022 18:17:42 +0100 Message-Id: <20220323171751.78612-5-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::536 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Both the comment and the hvf_enabled() check are duplicated at the beginning of hvf_cpu_thread_fn(), which is the thread callback created by hvf_start_vcpu_thread(). Remove. Signed-off-by: Philippe Mathieu-Daudé --- accel/hvf/hvf-accel-ops.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 54457c76c2..5c33dc602e 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -446,12 +446,6 @@ static void hvf_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - /* - * HVF currently does not support TCG, and only runs in - * unrestricted-guest mode. - */ - assert(hvf_enabled()); - cpu->thread = g_malloc0(sizeof(QemuThread)); cpu->halt_cond = g_malloc0(sizeof(QemuCond)); qemu_cond_init(cpu->halt_cond); From patchwork Wed Mar 23 17:17:43 2022 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: 12789989 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 D83A5C433F5 for ; Wed, 23 Mar 2022 17:23:10 +0000 (UTC) Received: from localhost ([::1]:36390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4hS-00044U-0a for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:23:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4dU-0004fX-D3 for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:04 -0400 Received: from [2607:f8b0:4864:20::62d] (port=41606 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4dS-0004cz-Pw for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:04 -0400 Received: by mail-pl1-x62d.google.com with SMTP id j13so2147053plj.8 for ; Wed, 23 Mar 2022 10:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0hihgfEmLJPNBEh4WW6rYf49XmgK0ovI41W1a0emuNk=; b=MrdYb7945anCfYH1VRiFA5pAW7S4hoZOOF1Pdv+2ZTrCvIPQ0tdNE6NgZGHvIaYl6F plkh3wIlaqYoXktAcEAtQmOqlHJdMmidt+Oa/wnRaHYaNMUJZ9CkCSrlqjquwFaZdWSC HPnXLzJcabcEufzwkRoVTxfpe1EHQA8+scJQyC9OkHIYWUa2UKWUlEhDYRHbD8EXQtLR hGXTs3LTe0tNECvEc0QQ3gavKzuFIBW5V+W6pGyNgy0F8X1RKcixk5n93FXcTecHiIep G1WrbmTHafbZqiFIsAW0M4VWI5qRob0xYjL9jnDgfVfth7/f271rS43Pm6WxxiTOI/Ta havA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0hihgfEmLJPNBEh4WW6rYf49XmgK0ovI41W1a0emuNk=; b=kxrMc1fWLMaBHc2LFEOxfNi6alQrjKNDPikSaHNa4/vxnpX/Tt6TU/Bn94Wf0II/oS EIhZZz0GCFlSyh0qlxe8Gnv/j1qKKw12CJ7v+B2JUST5Ruz+wYE7TiofbKYrv30v7mE7 wZaLK4eYm9O8YDxJjRhORc4UosjCP7FwtA+PK4s9sHrtl7FZGSgoTPUNkr5iXzUtGiWV /6TqwW+gfloo/bMwysT+eCFsvzhyv1MvotcHYKLKIUlyNzWNkWmBJzlZ8ZG2pRn5lg95 ugjgm+Z6NAqaIPH+n3srb1e08CqpNEhWWedIa45jHBAFtAbMYZTOkPJnrwufbVymMFrr HHeQ== X-Gm-Message-State: AOAM5316MxNhY7Z7HBI3sCLWHCBxNnRfAaxArGA11t1ZBS1EuJpf4E/4 G5vzJZ6ccGSbWx/ZjsxizopP7zngsag= X-Google-Smtp-Source: ABdhPJwdV5/nAguIIYnMM8I+otidppMXPEnBBQGuuNIH21Igt/CypcRNRBAVG30eApAdY410n71pzg== X-Received: by 2002:a17:90a:8581:b0:1b2:7541:af6c with SMTP id m1-20020a17090a858100b001b27541af6cmr842235pjn.48.1648055941418; Wed, 23 Mar 2022 10:19:01 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id u15-20020a056a00098f00b004faa58d44eesm455060pfg.145.2022.03.23.10.18.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:19:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 05/13] accel/tcg: Init TCG cflags in vCPU thread handler Date: Wed, 23 Mar 2022 18:17:43 +0100 Message-Id: <20220323171751.78612-6-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Move TCG cflags initialization to thread handler. Remove the duplicated assert checks. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops-mttcg.c | 5 ++--- accel/tcg/tcg-accel-ops-rr.c | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c index ea2b741deb..80609964a6 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -71,6 +71,8 @@ static void *mttcg_cpu_thread_fn(void *arg) assert(tcg_enabled()); g_assert(!icount_enabled()); + tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); + rcu_register_thread(); force_rcu.notifier.notify = mttcg_force_rcu; force_rcu.cpu = cpu; @@ -140,9 +142,6 @@ void mttcg_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; - g_assert(tcg_enabled()); - tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); - cpu->thread = g_new0(QemuThread, 1); cpu->halt_cond = g_malloc0(sizeof(QemuCond)); qemu_cond_init(cpu->halt_cond); diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index b287110766..de8af32af7 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -153,7 +153,9 @@ static void *rr_cpu_thread_fn(void *arg) Notifier force_rcu; CPUState *cpu = arg; - assert(tcg_enabled()); + g_assert(tcg_enabled()); + tcg_cpu_init_cflags(cpu, false); + rcu_register_thread(); force_rcu.notify = rr_force_rcu; rcu_add_force_rcu_notifier(&force_rcu); @@ -276,9 +278,6 @@ void rr_start_vcpu_thread(CPUState *cpu) static QemuCond *single_tcg_halt_cond; static QemuThread *single_tcg_cpu_thread; - g_assert(tcg_enabled()); - tcg_cpu_init_cflags(cpu, false); - if (!single_tcg_cpu_thread) { cpu->thread = g_new0(QemuThread, 1); cpu->halt_cond = g_new0(QemuCond, 1); From patchwork Wed Mar 23 17:17:44 2022 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: 12789994 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 F246EC433EF for ; Wed, 23 Mar 2022 17:28:58 +0000 (UTC) Received: from localhost ([::1]:50740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4n3-0005mx-QQ for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:28:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4dg-0004xo-2d for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:17 -0400 Received: from [2607:f8b0:4864:20::62a] (port=36836 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4de-0004eh-Lr for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:15 -0400 Received: by mail-pl1-x62a.google.com with SMTP id q5so2162566plg.3 for ; Wed, 23 Mar 2022 10:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ARhouW8OXYXIRPQjyAafjquDP6FUc0ZjucITbhHVg5E=; b=qrmYjLiXax41wynkldUk46+CTEMhEwNtecSEajm0opdutnFDwZFnb5R/0qKYGW240d Xfip76+lUKk9ny0xZ6YhE00J4TKeGUMnJ8SoGN13GNg0qwOnowPKMtRWHdotb/gtDf5D MtRHQsTElQmEIKX9ZZdHDbTe5WtCrvk7tdOYhyQM3qFOeBHzl9lmse0tjqCeQBy7UGAO ybhOz4GI6Y3MO4ukQmThEULFFMRC2oMeKASkkcCP/dzLf46Qozna5NyY8TjPqJE1DQEs GnXGhPd1I7iqkj+/YcGjrCQJ3XokcBCDvDTZ5EW8eBPnuLOf/HAk1jK7Hlg+t8pJiPz7 v+sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ARhouW8OXYXIRPQjyAafjquDP6FUc0ZjucITbhHVg5E=; b=24ZaUM9MMMSPC6XmzJcYkL/8caZ2bMusbGihRKiiOujwIcVTsFrpGjlmIocS7gl+63 dreSevM+w1mL3x8BVVZzfA1ESWtQvixvONKwM+sQV/Q+SEpeqbeMjImYyUREp6QW8sFB p61VOEQBhrqe8aBndcwWh1ixMaSjMhsxYF930kGWkH1N+XpwWO7yyLnn80teyitwBteK 6zjz3fg0ESwcxmNUiX/oVxi3oBUfYexY6+l2bBLePltgy5j2xhV6Bawb7ehXNYNnBLbE pgKbdZKvrgeiAQC1l9iMh45SZ5G/lSFS/+hkASsCUXoQAn8rczkT+SvP1ghDOinMLPSX Yiiw== X-Gm-Message-State: AOAM532Yh8HBl9kDmO6og0DvHDEusJs3VsB4GhHchxbsv8iC3pbzBPsJ YkHzfSdMFxZiDeuYzTMxlkBuLSoySXI= X-Google-Smtp-Source: ABdhPJzLdZtFm+tMEOoscqkjQAgJQZm9yuu7A4C9NQT5lLkj2BUY8yeJrCTrFbO4ucEGmuTjUPWoUA== X-Received: by 2002:a17:902:bf07:b0:14f:a3a7:97a0 with SMTP id bi7-20020a170902bf0700b0014fa3a797a0mr1005569plb.105.1648055953255; Wed, 23 Mar 2022 10:19:13 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id 5-20020a17090a1a4500b001c54dc9061esm266865pjl.51.2022.03.23.10.19.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:19:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 06/13] accel/tcg: Reorganize tcg_accel_ops_init() Date: Wed, 23 Mar 2022 18:17:44 +0100 Message-Id: <20220323171751.78612-7-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Reorg TCG AccelOpsClass initialization to emphasis icount mode share more code with single-threaded TCG. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/tcg/tcg-accel-ops.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index ea7dcad674..d2181ea1e5 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -98,16 +98,17 @@ static void tcg_accel_ops_init(AccelOpsClass *ops) ops->create_vcpu_thread = mttcg_start_vcpu_thread; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt; - } else if (icount_enabled()) { - ops->create_vcpu_thread = rr_start_vcpu_thread; - ops->kick_vcpu_thread = rr_kick_vcpu_thread; - ops->handle_interrupt = icount_handle_interrupt; - ops->get_virtual_clock = icount_get; - ops->get_elapsed_ticks = icount_get; } else { ops->create_vcpu_thread = rr_start_vcpu_thread; ops->kick_vcpu_thread = rr_kick_vcpu_thread; - ops->handle_interrupt = tcg_handle_interrupt; + + if (icount_enabled()) { + ops->handle_interrupt = icount_handle_interrupt; + ops->get_virtual_clock = icount_get; + ops->get_elapsed_ticks = icount_get; + } else { + ops->handle_interrupt = tcg_handle_interrupt; + } } } From patchwork Wed Mar 23 17:17:45 2022 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: 12789992 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 D9492C433F5 for ; Wed, 23 Mar 2022 17:26:08 +0000 (UTC) Received: from localhost ([::1]:43908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4kJ-0000lk-Sr for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:26:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4ds-00058X-7g for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:28 -0400 Received: from [2607:f8b0:4864:20::433] (port=42877 helo=mail-pf1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4dq-0004gL-PC for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:27 -0400 Received: by mail-pf1-x433.google.com with SMTP id g19so1969161pfc.9 for ; Wed, 23 Mar 2022 10:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qDaNpZGuS1pck7ljrYFEMbUPV6qyv4FTweWO+b6dthQ=; b=T/qLqQeIJbWYsc9iaC9cBJMrxMVXpFG/QUiJyPoZd2LdVpzgu4IXrjsjtgh7JucAvy K7XpwsgzEr4aysFsdfXZmw3r4NYiJ3DWcc8JZSOA6Tl3BokPzJQNj2so5OQV1hh6HwEd K1QxKLSW49T2dyO8ay7JL+g882pp7zrdo93r7w/Lf9Ytie2vCQEYjBetUSMwG2E36vDl O1T8FHb+t6UP2pO29Px3c/CN3Z5Qpup501aDNB/0R3S7yzRNJBBBqU6RsNi2V43JnUir +2yzv/A6XJFzT3jeRvNmug8zR6Gv0G3QKmEJL2xM7jyr2axrPlstTpbbBI6cVPxAa6d7 uTWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qDaNpZGuS1pck7ljrYFEMbUPV6qyv4FTweWO+b6dthQ=; b=3qO3MJ/KyoinwAf1Juwz4OV/whm+MCYfi9iXrZL5ksyICBbEjaQoOVS6FRSgtEvQtH 1KaJGXWQg5+TuP5m7jvfZ9nwBTsPSymMj1HU+PMcGcuJ1kPaXqT4qxB/lGg7HMSRffqy WI2Oacont+7TML3ioXHI+H6O1EdksNXEEj/eozpHbGWJOXLMMxZN3Ay+1ZaDKW4lF2YM 5k01xT2ZIu+SBU9V9gXM+HE+Vn68l/gReLt86QCw3UYHWjjvO16MblWyAlMr4mTemm06 dUZCjt2Y1gFxF92X1d+Tvzkmk+pSiieO4UHo9W5wP75HXPPCAn6kTiyxmoAGZUavbGyV XFQg== X-Gm-Message-State: AOAM532XeuoSjH4Qf2DgGpwfMB/TX8xeTfrJidNtL5JzYiPpfOyuIiB9 Nk1lQJNHuLyQNs4qOXg6cO7ljTQ7Ru8= X-Google-Smtp-Source: ABdhPJysELA1SacEi6NLWr6VDuEztyIdr+gkkW330J+PSAAiBOd3a1EdmuP7lIO3WbruDTaR69cscQ== X-Received: by 2002:a63:cf09:0:b0:372:d564:8024 with SMTP id j9-20020a63cf09000000b00372d5648024mr705074pgg.251.1648055965298; Wed, 23 Mar 2022 10:19:25 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id a24-20020a637f18000000b003821e17819csm354438pgd.61.2022.03.23.10.19.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:19:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / postcheck handlers Date: Wed, 23 Mar 2022 18:17:45 +0100 Message-Id: <20220323171751.78612-8-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::433 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Introduce precheck/postcheck handlers which will help to refactor code common to the various create_vcpu_thread() implementations. Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/accel-ops.h | 4 ++++ softmmu/cpus.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 6013c9444c..26b542d35c 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -31,6 +31,10 @@ struct AccelOpsClass { bool (*cpus_are_resettable)(void); void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ + /* If non-NULL, return whether common vCPU thread must be created */ + bool (*create_vcpu_thread_precheck)(CPUState *cpu); + void (*create_vcpu_thread_postcheck)(CPUState *cpu); + void (*kick_vcpu_thread)(CPUState *cpu); bool (*cpu_thread_is_idle)(CPUState *cpu); diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 7b75bb66d5..857e2081ba 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -637,7 +637,13 @@ void qemu_init_vcpu(CPUState *cpu) /* accelerators all implement the AccelOpsClass */ g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL); - cpus_accel->create_vcpu_thread(cpu); + if (cpus_accel->create_vcpu_thread_precheck == NULL + || cpus_accel->create_vcpu_thread_precheck(cpu)) { + cpus_accel->create_vcpu_thread(cpu); + } + if (cpus_accel->create_vcpu_thread_postcheck) { + cpus_accel->create_vcpu_thread_postcheck(cpu); + } while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); From patchwork Wed Mar 23 17:17:46 2022 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: 12789987 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 1EFABC433F5 for ; Wed, 23 Mar 2022 17:22:59 +0000 (UTC) Received: from localhost ([::1]:35322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4hF-0003Gw-Sh for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:22:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4e4-0005I2-HQ for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:40 -0400 Received: from [2607:f8b0:4864:20::62c] (port=40889 helo=mail-pl1-x62c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4e2-0004in-Av for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:39 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x2so2151046plm.7 for ; Wed, 23 Mar 2022 10:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hGzoIEiqotEx27Bg+Z4eL5zpKSfKxDxE5VGRYeUpF1U=; b=YN2nPW6qFv/FXMaZbHoge7dvyFY38/0TL7t4FHhvZ3ROq4ndXz7aVe/WYlNC1die01 TcD+kFy/xidXVPGx7gpqZ75SywkLL2EYPJoDBotF8TIRl44RYN5JTM1qKjZv3d6GIfqU jWotsaKHFfCdSkhPSpjxx+SuvENG8Rj/Mv3l0DwhQfohsPpFU6t73UPPj8CSrbQfuBkd 9Z/VXAQWYd7J2zxrjtJ/gWD5iowxhsrQ7vwQGuFXZNP0fMUeSz4fBHXmC/cKAe6dYlVs NCh7inykD23K3nAQkmHK7E/YkkRS5g4L8ZmGYcKNVOwgDWWwZ2QenCCnu2L1vwreGob1 13sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hGzoIEiqotEx27Bg+Z4eL5zpKSfKxDxE5VGRYeUpF1U=; b=q+cKOcBHtQ55vZzG3Asl4QVWUeFx74DvFA549DH0sSELfYvT8aXPItO38BBmOtC176 6q1Z63SxeXCZVyuu8HunIuSv7WN74ejHXycJTNqiCkEqFT3B4qlDB3GUSyvfR88/csym hQ8sjn7ESd/qlApfhWT01vNLjNm2rX0xwGnJHP5ABfQeNU7zLxazgPxKRgZ8a2Am8FtF 0kWss5NB2PNnG/w+c/7ALa/htanrToXaJNPalZN2CxW8nWaItX8vtvFI9Lm8hrT6rDt5 0lCrAZq+WIwfL12IXXvb5PfxAq8sMketPbMJLhV67igtcYMPL4Pu0ToJwHySMzMDS59E v3LA== X-Gm-Message-State: AOAM5328SpwNR0WJ+d+qasiufw4H0YfXeJUj0vUlFNYTCmhm+9iVKMi7 zPdyhFbjJZVvI+d1qbIEADP8B2ltSzg= X-Google-Smtp-Source: ABdhPJypHL2FuS5xBRJ7IZra6e8WHCycd0JJ50I5gNrC37pYhlUHgXYCXbDEv97OJjTv0XckGdi+gQ== X-Received: by 2002:a17:902:8543:b0:154:9588:52ab with SMTP id d3-20020a170902854300b00154958852abmr1177032plo.50.1648055976951; Wed, 23 Mar 2022 10:19:36 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id d25-20020a639919000000b00364f999aed5sm349409pge.20.2022.03.23.10.19.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:19:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 08/13] accel/tcg: Extract rr_create_vcpu_thread_precheck() Date: Wed, 23 Mar 2022 18:17:46 +0100 Message-Id: <20220323171751.78612-9-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé We are going to extract common pattern from rr_start_vcpu_thread(). First extract the rr_create_vcpu_thread_precheck() helper. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops-rr.c | 7 +++++++ accel/tcg/tcg-accel-ops-rr.h | 1 + 2 files changed, 8 insertions(+) diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index de8af32af7..3da684b8e6 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -272,6 +272,13 @@ static void *rr_cpu_thread_fn(void *arg) return NULL; } +static QemuThread *single_tcg_cpu_thread; + +bool rr_create_vcpu_thread_precheck(CPUState *cpu) +{ + return !single_tcg_cpu_thread; +} + void rr_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; diff --git a/accel/tcg/tcg-accel-ops-rr.h b/accel/tcg/tcg-accel-ops-rr.h index 54f6ae6e86..e2273b66d4 100644 --- a/accel/tcg/tcg-accel-ops-rr.h +++ b/accel/tcg/tcg-accel-ops-rr.h @@ -15,6 +15,7 @@ /* Kick all RR vCPUs. */ void rr_kick_vcpu_thread(CPUState *unused); +bool rr_create_vcpu_thread_precheck(CPUState *cpu); /* start the round robin vcpu thread */ void rr_start_vcpu_thread(CPUState *cpu); From patchwork Wed Mar 23 17:17:47 2022 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: 12789995 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 3500DC433EF for ; Wed, 23 Mar 2022 17:31:16 +0000 (UTC) Received: from localhost ([::1]:56810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4pH-0001ef-DX for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:31:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4eH-0005zl-7d for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:53 -0400 Received: from [2607:f8b0:4864:20::531] (port=41607 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4eE-0004jt-Pd for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:19:52 -0400 Received: by mail-pg1-x531.google.com with SMTP id t13so433026pgn.8 for ; Wed, 23 Mar 2022 10:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pYl7PFx6HJtSTXEwRh0v4jjLcljevjvNsnI/ABIkNpc=; b=AVu5Njemv6HLmOsdKQ+VfG9+68Y75QCUvSBWjlFuBjz/HNiGqkYCNDiZx3nYu9plDG UF7gb7VVoz34sG1mev5yCvoNrsQ1z8IWtvbq8+aDO+pYuGeK/DFV2qzT8BBc6poAy1Ll lOEl1BAafr+0lbjC4zH66PCSBb7+R1xkhdgQxWxYoeJlwK3WLMcfEGBgnF+sjnGbStK4 a9SLdMMRZo/bJUh14Z6gnY4UjA5DdwaI6pbaa9fmRZtN7HA6P8qF3KsTh8w0VYYU2kuV 0AUyXjYRd81y11ZlUPISW8rgQ5pc3ziJB920CpKR3PJuR1zGs+XHXjL8xkJmc2RZcs4z JHdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pYl7PFx6HJtSTXEwRh0v4jjLcljevjvNsnI/ABIkNpc=; b=iyV4fJs0zFo86PDvpAicbV87CNWM7sIf4bg8KYBrP2IPGJQXSEE5ghjEbvfj0s81cN DuYk58ERpNfNfsBrrzoDHhzSeOGl2V0KyIZAf4O/jqyobjb7Uyr2Dz26k77LW91ewI9W J6q9ODKEwWtrBUZepk1MBMP3fGyeui2N11Dahui1Yb/bz73y7gqSyMCOgZ6RlB84LzYO KLzDKj70YGLC6DFYj8aRVXlHckmJHRpB6vHfstAaP+bpzwwam+jE/cd5+LxAeU6NMeGC zkJzokwYnf/z4lxs0882lgk1+gKHulCOT+IbDDm1ZcZ5/v72w5wCryj03HiACo5dZnkH KQhg== X-Gm-Message-State: AOAM533LtzO5uyM6QP8z+iwwnudViV1bnQXo1VOlPf+sQ3FD2WzA/76M D9F7JzqkwJQJoJv8e+xZ0Iv+ffDFGk8= X-Google-Smtp-Source: ABdhPJxwe0fvqNFuFM35WUTu/PR9vPZnoQaBkNABrXApSmPztgel1hVfca2uBIR7EEKKmqRyCL7USA== X-Received: by 2002:a63:4d56:0:b0:382:9ad9:d28d with SMTP id n22-20020a634d56000000b003829ad9d28dmr691452pgl.45.1648055988955; Wed, 23 Mar 2022 10:19:48 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id h10-20020a056a00230a00b004faa0f67c3esm515084pfh.23.2022.03.23.10.19.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:19:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create() Date: Wed, 23 Mar 2022 18:17:47 +0100 Message-Id: <20220323171751.78612-10-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pg1-x531.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé All accelerators implement a very similar create_vcpu_thread() handler. Extract the common part as common_vcpu_thread_create(), which only requires the AccelOpsClass::vcpu_thread_fn() routine and the accelerator AccelOpsClass::thread_name for debugging purpose. The single exception is TCG/RR which re-use a single vCPU. Have it use the same logic by using the .precheck/.postcheck handlers. Signed-off-by: Philippe Mathieu-Daudé --- accel/accel-softmmu.c | 2 +- accel/dummy-cpus.c | 15 +-------------- accel/hvf/hvf-accel-ops.c | 18 +++--------------- accel/kvm/kvm-accel-ops.c | 17 +++-------------- accel/qtest/qtest.c | 3 ++- accel/tcg/tcg-accel-ops-mttcg.c | 22 +--------------------- accel/tcg/tcg-accel-ops-mttcg.h | 3 +-- accel/tcg/tcg-accel-ops-rr.c | 21 +++------------------ accel/tcg/tcg-accel-ops-rr.h | 6 ++++-- accel/tcg/tcg-accel-ops.c | 6 ++++-- accel/xen/xen-all.c | 2 +- include/sysemu/accel-ops.h | 3 ++- include/sysemu/cpus.h | 4 ++-- softmmu/cpus.c | 23 ++++++++++++++++++++--- target/i386/hax/hax-accel-ops.c | 20 ++------------------ target/i386/nvmm/nvmm-accel-ops.c | 17 +++-------------- target/i386/whpx/whpx-accel-ops.c | 20 +++----------------- 17 files changed, 56 insertions(+), 146 deletions(-) diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c index 67276e4f52..7800df0234 100644 --- a/accel/accel-softmmu.c +++ b/accel/accel-softmmu.c @@ -77,7 +77,7 @@ void accel_init_ops_interfaces(AccelClass *ac) /* * all accelerators need to define ops, providing at least a mandatory - * non-NULL create_vcpu_thread operation. + * non-NULL vcpu_thread_fn operation. */ g_assert(ops != NULL); if (ops->ops_init) { diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index 10429fdfb2..9840057969 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -18,7 +18,7 @@ #include "qemu/main-loop.h" #include "hw/core/cpu.h" -static void *dummy_cpu_thread_fn(void *arg) +void *dummy_vcpu_thread_fn(void *arg) { CPUState *cpu = arg; sigset_t waitset; @@ -57,16 +57,3 @@ static void *dummy_cpu_thread_fn(void *arg) rcu_unregister_thread(); return NULL; } - -void dummy_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu, - QEMU_THREAD_JOINABLE); -} diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 5c33dc602e..91d65036b4 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -442,25 +442,13 @@ static void *hvf_cpu_thread_fn(void *arg) return NULL; } -static void hvf_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HVF", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, hvf_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -} - static void hvf_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = hvf_start_vcpu_thread; + ops->thread_name = "HVF"; + ops->vcpu_thread_fn = hvf_cpu_thread_fn; + ops->kick_vcpu_thread = hvf_kick_vcpu_thread; ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index c4244a23c6..3d13efce0f 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -61,19 +61,6 @@ static void *kvm_vcpu_thread_fn(void *arg) return NULL; } -static void kvm_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_malloc0(sizeof(QemuThread)); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/KVM", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, kvm_vcpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -} - static bool kvm_vcpu_thread_is_idle(CPUState *cpu) { return !kvm_halt_in_kernel(); @@ -88,7 +75,9 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->thread_name = "KVM"; + ops->vcpu_thread_fn = kvm_vcpu_thread_fn; + ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset; diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index f6056ac836..1d0b1c855c 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -50,7 +50,8 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = dummy_start_vcpu_thread; + ops->vcpu_thread_fn = dummy_vcpu_thread_fn; + ops->get_virtual_clock = qtest_get_virtual_clock; }; diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c index 80609964a6..c7836332d7 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -63,7 +63,7 @@ static void mttcg_force_rcu(Notifier *notify, void *data) * current CPUState for a given thread. */ -static void *mttcg_cpu_thread_fn(void *arg) +void *mttcg_vcpu_thread_fn(void *arg) { MttcgForceRcuNotifier force_rcu; CPUState *cpu = arg; @@ -137,23 +137,3 @@ void mttcg_kick_vcpu_thread(CPUState *cpu) { cpu_exit(cpu); } - -void mttcg_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); - - /* create a thread per vCPU with TCG (MTTCG) */ - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG", - cpu->cpu_index); - - qemu_thread_create(cpu->thread, thread_name, mttcg_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); - -#ifdef _WIN32 - cpu->hThread = qemu_thread_get_handle(cpu->thread); -#endif -} diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttcg.h index 9fdc5a2ab5..b61aff5c1d 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.h +++ b/accel/tcg/tcg-accel-ops-mttcg.h @@ -13,7 +13,6 @@ /* kick MTTCG vCPU thread */ void mttcg_kick_vcpu_thread(CPUState *cpu); -/* start an mttcg vCPU thread */ -void mttcg_start_vcpu_thread(CPUState *cpu); +void *mttcg_vcpu_thread_fn(void *arg); #endif /* TCG_CPUS_MTTCG_H */ diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 3da684b8e6..006b787289 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -148,7 +148,7 @@ static void rr_force_rcu(Notifier *notify, void *data) * elsewhere. */ -static void *rr_cpu_thread_fn(void *arg) +void *rr_vcpu_thread_fn(void *arg) { Notifier force_rcu; CPUState *cpu = arg; @@ -279,28 +279,13 @@ bool rr_create_vcpu_thread_precheck(CPUState *cpu) return !single_tcg_cpu_thread; } -void rr_start_vcpu_thread(CPUState *cpu) +void rr_create_vcpu_thread_postcheck(CPUState *cpu) { - char thread_name[VCPU_THREAD_NAME_SIZE]; static QemuCond *single_tcg_halt_cond; - static QemuThread *single_tcg_cpu_thread; - - if (!single_tcg_cpu_thread) { - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); - - /* share a single thread for all cpus with TCG */ - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "ALL CPUs/TCG"); - qemu_thread_create(cpu->thread, thread_name, - rr_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); + if (! single_tcg_cpu_thread) { single_tcg_halt_cond = cpu->halt_cond; single_tcg_cpu_thread = cpu->thread; -#ifdef _WIN32 - cpu->hThread = qemu_thread_get_handle(cpu->thread); -#endif } else { /* we share the thread */ cpu->thread = single_tcg_cpu_thread; diff --git a/accel/tcg/tcg-accel-ops-rr.h b/accel/tcg/tcg-accel-ops-rr.h index e2273b66d4..a1e75e7afb 100644 --- a/accel/tcg/tcg-accel-ops-rr.h +++ b/accel/tcg/tcg-accel-ops-rr.h @@ -16,7 +16,9 @@ void rr_kick_vcpu_thread(CPUState *unused); bool rr_create_vcpu_thread_precheck(CPUState *cpu); -/* start the round robin vcpu thread */ -void rr_start_vcpu_thread(CPUState *cpu); +void rr_create_vcpu_thread_postcheck(CPUState *cpu); +bool rr_destroy_vcpu_thread_precheck(CPUState *cpu); + +void *rr_vcpu_thread_fn(void *arg); #endif /* TCG_CPUS_RR_H */ diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index d2181ea1e5..127dd6fee5 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -95,11 +95,13 @@ void tcg_handle_interrupt(CPUState *cpu, int mask) static void tcg_accel_ops_init(AccelOpsClass *ops) { if (qemu_tcg_mttcg_enabled()) { - ops->create_vcpu_thread = mttcg_start_vcpu_thread; + ops->vcpu_thread_fn = mttcg_vcpu_thread_fn; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt; } else { - ops->create_vcpu_thread = rr_start_vcpu_thread; + ops->vcpu_thread_fn = rr_vcpu_thread_fn; + ops->create_vcpu_thread_precheck = rr_create_vcpu_thread_precheck; + ops->create_vcpu_thread_postcheck = rr_create_vcpu_thread_postcheck; ops->kick_vcpu_thread = rr_kick_vcpu_thread; if (icount_enabled()) { diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 69aa7d018b..ef40f626e2 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -219,7 +219,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = dummy_start_vcpu_thread; + ops->vcpu_thread_fn = dummy_vcpu_thread_fn; } static const TypeInfo xen_accel_ops_type = { diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 26b542d35c..caf337f61f 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -30,7 +30,8 @@ struct AccelOpsClass { bool (*cpus_are_resettable)(void); - void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ + const char *thread_name; + void *(*vcpu_thread_fn)(void *arg); /* MANDATORY NON-NULL */ /* If non-NULL, return whether common vCPU thread must be created */ bool (*create_vcpu_thread_precheck)(CPUState *cpu); void (*create_vcpu_thread_postcheck)(CPUState *cpu); diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index b5c87d48b3..bf5629c58f 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -9,8 +9,8 @@ void cpus_register_accel(const AccelOpsClass *i); /* accel/dummy-cpus.c */ -/* Create a dummy vcpu for AccelOpsClass->create_vcpu_thread */ -void dummy_start_vcpu_thread(CPUState *); +/* Create a dummy vcpu for AccelOpsClass->vcpu_thread_fn */ +void *dummy_vcpu_thread_fn(void *arg); /* interface available for cpus accelerator threads */ diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 857e2081ba..cf430ac486 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -601,6 +601,22 @@ void resume_all_vcpus(void) } } +static void common_vcpu_thread_create(CPUState *cpu) +{ + char thread_name[VCPU_THREAD_NAME_SIZE]; + + cpu->thread = g_new0(QemuThread, 1); + cpu->halt_cond = g_new0(QemuCond, 1); + qemu_cond_init(cpu->halt_cond); + snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/%s", + cpu->cpu_index, cpus_accel->thread_name ?: "DUMMY"); + qemu_thread_create(cpu->thread, thread_name, cpus_accel->vcpu_thread_fn, + cpu, QEMU_THREAD_JOINABLE); +#ifdef _WIN32 + cpu->hThread = qemu_thread_get_handle(cpu->thread); +#endif +} + void cpu_remove_sync(CPUState *cpu) { cpu->stop = true; @@ -614,7 +630,7 @@ void cpu_remove_sync(CPUState *cpu) void cpus_register_accel(const AccelOpsClass *ops) { assert(ops != NULL); - assert(ops->create_vcpu_thread != NULL); /* mandatory */ + assert(ops->vcpu_thread_fn != NULL); /* mandatory */ cpus_accel = ops; } @@ -636,10 +652,11 @@ void qemu_init_vcpu(CPUState *cpu) } /* accelerators all implement the AccelOpsClass */ - g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL); + g_assert(cpus_accel != NULL && cpus_accel->vcpu_thread_fn != NULL); + if (cpus_accel->create_vcpu_thread_precheck == NULL || cpus_accel->create_vcpu_thread_precheck(cpu)) { - cpus_accel->create_vcpu_thread(cpu); + common_vcpu_thread_create(cpu); } if (cpus_accel->create_vcpu_thread_postcheck) { cpus_accel->create_vcpu_thread_postcheck(cpu); diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c index 18114fe34d..2fc2a9b8a4 100644 --- a/target/i386/hax/hax-accel-ops.c +++ b/target/i386/hax/hax-accel-ops.c @@ -57,28 +57,12 @@ static void *hax_cpu_thread_fn(void *arg) return NULL; } -static void hax_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); - - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -#ifdef _WIN32 - cpu->hThread = qemu_thread_get_handle(cpu->thread); -#endif -} - static void hax_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = hax_start_vcpu_thread; + ops->thread_name = "HAX"; + ops->vcpu_thread_fn = hax_cpu_thread_fn; ops->kick_vcpu_thread = hax_kick_vcpu_thread; ops->synchronize_post_reset = hax_cpu_synchronize_post_reset; diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index 6c46101ac1..a6dc73aa35 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -60,19 +60,6 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) return NULL; } -static void nvmm_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/NVMM", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, qemu_nvmm_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -} - /* * Abort the call to run the virtual processor by another thread, and to * return the control to that thread. @@ -87,7 +74,9 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = nvmm_start_vcpu_thread; + ops->thread_name = "NVMM"; + ops->vcpu_thread_fn = qemu_nvmm_cpu_thread_fn; + ops->kick_vcpu_thread = nvmm_kick_vcpu_thread; ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset; diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index dd2a9f7657..6498eb2060 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -60,22 +60,6 @@ static void *whpx_cpu_thread_fn(void *arg) return NULL; } -static void whpx_start_vcpu_thread(CPUState *cpu) -{ - char thread_name[VCPU_THREAD_NAME_SIZE]; - - cpu->thread = g_new0(QemuThread, 1); - cpu->halt_cond = g_new0(QemuCond, 1); - qemu_cond_init(cpu->halt_cond); - snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX", - cpu->cpu_index); - qemu_thread_create(cpu->thread, thread_name, whpx_cpu_thread_fn, - cpu, QEMU_THREAD_JOINABLE); -#ifdef _WIN32 - cpu->hThread = qemu_thread_get_handle(cpu->thread); -#endif -} - static void whpx_kick_vcpu_thread(CPUState *cpu) { if (!qemu_cpu_is_self(cpu)) { @@ -92,7 +76,9 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); - ops->create_vcpu_thread = whpx_start_vcpu_thread; + ops->thread_name = "WHPX"; + ops->vcpu_thread_fn = whpx_cpu_thread_fn; + ops->kick_vcpu_thread = whpx_kick_vcpu_thread; ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle; From patchwork Wed Mar 23 17:17:48 2022 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: 12789990 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 D1218C433EF for ; Wed, 23 Mar 2022 17:25:04 +0000 (UTC) Received: from localhost ([::1]:43048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4jH-00008b-Si for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:25:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4eR-0006dF-P3 for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:03 -0400 Received: from [2607:f8b0:4864:20::1031] (port=53029 helo=mail-pj1-x1031.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4eQ-0004lI-3J for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:03 -0400 Received: by mail-pj1-x1031.google.com with SMTP id v4so2381164pjh.2 for ; Wed, 23 Mar 2022 10:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f+HL4Abo/9emIoVYr4nPcZWANTfk8HbxwtFhwWh4T4E=; b=R38CVVHJgH8kHmGn0ZOyhoWZ33CV6mzkknIiqbfMkEd3nlYmXum5LYE5EuR9nOh5dV 4p+1F+9RocXuE6X/etkgzAlBdiSWWmatjKQnx2IG0DXq/5XQUfkek0cJmgKz3CvRAv+Q ZEQD4UjM+CuFPFnvkD7N3P9I3mXgm6KY1NLl24qU0ZpnRER1x6XTt68YoiVIlyjwivDY O6oJvDcjzbgtgV5VVYi1YxOK5p8sfe9NSUl24zEhnSJ+u/RzIPghmhV5VRqXDLHTZfDz 1fSHXii1iS47EJJoenarBJh84GnRVtK24aTa2pye2VI1SSKFMWmBWKuqZTE/MxejwKcS YLCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f+HL4Abo/9emIoVYr4nPcZWANTfk8HbxwtFhwWh4T4E=; b=EtPb4GFcQd+5imaEc+xD2zLhMxfutPm06udDGP83WVqhwnfYUV2l2KkCa4Sf5Vzm8G kGJwtH/vNhOpqyTq7H/aUbpbD4YCvgX5fhJLNbqeoWzNNm2ExCAJxtCXnwTeTglR6IZC 7bknDQobLxyPKe7hbjd1VMuRSMaeTmCI+BSPFlRtvH+k6WYbAU3mwKA/F2AN6FIeH01r CKUGySIB6OqncdMNI2swedOLyJW99niZXHy4oWMCmBB8HMwedkyZ2w3EMvN93849Yh6t TlCF3uPADFGQlkql7F9/hJLPdpK05N+KcgXDnroGIcwvsBgAJiUAX0RwjqHWwcLy8XpG vZHA== X-Gm-Message-State: AOAM533TbjOB8Snh1HSkQ1/p+sJoOTwBXRRZ2gh0XBdZ57oton52wpKH 0JqT7woU7APhSZn2xKtE19zq3n0TUko= X-Google-Smtp-Source: ABdhPJwUGIANIvoDBDf1d6wuhMbglFjfjHX2yL7VBu0eJlXm38w4pEE/zj+JRqSDdW4aqPv9Y3LI/A== X-Received: by 2002:a17:90a:8d85:b0:1b8:a215:e3e4 with SMTP id d5-20020a17090a8d8500b001b8a215e3e4mr12881119pjo.175.1648056000652; Wed, 23 Mar 2022 10:20:00 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id oo17-20020a17090b1c9100b001bf0ccc59c2sm7189967pjb.16.2022.03.23.10.19.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:20:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 10/13] accel-ops: Introduce common_vcpu_thread_destroy() and .precheck handler Date: Wed, 23 Mar 2022 18:17:48 +0100 Message-Id: <20220323171751.78612-11-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1031 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Introduce an empty common_vcpu_thread_destroy() function, and provide a AccelOpsClass::destroy_vcpu_thread_precheck() callback so accelerators can choose whether to call common_vcpu_thread_destroy. Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/accel-ops.h | 2 ++ softmmu/cpus.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index caf337f61f..b47f6de3f9 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -35,6 +35,8 @@ struct AccelOpsClass { /* If non-NULL, return whether common vCPU thread must be created */ bool (*create_vcpu_thread_precheck)(CPUState *cpu); void (*create_vcpu_thread_postcheck)(CPUState *cpu); + /* If non-NULL, return whether common vCPU thread must be destroyed */ + bool (*destroy_vcpu_thread_precheck)(CPUState *cpu); void (*kick_vcpu_thread)(CPUState *cpu); bool (*cpu_thread_is_idle)(CPUState *cpu); diff --git a/softmmu/cpus.c b/softmmu/cpus.c index cf430ac486..37325b3b8d 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -617,6 +617,10 @@ static void common_vcpu_thread_create(CPUState *cpu) #endif } +static void common_vcpu_thread_destroy(CPUState *cpu) +{ +} + void cpu_remove_sync(CPUState *cpu) { cpu->stop = true; @@ -625,6 +629,11 @@ void cpu_remove_sync(CPUState *cpu) qemu_mutex_unlock_iothread(); qemu_thread_join(cpu->thread); qemu_mutex_lock_iothread(); + + if (cpus_accel->destroy_vcpu_thread_precheck == NULL + || cpus_accel->destroy_vcpu_thread_precheck(cpu)) { + common_vcpu_thread_destroy(cpu); + } } void cpus_register_accel(const AccelOpsClass *ops) From patchwork Wed Mar 23 17:17:49 2022 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: 12789996 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 E0CFEC433EF for ; Wed, 23 Mar 2022 17:32:38 +0000 (UTC) Received: from localhost ([::1]:59432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4qb-0003Wn-Tk for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:32:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4ed-00078G-AG for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:15 -0400 Received: from [2607:f8b0:4864:20::1031] (port=54111 helo=mail-pj1-x1031.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4eb-000595-RZ for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:14 -0400 Received: by mail-pj1-x1031.google.com with SMTP id bx5so2371181pjb.3 for ; Wed, 23 Mar 2022 10:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MsX1ZkecFTiI7JDWgHH13CsFxdulVP/faYY6Ho3L9NU=; b=WiW4MrCr//Z88g+PXSFrPmTGMoceaVHESi73affp7lvaELZrmIQzuoUOKQHWdxEGR1 NO8SV9ARJQk3egmkmUIPnlIThomv8Lit2KqxTc39Z2U2FpA9dGoRpDFaiV7jNk13qUza 7zTfMC78Yc9mIXAGObaiUFBGpvB4UERocSaZSl7rhPntj8Gi1+FoC3nfqPiNjeGgZmPh TRMYKUG2CwwJHNw1Jqgv/qe0wIDn26xQq8oJkIoqzDAj6WG0NmljbJFdXSn/JSJOqJKV ad67bhyOCOEqsfPGFGJ1vRiL63Vd3PXt65wKeeSdZ40GLF1FXc9OTqtSP/xBz7j9+tjc hyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MsX1ZkecFTiI7JDWgHH13CsFxdulVP/faYY6Ho3L9NU=; b=EFYepmxq4mZwIfegN6HqTRjHc08lW7PUk51XYcjB0CTDH1nNwqUU2AmUoLdMS0fkM+ ts8qM5mNYaNFBfve3WK6vh7apVwU7D2qIIFT5fEitjlewNMiKJjwVeK/hI4MWiN2DCCW KqPjdiWk73qIxdnoynjjFISYU3Ng7VMSrtsHLnWeth8IsGil9Zufs/q8YMmi3gw5ydEZ t6nfvjFjIhZZI/AfY+QKbaftgMMyWYT3vvdHJ63k0pkCHnDdW3Ip8sOGC/ll9EJJxFdE DDA8ZWApf0rLkZc0Yr6mvJb96c3gsiPO8+jQg5vW748WUD6waA3HAz7g1x25T9gdo2e/ mlzg== X-Gm-Message-State: AOAM532CE2328nl5rngJVMVhkNkj9ToWuUkGsB3szlh+/8RJUOVZ8dE7 K4MhR4h/EFUZH6bmWU7nSLRzCvDFenM= X-Google-Smtp-Source: ABdhPJyjcb2sZqeH87rq3zUZWSVN13XuvvacgYKtkqz+CZvHLPq51GDtssoIVmULExUOmBBtc3gkrA== X-Received: by 2002:a17:90a:5291:b0:1bb:ef4d:947d with SMTP id w17-20020a17090a529100b001bbef4d947dmr12885297pjh.243.1648056012464; Wed, 23 Mar 2022 10:20:12 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id d24-20020a637358000000b003823aefde04sm336971pgn.86.2022.03.23.10.20.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:20:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 11/13] accel/tcg: Add rr_destroy_vcpu_thread_precheck() Date: Wed, 23 Mar 2022 18:17:49 +0100 Message-Id: <20220323171751.78612-12-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1031 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé TCG/RR is special and creates a single vCPU. It only have to release its resources once. Implement the .precheck() for that purpose. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops-rr.c | 9 +++++++++ accel/tcg/tcg-accel-ops.c | 1 + 2 files changed, 10 insertions(+) diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 006b787289..6fe8e20356 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -295,3 +295,12 @@ void rr_create_vcpu_thread_postcheck(CPUState *cpu) cpu->created = true; } } + +bool rr_destroy_vcpu_thread_precheck(CPUState *cpu) +{ + if (single_tcg_cpu_thread) { + single_tcg_cpu_thread = NULL; + return true; + } + return false; +} diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 127dd6fee5..0b0dbcc47a 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -102,6 +102,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops) ops->vcpu_thread_fn = rr_vcpu_thread_fn; ops->create_vcpu_thread_precheck = rr_create_vcpu_thread_precheck; ops->create_vcpu_thread_postcheck = rr_create_vcpu_thread_postcheck; + ops->destroy_vcpu_thread_precheck = rr_destroy_vcpu_thread_precheck; ops->kick_vcpu_thread = rr_kick_vcpu_thread; if (icount_enabled()) { From patchwork Wed Mar 23 17:17:50 2022 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: 12789993 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 1012DC433EF for ; Wed, 23 Mar 2022 17:28:53 +0000 (UTC) Received: from localhost ([::1]:50224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4my-0005SA-4P for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:28:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4ep-0007Pi-Uc for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:28 -0400 Received: from [2607:f8b0:4864:20::1035] (port=53035 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4eo-0005LC-DI for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:27 -0400 Received: by mail-pj1-x1035.google.com with SMTP id v4so2382485pjh.2 for ; Wed, 23 Mar 2022 10:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ed6iY8pMEzMkAOvdT6TEMCudwvjmYJcGMMpCaTIv/yU=; b=RyKgoe5HgJCJpFJvPNUJVGX9nExg70mZzCcSsKHkmRw2HUwXJBO+ViJY8Cg1JFjM2H G0OgG2uMd3kfN/cqwIfkckDdV0ro4mD03PEFsBMGgIFVHwNisdMFtViW7UEW0QokyJ18 /1sVuSemm0/QC9FQEH4gtz9xLl3QWzTjGmS6U6thAkmdoZhRJ3tRO1ZYnvykNZfNtAY7 hsT8RrSJ2JYd++oXi25BCbjpyRPtyPQS4TfqKZj1OE2g3DX3iSvXB/fb6naDgvDbxoVg v/pUtMjxZ1idxkWkbRDhcEj5lEdEAR20mwKPOE/HmsGKZUkhhIAWrUbX6M9OiZDfFKNS ulEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ed6iY8pMEzMkAOvdT6TEMCudwvjmYJcGMMpCaTIv/yU=; b=eCso+Glf8Wzw/I+a5qZx806bfhPRU0EX5F4SFRCgPl7vMEJNEFIkyCtG0ZmOQ3bNUE boGxu/DsScuXSeiXo1o4b6DKfp8BLjCOxZv8njkUI/oG2obKufe4KOnk2ok/kwrRRSzl 7e/bh4IqGusDqPwx2Lj/z4L7gcxnuAqRE8orpbUQJAeFUOOQC57HBJoExuU1XvZnc6nA MeyDITx4oshec+swsqVF0UmjwyXB4weqdXabNtRyOWSr29xlHX5f+/KyyEdAlXt1s0gB FHck8dgiBLed8A1VyEhz3F5YVEa6wtjXCXYxHJQpAClgdW5EAhHHJjkxEOuSSNxPvsEi 9PQw== X-Gm-Message-State: AOAM532WXerizLB/+bmbAW/iwJukHKPvqeuY4VA4O58TO6xjcOKqaYuT RZAclwhDuw6isECpmP5NO6Apy6Gpp50= X-Google-Smtp-Source: ABdhPJwqx6x4zfaaNXs3hip1MrGQWDzMJ1aziOlNPCMVNNhEzttDkRqQAwuDm1jVkFyWnxpwXzRJYA== X-Received: by 2002:a17:903:2406:b0:14d:6447:990c with SMTP id e6-20020a170903240600b0014d6447990cmr1048970plo.22.1648056024958; Wed, 23 Mar 2022 10:20:24 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id o24-20020a17090a5b1800b001c6aaafa5fbsm282644pji.24.2022.03.23.10.20.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:20:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 12/13] softmmu/cpus: Free cpu->thread in generic_destroy_vcpu_thread() Date: Wed, 23 Mar 2022 18:17:50 +0100 Message-Id: <20220323171751.78612-13-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda Free cpu->thread in a new AccelOpsClass::destroy_vcpu_thread() handler generic_destroy_vcpu_thread(). vCPU hotunplug related leak reported by Valgrind: ==102631== 8 bytes in 1 blocks are definitely lost in loss record 1,037 of 8,555 ==102631== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==102631== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==102631== by 0x92443A: kvm_start_vcpu_thread (kvm-accel-ops.c:68) ==102631== by 0x4505C2: qemu_init_vcpu (cpus.c:643) ==102631== by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520) ==102631== by 0x9344A7: device_set_realized (qdev.c:531) ==102631== by 0x93E329: property_set_bool (object.c:2273) ==102631== by 0x93C2F8: object_property_set (object.c:1408) ==102631== by 0x940796: object_property_set_qobject (qom-qobject.c:28) ==102631== by 0x93C663: object_property_set_bool (object.c:1477) ==102631== by 0x933D3B: qdev_realize (qdev.c:333) ==102631== by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda Message-Id: <20220321141409.3112932-3-mark.kanda@oracle.com> Signed-off-by: Philippe Mathieu-Daudé --- softmmu/cpus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 37325b3b8d..efa8397f04 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -619,6 +619,7 @@ static void common_vcpu_thread_create(CPUState *cpu) static void common_vcpu_thread_destroy(CPUState *cpu) { + g_free(cpu->thread); } void cpu_remove_sync(CPUState *cpu) From patchwork Wed Mar 23 17:17:51 2022 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: 12790002 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 A6DEAC433F5 for ; Wed, 23 Mar 2022 17:33:38 +0000 (UTC) Received: from localhost ([::1]:33698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX4rZ-0005Gz-MQ for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 13:33:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX4f4-0007UE-29 for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:42 -0400 Received: from [2607:f8b0:4864:20::431] (port=36788 helo=mail-pf1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX4f2-0005aE-1E for qemu-devel@nongnu.org; Wed, 23 Mar 2022 13:20:41 -0400 Received: by mail-pf1-x431.google.com with SMTP id z16so1991646pfh.3 for ; Wed, 23 Mar 2022 10:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=32I90XyrSsgFhoTvAz7kFHmgBFJVrEU2lmj8L6zrA7w=; b=HziQehOw9rA6WaAjt6GWtN96OEZQKNeqtt8BUYKzQhy7osdWurjWlBG20QGQW/EB+F jeu4GS9/mQNcxaXFiYXQHD+Newqzq1veJVbG2jRb7R8WXmdqG/gVdrZDjIlDxW4lRXOq I71naYjPm4YaQCCMtZQaseOvo60Lz/IkNWzSHUBWsfnNXC2oOABAKojB2mfg+D9g7D1D aCifnKvwu9gBP/efpCWO8b9KL2IWYDxFdNbknFbXsjBT6YGAcCikhEVWZMzFhjo4Dyoi m5OUOkfn3o+MT9iQ4opD1tk8fsbzJgw5Qcb9c/JxYjHFhN6Q4eH03QkTyrPcQEV21Vlq Vusg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=32I90XyrSsgFhoTvAz7kFHmgBFJVrEU2lmj8L6zrA7w=; b=y4PkJc+VdN5aZVYHKiU0b8BrE9DZvACuLPAARHUPltd27UvJMVEYXAk4iu7cHki/rA xAuT6BP9+gfyh9UfNW7uMrsWAyzdM011bfvbHZ//EgRf3RG/XdbsDVq8KSlVSAUE+8+1 kBEKiOleLkK7JKgqmMV2I7VD5Xqad36pbpV9+vbFBf30iHjmG9tZ5O8BPlIw2GxASyHr v5XrwQyrqEGxiXHVo0LXZZT15HsEN22cVUqBvOidgj7h56kJTsjlvjxvIKrooOXgCD2K O+Es2jimhUTuPTRM69K1I4tA5Utq56G2/1X61dzcvsoWpnsyXpyUgsnOMvlIYrzk1UPU hFZg== X-Gm-Message-State: AOAM533mEOB5kFveleq8aciYuDgN9/5X3R/1xYbmvJGQUQeHE7tdCxAJ 30JHf7bYqdbsUWfqLuFVeAW4OwSiwzo= X-Google-Smtp-Source: ABdhPJzitqpHPUzN1FOlO6Xy6wxyKTy6324HAUZa9Y29UTDRmfk9C7LuqvIVu5doI3n8WNcv+vf6iw== X-Received: by 2002:a63:1e52:0:b0:380:ae84:256e with SMTP id p18-20020a631e52000000b00380ae84256emr758991pgm.84.1648056037806; Wed, 23 Mar 2022 10:20:37 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id y12-20020a17090a784c00b001c6bdafc995sm5775028pjl.3.2022.03.23.10.20.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:20:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 13/13] softmmu/cpus: Free cpu->halt_cond in generic_destroy_vcpu_thread() Date: Wed, 23 Mar 2022 18:17:51 +0100 Message-Id: <20220323171751.78612-14-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::431 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Paul Durrant , Peter Xu , Yanan Wang , haxm-team@intel.com, Colin Xu , Stefano Stabellini , David Hildenbrand , Kamil Rytarowski , Reinoud Zandijk , Anthony Perard , xen-devel@lists.xenproject.org, Laurent Vivier , Thomas Huth , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Sunil Muthuswamy , Eduardo Habkost , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wenchao Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda vCPU hotunplug related leak reported by Valgrind: ==102631== 56 bytes in 1 blocks are definitely lost in loss record 5,089 of 8,555 ==102631== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==102631== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==102631== by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69) ==102631== by 0x4505C2: qemu_init_vcpu (cpus.c:643) ==102631== by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520) ==102631== by 0x9344A7: device_set_realized (qdev.c:531) ==102631== by 0x93E329: property_set_bool (object.c:2273) ==102631== by 0x93C2F8: object_property_set (object.c:1408) ==102631== by 0x940796: object_property_set_qobject (qom-qobject.c:28) ==102631== by 0x93C663: object_property_set_bool (object.c:1477) ==102631== by 0x933D3B: qdev_realize (qdev.c:333) ==102631== by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda Message-Id: <20220321141409.3112932-4-mark.kanda@oracle.com> Signed-off-by: Philippe Mathieu-Daudé --- softmmu/cpus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index efa8397f04..23bed29545 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -620,6 +620,7 @@ static void common_vcpu_thread_create(CPUState *cpu) static void common_vcpu_thread_destroy(CPUState *cpu) { g_free(cpu->thread); + g_free(cpu->halt_cond); } void cpu_remove_sync(CPUState *cpu)