qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Paul Durrant" <paul@xen.org>, "Peter Xu" <peterx@redhat.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	haxm-team@intel.com, "Colin Xu" <colin.xu@intel.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"David Hildenbrand" <david@redhat.com>,
	"Kamil Rytarowski" <kamil@netbsd.org>,
	"Reinoud Zandijk" <reinoud@netbsd.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	xen-devel@lists.xenproject.org,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Cameron Esfahani" <dirty@apple.com>,
	"Roman Bolshakov" <r.bolshakov@yadro.com>,
	"Sunil Muthuswamy" <sunilmut@microsoft.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Wenchao Wang" <wenchao.wang@intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v4 11/13] accel/tcg: Add rr_destroy_vcpu_thread_precheck()
Date: Wed, 23 Mar 2022 18:17:49 +0100	[thread overview]
Message-ID: <20220323171751.78612-12-philippe.mathieu.daude@gmail.com> (raw)
In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com>

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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é <f4bug@amsat.org>
---
 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()) {
-- 
2.35.1



  parent reply	other threads:[~2022-03-23 17:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 17:17 [PATCH v4 00/13] accel: Fix vCPU memory leaks Philippe Mathieu-Daudé
2022-03-23 17:17 ` [PATCH v4 01/13] cpu: Free cpu->cpu_ases in cpu_address_space_destroy() Philippe Mathieu-Daudé
2022-03-23 18:56   ` Philippe Mathieu-Daudé
2022-03-23 19:14     ` Mark Kanda
2022-03-23 17:17 ` [PATCH v4 02/13] target/i386/kvm: Free xsave_buf when destroying vCPU Philippe Mathieu-Daudé
2022-03-23 21:15   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 03/13] target/i386/hvf: Free resources when vCPU is destroyed Philippe Mathieu-Daudé
2022-03-23 21:19   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 04/13] accel/hvf: Remove pointless assertion Philippe Mathieu-Daudé
2022-03-23 17:17 ` [PATCH v4 05/13] accel/tcg: Init TCG cflags in vCPU thread handler Philippe Mathieu-Daudé
2022-03-23 21:29   ` Richard Henderson
2022-06-20 20:04   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 06/13] accel/tcg: Reorganize tcg_accel_ops_init() Philippe Mathieu-Daudé
2022-03-23 21:31   ` Richard Henderson
2022-06-20 20:09   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / postcheck handlers Philippe Mathieu-Daudé
2022-03-23 22:26   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 08/13] accel/tcg: Extract rr_create_vcpu_thread_precheck() Philippe Mathieu-Daudé
2022-03-23 17:17 ` [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create() Philippe Mathieu-Daudé
2022-03-23 22:11   ` Richard Henderson
2022-03-23 22:15   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 10/13] accel-ops: Introduce common_vcpu_thread_destroy() and .precheck handler Philippe Mathieu-Daudé
2022-03-23 22:31   ` Richard Henderson
2022-03-23 17:17 ` Philippe Mathieu-Daudé [this message]
2022-03-23 22:42   ` [PATCH v4 11/13] accel/tcg: Add rr_destroy_vcpu_thread_precheck() Richard Henderson
2022-03-23 17:17 ` [PATCH v4 12/13] softmmu/cpus: Free cpu->thread in generic_destroy_vcpu_thread() Philippe Mathieu-Daudé
2022-03-23 17:30   ` Mark Kanda
2022-03-23 22:42   ` Richard Henderson
2022-03-23 17:17 ` [PATCH v4 13/13] softmmu/cpus: Free cpu->halt_cond " Philippe Mathieu-Daudé
2022-03-23 22:43   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220323171751.78612-12-philippe.mathieu.daude@gmail.com \
    --to=philippe.mathieu.daude@gmail.com \
    --cc=anthony.perard@citrix.com \
    --cc=colin.xu@intel.com \
    --cc=david@redhat.com \
    --cc=dirty@apple.com \
    --cc=eduardo@habkost.net \
    --cc=f4bug@amsat.org \
    --cc=haxm-team@intel.com \
    --cc=kamil@netbsd.org \
    --cc=lvivier@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=reinoud@netbsd.org \
    --cc=richard.henderson@linaro.org \
    --cc=sstabellini@kernel.org \
    --cc=sunilmut@microsoft.com \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    --cc=wenchao.wang@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).