From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU2IH-0003ye-Eu for qemu-devel@nongnu.org; Mon, 24 Aug 2015 20:40:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZU2IE-0005vr-5B for qemu-devel@nongnu.org; Mon, 24 Aug 2015 20:40:53 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:56772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU2IE-0005vO-0s for qemu-devel@nongnu.org; Mon, 24 Aug 2015 20:40:50 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 870EC20BA2 for ; Mon, 24 Aug 2015 20:40:48 -0400 (EDT) From: "Emilio G. Cota" Date: Mon, 24 Aug 2015 20:41:07 -0400 Message-Id: <1440463270-11819-1-git-send-email-cota@braap.org> In-Reply-To: <55DA6D53.2080709@redhat.com> References: <55DA6D53.2080709@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] cpus: add qemu_cpu_thread_init_common() to avoid code duplication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pbonzini@redhat.com Cc: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, guillaume.delbergue@greensocs.com, alex.bennee@linaro.org, Frederic Konrad Signed-off-by: Emilio G. Cota --- cpus.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/cpus.c b/cpus.c index 81dda93..fd9e903 100644 --- a/cpus.c +++ b/cpus.c @@ -922,18 +922,23 @@ static void qemu_kvm_wait_io_event(CPUState *cpu) qemu_wait_io_event_common(cpu); } +/* call with BQL held */ +static void qemu_cpu_thread_init_common(CPUState *cpu) +{ + rcu_register_thread(); + qemu_thread_get_self(cpu->thread); + cpu->thread_id = qemu_get_thread_id(); + cpu->can_do_io = 1; + current_cpu = cpu; +} + static void *qemu_kvm_cpu_thread_fn(void *arg) { CPUState *cpu = arg; int r; - rcu_register_thread(); - qemu_mutex_lock_iothread(); - qemu_thread_get_self(cpu->thread); - cpu->thread_id = qemu_get_thread_id(); - cpu->can_do_io = 1; - current_cpu = cpu; + qemu_cpu_thread_init_common(cpu); r = kvm_init_vcpu(cpu); if (r < 0) { @@ -970,13 +975,8 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) sigset_t waitset; int r; - rcu_register_thread(); - qemu_mutex_lock_iothread(); - qemu_thread_get_self(cpu->thread); - cpu->thread_id = qemu_get_thread_id(); - cpu->can_do_io = 1; - current_cpu = cpu; + qemu_cpu_thread_init_common(cpu); sigemptyset(&waitset); sigaddset(&waitset, SIG_IPI); @@ -1009,15 +1009,9 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *cpu = arg; - rcu_register_thread(); - qemu_mutex_lock_iothread(); - qemu_thread_get_self(cpu->thread); - - cpu->thread_id = qemu_get_thread_id(); + qemu_cpu_thread_init_common(cpu); cpu->created = true; - cpu->can_do_io = 1; - current_cpu = cpu; qemu_cond_signal(&qemu_cpu_cond); -- 1.9.1