[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 09/12] exec: Remove cpu from cpus list during cpu_exec_
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 09/12] exec: Remove cpu from cpus list during cpu_exec_exit() |
Date: |
Tue, 31 May 2016 10:41:14 +1000 |
From: Bharata B Rao <address@hidden>
CPUState *cpu gets added to the cpus list during cpu_exec_init(). It
should be removed from cpu_exec_exit().
cpu_exec_exit() is called from generic CPU::instance_finalize and some
archs like PowerPC call it from CPU unrealizefn. So ensure that we
dequeue the cpu only once.
Now -1 value for cpu->cpu_index indicates that we have already dequeued
the cpu for CONFIG_USER_ONLY case also.
Signed-off-by: Bharata B Rao <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
exec.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/exec.c b/exec.c
index a3a93ae..a1dfc01 100644
--- a/exec.c
+++ b/exec.c
@@ -612,15 +612,9 @@ static int cpu_get_free_index(Error **errp)
return cpu;
}
-void cpu_exec_exit(CPUState *cpu)
+static void cpu_release_index(CPUState *cpu)
{
- if (cpu->cpu_index == -1) {
- /* cpu_index was never allocated by this @cpu or was already freed. */
- return;
- }
-
bitmap_clear(cpu_index_map, cpu->cpu_index, 1);
- cpu->cpu_index = -1;
}
#else
@@ -635,11 +629,33 @@ static int cpu_get_free_index(Error **errp)
return cpu_index;
}
-void cpu_exec_exit(CPUState *cpu)
+static void cpu_release_index(CPUState *cpu)
{
+ return;
}
#endif
+void cpu_exec_exit(CPUState *cpu)
+{
+#if defined(CONFIG_USER_ONLY)
+ cpu_list_lock();
+#endif
+ if (cpu->cpu_index == -1) {
+ /* cpu_index was never allocated by this @cpu or was already freed. */
+#if defined(CONFIG_USER_ONLY)
+ cpu_list_unlock();
+#endif
+ return;
+ }
+
+ QTAILQ_REMOVE(&cpus, cpu, node);
+ cpu_release_index(cpu);
+ cpu->cpu_index = -1;
+#if defined(CONFIG_USER_ONLY)
+ cpu_list_unlock();
+#endif
+}
+
void cpu_exec_init(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
--
2.5.5
- [Qemu-ppc] [PULL 00/12] ppc-for-2.7 queue 20160531, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 04/12] ppc: tlbie, tlbia and tlbisync are HV only, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 09/12] exec: Remove cpu from cpus list during cpu_exec_exit(),
David Gibson <=
- [Qemu-ppc] [PULL 01/12] ppc: Remove MMU_MODEn_SUFFIX definitions, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 02/12] ppc: Use split I/D mmu modes to avoid flushes on interrupts, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 03/12] ppc: Do some batching of TCG tlb flushes, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 05/12] ppc: Change 'invalid' bit mask of tlbiel and tlbie, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 10/12] exec: Do vmstate unregistration from cpu_exec_exit(), David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 08/12] ppc: Add PPC_64H instruction flag to POWER7 and POWER8, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 11/12] cpu: Reclaim vCPU objects, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 07/12] ppc: Get out of emulation on SMT "OR" ops, David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 12/12] cpu: Add a sync version of cpu_remove(), David Gibson, 2016/05/30
- [Qemu-ppc] [PULL 06/12] ppc: Fix sign extension issue in mtmsr(d) emulation, David Gibson, 2016/05/30