From nobody Sat Apr 27 14:59:05 2024 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; 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 1518206130699303.28062790315414; Fri, 9 Feb 2018 11:55:30 -0800 (PST) Received: from localhost ([::1]:34723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekEld-0003M0-Sg for importer@patchew.org; Fri, 09 Feb 2018 14:55:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekEjC-0001Le-2K for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekEj7-0002yl-Q3 for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57672 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekEj7-0002xt-LL for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE1FAEAE83; Fri, 9 Feb 2018 19:52:49 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94B48100F9F3; Fri, 9 Feb 2018 19:52:46 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 9 Feb 2018 20:52:37 +0100 Message-Id: <20180209195239.16048-2-david@redhat.com> In-Reply-To: <20180209195239.16048-1-david@redhat.com> References: <20180209195239.16048-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 09 Feb 2018 19:52:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 09 Feb 2018 19:52:49 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v1 1/3] cpus: properly inititalize CPU > 1 under single-threaded TCG 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: Paolo Bonzini , Richard Henderson , David Hildenbrand , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All but the first CPU are currently not fully inititalized (e.g. cpu->created is never set). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- cpus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpus.c b/cpus.c index f298b659f4..ade1651032 100644 --- a/cpus.c +++ b/cpus.c @@ -1863,6 +1863,9 @@ static void qemu_tcg_init_vcpu(CPUState *cpu) /* For non-MTTCG cases we share the thread */ cpu->thread =3D single_tcg_cpu_thread; cpu->halt_cond =3D single_tcg_halt_cond; + cpu->thread_id =3D first_cpu->thread_id; + cpu->can_do_io =3D 1; + cpu->created =3D true; } } =20 --=20 2.14.3 From nobody Sat Apr 27 14:59:05 2024 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; 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 1518206126661448.98378171614206; Fri, 9 Feb 2018 11:55:26 -0800 (PST) Received: from localhost ([::1]:34721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekElZ-0003Gh-Jr for importer@patchew.org; Fri, 09 Feb 2018 14:55:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekEjC-0001LZ-1g for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekEj7-0002yN-64 for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45324 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekEj7-0002xv-0G for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7A968182D3D; Fri, 9 Feb 2018 19:52:51 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48146100F9F3; Fri, 9 Feb 2018 19:52:50 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 9 Feb 2018 20:52:38 +0100 Message-Id: <20180209195239.16048-3-david@redhat.com> In-Reply-To: <20180209195239.16048-1-david@redhat.com> References: <20180209195239.16048-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 09 Feb 2018 19:52:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 09 Feb 2018 19:52:51 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v1 2/3] 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: Paolo Bonzini , Richard Henderson , David Hildenbrand , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Richard Henderson --- cpus.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/cpus.c b/cpus.c index ade1651032..22ab15840f 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 2.14.3 From nobody Sat Apr 27 14:59:05 2024 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; 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 1518206238296823.5085636687115; Fri, 9 Feb 2018 11:57:18 -0800 (PST) Received: from localhost ([::1]:34898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekEnN-000545-Ca for importer@patchew.org; Fri, 09 Feb 2018 14:57:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekEjC-0001Lb-1i for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekEj8-0002zD-7L for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57242 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekEj8-0002yp-2D for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:52:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91A3940FB635; Fri, 9 Feb 2018 19:52:53 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 217A4100F9F3; Fri, 9 Feb 2018 19:52:51 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 9 Feb 2018 20:52:39 +0100 Message-Id: <20180209195239.16048-4-david@redhat.com> In-Reply-To: <20180209195239.16048-1-david@redhat.com> References: <20180209195239.16048-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 09 Feb 2018 19:52:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 09 Feb 2018 19:52:53 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v1 3/3] cpus: CPU threads are always created initially for one CPU only 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: Paolo Bonzini , Richard Henderson , David Hildenbrand , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It can never happen for single-threaded TCG that we have more than one CPU in the list, while the first one has not been marked as "created". Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- cpus.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cpus.c b/cpus.c index 22ab15840f..2653a89e88 100644 --- a/cpus.c +++ b/cpus.c @@ -1383,11 +1383,9 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); =20 - CPU_FOREACH(cpu) { - cpu->thread_id =3D qemu_get_thread_id(); - cpu->created =3D true; - cpu->can_do_io =3D 1; - } + cpu->thread_id =3D qemu_get_thread_id(); + cpu->created =3D true; + cpu->can_do_io =3D 1; qemu_cond_signal(&qemu_cpu_cond); =20 /* wait for initial kick-off after machine start */ --=20 2.14.3