From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmpD7-000083-3S for qemu-devel@nongnu.org; Mon, 27 Apr 2015 16:00:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmpD5-0007YD-V4 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 16:00:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmpD5-0007Xx-FP for qemu-devel@nongnu.org; Mon, 27 Apr 2015 16:00:55 -0400 From: Eduardo Habkost Date: Mon, 27 Apr 2015 17:00:33 -0300 Message-Id: <1430164833-21006-4-git-send-email-ehabkost@redhat.com> In-Reply-To: <1430164833-21006-1-git-send-email-ehabkost@redhat.com> References: <1430164833-21006-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Cc: Igor Mammedov , Paolo Bonzini Instead of initializing cpu->as, cpu->thread_id, and reloading memory map while holding cpu_list_lock(), do it earlier, before locking the CPU list and initializing cpu_index. This allows the code handling cpu_index and global CPU list to be isolated from the rest. Cc: Paolo Bonzini Signed-off-by: Eduardo Habkost --- Changes v1 -> v2: * Rebased and moved the new cpu_reload_memory_map(cpu) line * Reviewed-by from Igor not kept because more complex code is now being moved --- exec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/exec.c b/exec.c index 8d5d844..e2c438a 100644 --- a/exec.c +++ b/exec.c @@ -537,6 +537,12 @@ void cpu_exec_init(CPUArchState *env) CPUState *some_cpu; int cpu_index; +#ifndef CONFIG_USER_ONLY + cpu->as = &address_space_memory; + cpu->thread_id = qemu_get_thread_id(); + cpu_reload_memory_map(cpu); +#endif + #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif @@ -545,11 +551,6 @@ void cpu_exec_init(CPUArchState *env) cpu_index++; } cpu->cpu_index = cpu_index; -#ifndef CONFIG_USER_ONLY - cpu->as = &address_space_memory; - cpu->thread_id = qemu_get_thread_id(); - cpu_reload_memory_map(cpu); -#endif QTAILQ_INSERT_TAIL(&cpus, cpu, node); #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); -- 2.1.0