From nobody Sat Oct 25 09:08:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520342504382327.7130071788728; Tue, 6 Mar 2018 05:21:44 -0800 (PST) Received: from localhost ([::1]:55699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCXE-0006f8-DQ for importer@patchew.org; Tue, 06 Mar 2018 08:21:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCVJ-0004kq-Vv for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:19:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etCVJ-0006Bs-1K for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:19:41 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:53341) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1etCVI-0006BO-QX for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:19:40 -0500 Received: by mail-wm0-x244.google.com with SMTP id e194so3743636wmd.3 for ; Tue, 06 Mar 2018 05:19:40 -0800 (PST) Received: from 640k.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l38sm25652538wrc.96.2018.03.06.05.19.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 05:19:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=xjz0oM0shCZiDKncEfNZC6Nv4HNIWxzt3rlo6WWD6Mw=; b=J3/8UHw0mzCzeXvrPpgXqHlTDE9d3s6eVIBhe1DXAMvf/vXv/yjtI1mmiu6YHF/im2 u6CCoWuM9vfM/vIJZvyE+WE02TSxPr7EkU09nHbvyVTU+c3HvwVt+gYjNvwYfPnFcR3a 5S/Imw8BW6yf9AQEc4XDmkwvWuOxKiBKpRvrwxiOatBn74aGyf50pePRBpFxobUMdK1R kkbmuyWVYYjeQHB1xo37zpDLVJxbB0nLddeWs7YkKG/eEgtULzh93LAuKvFE5aooYlHR aH7v/atwHS5E5Dslm7KKgK79qGK+oaA8OAxT/2ajzEwtJ3anZbRi+HkDa1EiomTM65VO cHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=xjz0oM0shCZiDKncEfNZC6Nv4HNIWxzt3rlo6WWD6Mw=; b=BNZ3o7cZUI4W4iUQD5wbF0QmcPq58VwhAmcKaWI7WZxnen/2D65I5sdnerm+4on+eZ WIASAqWvclus+PBG5upaYhJiIsJRwirL6luA/Op/zA4bVOZSDq2qxnBa2q0nWWyZtg5b pArtoLu6jAE6LU7PxElrgYxXHbCWo7iyx+SvxEenD3wJb8U0d8Ac37/Z3V8S41xKrUrn E9YSRLZOxBIf/IF9jQrahywtD2b6p1tty/8wgeH680Sgx2bgt6FhPB4Efn4gTUdtgq0/ rbnr1B2C2BeXliFtcyNwRImE/mFgnqZwhROzhnD3ng39fYfTB7joie6d2dBFGKQSlZ9q HJwQ== X-Gm-Message-State: AElRT7GiM98SEz0QMXJUhuW2gym3qBmFBDZnoqCY1E0LYhrAvg7/e3TQ ni9iubCdWvEUJ6gC1NC2sqNKjcM/ X-Google-Smtp-Source: AG47ELsho3wyMtOJeJaJGe7z8L2jGkn9YXrF66fSUVr2VNwAdVXcn+gPSysVHBzL0Peb58WfhFkTfw== X-Received: by 10.28.48.11 with SMTP id w11mr12135664wmw.88.1520342379544; Tue, 06 Mar 2018 05:19:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 14:19:01 +0100 Message-Id: <1520342370-123606-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> References: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 05/34] cpus: wait for CPU creation at central place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We can now also wait for the CPU creation for single-threaded TCG, so we can move the waiting bits further out. Signed-off-by: David Hildenbrand Message-Id: <20180209195239.16048-3-david@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- cpus.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/cpus.c b/cpus.c index 970390b..bcfc0a4 100644 --- a/cpus.c +++ b/cpus.c @@ -1856,9 +1856,6 @@ static void qemu_tcg_init_vcpu(CPUState *cpu) #ifdef _WIN32 cpu->hThread =3D qemu_thread_get_handle(cpu->thread); #endif - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } else { /* For non-MTTCG cases we share the thread */ cpu->thread =3D single_tcg_cpu_thread; @@ -1884,9 +1881,6 @@ static void qemu_hax_start_vcpu(CPUState *cpu) #ifdef _WIN32 cpu->hThread =3D qemu_thread_get_handle(cpu->thread); #endif - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } =20 static void qemu_kvm_start_vcpu(CPUState *cpu) @@ -1900,9 +1894,6 @@ static void qemu_kvm_start_vcpu(CPUState *cpu) cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } =20 static void qemu_hvf_start_vcpu(CPUState *cpu) @@ -1921,9 +1912,6 @@ static void qemu_hvf_start_vcpu(CPUState *cpu) cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, qemu_hvf_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } =20 static void qemu_whpx_start_vcpu(CPUState *cpu) @@ -1940,9 +1928,6 @@ static void qemu_whpx_start_vcpu(CPUState *cpu) #ifdef _WIN32 cpu->hThread =3D qemu_thread_get_handle(cpu->thread); #endif - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } =20 static void qemu_dummy_start_vcpu(CPUState *cpu) @@ -1956,9 +1941,6 @@ static void qemu_dummy_start_vcpu(CPUState *cpu) cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, qemu_dummy_cpu_thread_fn,= cpu, QEMU_THREAD_JOINABLE); - while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } } =20 void qemu_init_vcpu(CPUState *cpu) @@ -1988,6 +1970,10 @@ void qemu_init_vcpu(CPUState *cpu) } else { qemu_dummy_start_vcpu(cpu); } + + while (!cpu->created) { + qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); + } } =20 void cpu_stop_current(void) --=20 1.8.3.1