Skip to contentSkip to conversation

cpu_exec_init() cleanups

PATCH Applied Eduardo Habkost 2 participants 5 messages Apr 27, 2015

lore
Share & tools
lore
#0 lore raw

cover cpu_exec_init() cleanups

Those patches were submitted and reviewed back in March, and I believe they can go through the qom-cpu tree.

Patch 3/3 had to be redone because of new code.

Eduardo Habkost (3):
cpu: No need to zero-initialize numa_node
cpu: Initialize breakpoint/watchpoint lists on cpu_common_initfn()
cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init

 exec.c    | 14 ++++++--------
 qom/cpu.c |  2 ++
 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/3 cpu: No need to zero-initialize numa_node

QOM objects are already zero-filled when instantiated, there's no need to explicitly set numa_node to 0.

---
 exec.c | 1 -
 1 file changed, 1 deletion(-)
exec.c +0 -1
index 874ecfc..3566d8f 100644
@@ -545,7 +545,6 @@ void cpu_exec_init(CPUArchState *env)
         cpu_index++;
     }
     cpu->cpu_index = cpu_index;
-    cpu->numa_node = 0;
     QTAILQ_INIT(&cpu->breakpoints);
     QTAILQ_INIT(&cpu->watchpoints);
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/3 cpu: Initialize breakpoint/watchpoint lists on cpu_common_initfn()

In reply to Eduardo Habkost

One small step in the simplification of cpu_exec_init().

---
 exec.c    | 2 --
 qom/cpu.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
exec.c +0 -2
index 3566d8f..8d5d844 100644
@@ -545,8 +545,6 @@ void cpu_exec_init(CPUArchState *env)
         cpu_index++;
     }
     cpu->cpu_index = cpu_index;
-    QTAILQ_INIT(&cpu->breakpoints);
-    QTAILQ_INIT(&cpu->watchpoints);
 #ifndef CONFIG_USER_ONLY
     cpu->as = &address_space_memory;
     cpu->thread_id = qemu_get_thread_id();
qom/cpu.c +2 -0
index 108bfa2..56c53a8 100644
@@ -313,6 +313,8 @@ static void cpu_common_initfn(Object *obj)
     CPUClass *cc = CPU_GET_CLASS(obj);
 
     cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
+    QTAILQ_INIT(&cpu->breakpoints);
+    QTAILQ_INIT(&cpu->watchpoints);
 }
 
 static int64_t cpu_common_get_arch_id(CPUState *cpu)
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/3 cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init

In reply to Eduardo Habkost

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.

---
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(-)
exec.c +6 -5
index 8d5d844..e2c438a 100644
@@ -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();
Signature · 1 line
2.1.0
#4 lore raw
In reply to Eduardo Habkost

Am 27.04.2015 um 22:00 schrieb Eduardo Habkost:

Quoted 9 lines

Those patches were submitted and reviewed back in March, and I believe they can go through the qom-cpu tree.

Patch 3/3 had to be redone because of new code.

Eduardo Habkost (3):
cpu: No need to zero-initialize numa_node
cpu: Initialize breakpoint/watchpoint lists on cpu_common_initfn()
cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init

Thanks, applied all to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Quoted 3 lines
 exec.c    | 14 ++++++--------
 qom/cpu.c |  2 ++
 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)