Fix migration issues with arbitrary cpu-hot(un)plug
v2 cover Fix migration issues with arbitrary cpu-hot(un)plug
Changes from v1:
- be conservative, drop QTAIL_*() macros hunks and do list element check/cleanup localy in cpu_exec_exit()
- fix conflict caused by above
- update Reviewed-bys fom v1
- drop spapr patches as they will be a bit different and depend on not yet applied to master patch:
'spapr: disintricate core-id from DT semantics'
Series fixes migration issues caused by unstable cpu_index which depended on order cpus were created/destroyed. It follows David's idea to make cpu_index assignable by selected boards if board supports cpu-hotplug with device_add and needs stable cpu_index/'migration id' but leaves behaviour of the same as before for users that don't care about cpu-hot(un)plug making changes low-risk.
tested with:
SRC -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \
-device qemu64-x86_64-cpu,id=cpudel,apic-id=1 \
-device qemu64-x86_64-cpu,apic-id=2 (qemu) device_del cpudel
(qemu) stop
(qemu) migrate "exec:gzip -c > STATEFILE.gz"
DST -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \
-device qemu64-x86_64-cpu,apic-id=2 \
-incoming "exec: gzip -c -d STATEFILE.gz"git tree to test with:
https://github.com/imammedo/qemu cpu-index-stable-v2
to view
https://github.com/imammedo/qemu/commits/cpu-index-stable-v2
Igor Mammedov (6):
exec: reduce CONFIG_USER_ONLY ifdeffenery
exec: don't use cpu_index to detect if cpu_exec_init()'s been called
for cpu
exec: set cpu_index only if it's not been explictly set
qdev: fix object reference leak in case device.realize() fails
pc: init CPUState->cpu_index with index in possible_cpus[] Revert "pc: Enforce adding CPUs contiguously and removing them in
opposite order"
bsd-user/qemu.h | 2 -- include/exec/exec-all.h | 12 +++++++++ include/qom/cpu.h | 2 ++ linux-user/qemu.h | 2 -- exec.c | 66 +++++++++---------------------------------------- hw/core/qdev.c | 8 +++++- hw/i386/pc.c | 38 +++------------------------- qom/cpu.c | 2 +- 8 files changed, 38 insertions(+), 94 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/6 exec: reduce CONFIG_USER_ONLY ifdeffenery
--- bsd-user/qemu.h | 2 -- include/exec/exec-all.h | 12 ++++++++++++ linux-user/qemu.h | 2 -- exec.c | 17 +++-------------- 4 files changed, 15 insertions(+), 18 deletions(-)
bsd-user/qemu.h +0 -2
@@ -209,8 +209,6 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_addr);int target_msync (abi_ulong start,abi_ulong len,int flags);extern unsigned long last_brk; -void cpu_list_lock (void ); -void cpu_list_unlock (void );#if defined(CONFIG_USE_NPTL )void mmap_fork_start (void );void mmap_fork_end (int child);
include/exec/exec-all.h +12 -0
@@ -56,6 +56,18 @@ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, uint32_t flags, int cflags); +#if defined(CONFIG_USER_ONLY ) +void cpu_list_lock (void ); +void cpu_list_unlock (void ); +#else +static inline void cpu_list_unlock (void ) +{ +} +static inline void cpu_list_lock (void ) +{ +} +#endif +void cpu_exec_init (CPUState *cpu,Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
linux-user/qemu.h +0 -2
@@ -419,8 +419,6 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);extern unsigned long last_brk;extern abi_ulong mmap_next_start;abi_ulong mmap_find_vma (abi_ulong ,abi_ulong ); -void cpu_list_lock (void ); -void cpu_list_unlock (void );void mmap_fork_start (void );void mmap_fork_end (int child);
exec.c +3 -14
@@ -642,23 +642,17 @@ void cpu_exec_exit(CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (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 if (cc->vmsd !=NULL ) {vmstate_unregister (NULL , cc->vmsd, cpu);
@@ -670,7 +664,7 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { -CPUClass *cc =CPU_GET_CLASS (cpu); + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);Error *local_err =NULL ; cpu->as =NULL ;
@@ -694,22 +688,17 @@ void cpu_exec_init(CPUState *cpu, Error **errp)object_ref (OBJECT (cpu->memory));#endif -#if defined(CONFIG_USER_ONLY )cpu_list_lock (); -#endif cpu->cpu_index =cpu_get_free_index (&local_err);if (local_err) {error_propagate (errp, local_err); -#if defined(CONFIG_USER_ONLY )cpu_list_unlock (); -#endif return ; }QTAILQ_INSERT_TAIL (&cpus, cpu, node); -#if defined(CONFIG_USER_ONLY ) - (void ) cc;cpu_list_unlock (); -#else + +#ifndef CONFIG_USER_ONLY if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_register (NULL , cpu->cpu_index, &vmstate_cpu_common, cpu); }
Signature · 1 line
2.7.4
PATCH v2 2/6 exec: don't use cpu_index to detect if cpu_exec_init()'s been called for cpu
In reply to Igor MammedovInstead use QTAIL's tqe_prev field to detect if cpu's been placed in list by cpu_exec_init() which is always set if QTAIL element is in list.
Fixes SIGSEGV on failure path in case cpu_index is assigned by board and cpu.relalize() fails before cpu_exec_init() is called.
In follow up patches, cpu_index will be assigned by boards that support cpu hot(un)plug and need stable cpu_index that doesn't depend on order cpus are created/removed.
---
v2:
replace setting tqe_prev to NULL in generic QTAIL_REMOVE with a check and cleanup in cpu_exec_exit() to be on safe side. And delay QTAIL_REMOVE() change to 2.8.
--- exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
exec.c +3 -2
@@ -643,13 +643,14 @@ void cpu_exec_exit(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);cpu_list_lock (); -if (cpu->cpu_index ==-1 ) { -/* cpu_index was never allocated by this @cpu or was already freed. */ +if (cpu->node.tqe_prev ==NULL ) { +/* there is nothing to undo since cpu_exec_init() hasn't been called */ cpu_list_unlock ();return ; }QTAILQ_REMOVE (&cpus, cpu, node); + cpu->node.tqe_prev =NULL ;cpu_release_index (cpu); cpu->cpu_index =-1 ;cpu_list_unlock ();
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 2/6] exec: don't use cpu_index to detect if cpu_exec_init()'s been called for cpu
Quoted 7 lines · Igor Mammedov
Instead use QTAIL's
tqe_prevfield to detect if cpu's been placed in list bycpu_exec_init()which is always set if QTAIL element is in list.Fixes SIGSEGV on failure path in case
cpu_indexis assigned by board andcpu.relalize()fails beforecpu_exec_init()is called.
Quoted 6 lines
In follow up patches,
cpu_indexwill be assigned by boards that support cpu hot(un)plug and need stablecpu_indexthat doesn't depend on order cpus are created/removed.Signed-off-by Igor Mammedov <[email protected]>Reported-by David Gibson <[email protected]>
Quoted 30 lines
---
v2:
replace settingtqe_prevto NULL in genericQTAIL_REMOVEwith a check and cleanup incpu_exec_exit()to be on safe side. And delayQTAIL_REMOVE()change to 2.8.--- exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)exec.c +3
-2@@ -643,13 +643,14 @@ void cpu_exec_exit(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);cpu_list_lock (); -if (cpu->cpu_index ==-1 ) { -/* cpu_index was never allocated by this @cpu or was already freed. */ +if (cpu->node.tqe_prev ==NULL ) { +/* there is nothing to undo since cpu_exec_init() hasn't been called */ cpu_list_unlock ();return ; }QTAILQ_REMOVE (&cpus, cpu, node); + cpu->node.tqe_prev =NULL ;cpu_release_index (cpu); cpu->cpu_index =-1 ;cpu_list_unlock ();
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 3/6 exec: set cpu_index only if it's not been explictly set
In reply to Igor Mammedovit keeps the legacy behavior for all users that doesn't care about stable cpu_index value, but would allow boards that would support device_add/device_del to set stable cpu_index that won't depend on order in which cpus are created/destroyed.
While at that simplify cpu_get_free_index() as cpu_index generated by USER_ONLY and softmmu variants is the same since none of the users support cpu-remove so far, except of not yet released spapr/x86 device_add/delr, which will be altered by follow up patches to set stable cpu_index manually.
--- include/qom/cpu.h | 2 ++ exec.c | 44 ++++++-------------------------------------- qom/cpu.c | 2 +- 3 files changed, 9 insertions(+), 39 deletions(-)
include/qom/cpu.h +2 -0
@@ -883,4 +883,6 @@ extern const struct VMStateDescription vmstate_cpu_common; .offset = 0, \ } +#define UNASSIGNED_CPU_INDEX -1 +#endif
exec.c +6 -38
74 lines not on this page · raw message
qom/cpu.c +1 -1
@@ -340,7 +340,7 @@ static void cpu_common_initfn(Object *obj)CPUState *cpu =CPU (obj);CPUClass *cc =CPU_GET_CLASS (obj); - cpu->cpu_index =-1 ; + cpu->cpu_index =UNASSIGNED_CPU_INDEX ; cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;qemu_mutex_init (&cpu->work_mutex);QTAILQ_INIT (&cpu->breakpoints);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 3/6] exec: set cpu_index only if it's not been explictly set
Quoted 11 lines · Igor Mammedov
it keeps the legacy behavior for all users that doesn't care about stable
cpu_indexvalue, but would allow boards that would support device_add/device_del to set stablecpu_indexthat won't depend on order in which cpus are created/destroyed.While at that simplify
cpu_get_free_index()ascpu_indexgenerated byUSER_ONLYand softmmu variants is the same since none of the users support cpu-remove so far, except of not yet released spapr/x86 device_add/delr, which will be altered by follow up patches to set stablecpu_indexmanually.
So, cpu_get_free_index() behavior is exactly the same because cpu-remove is either unsupported, or only supported for the last CPU. But I worry that this will easily break if anybody starts implementing CPU removal in other machines without setting cpu_index explicitly in the board code. Then we can make cpu_get_free_index() generate a duplicate cpu_index.
I wonder if there any way we can add an assert() somewhere to ensure no machine will ever allow CPU removal while not initializing cpu_index explicitly.
(This shouldn't hold this patch, it's just a suggestion for a possible follow-up patch).
Additional comment:
Quoted 3 lines
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by David Gibson <[email protected]>
[...]
exec.c AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) · line 612
Quoted 9 lines
exec.c +0
-9-static int cpu_get_free_index (Error **errp) -{ -int cpu =find_first_zero_bit (cpu_index_map,MAX_CPUMASK_BITS ); - -if (cpu >=MAX_CPUMASK_BITS ) { -error_setg (errp,"Trying to use more CPUs than max of %d" , -MAX_CPUMASK_BITS ); -return -1 ; - }
We are now relying on the rest of the QEMU code to make sure cpu_index will be always < MAX_CPUMASK_BITS. In this case, I suggest we add an assert() below:
[...]
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 666
Quoted 9 lines
exec.c +3
-5- cpu->cpu_index =cpu_get_free_index (&local_err); -if (local_err) { -error_propagate (errp, local_err); -cpu_list_unlock (); -return ; +if (cpu->cpu_index ==UNASSIGNED_CPU_INDEX ) { + cpu->cpu_index =cpu_get_free_index (); +assert (cpu->cpu_index !=UNASSIGNED_CPU_INDEX ); }
Here:
assert(cpu->cpu_index <= MAX_CPUMASK_BITS)
Both comments can be addressed in a follow-up patch, so:
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH v2 3/6] exec: set cpu_index only if it's not been explictly set
Quoted 20 lines · On Tue, 26 Jul 2016 15:28:13 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 11 lines · Igor Mammedov
it keeps the legacy behavior for all users that doesn't care about stable
cpu_indexvalue, but would allow boards that would support device_add/device_del to set stablecpu_indexthat won't depend on order in which cpus are created/destroyed.While at that simplify
cpu_get_free_index()ascpu_indexgenerated byUSER_ONLYand softmmu variants is the same since none of the users support cpu-remove so far, except of not yet released spapr/x86 device_add/delr, which will be altered by follow up patches to set stablecpu_indexmanually.So,
cpu_get_free_index()behavior is exactly the same because cpu-remove is either unsupported, or only supported for the last CPU. But I worry that this will easily break if anybody starts implementing CPU removal in other machines without settingcpu_indexexplicitly in the board code. Then we can makecpu_get_free_index()generate a duplicatecpu_index.
Quoted 6 lines
I wonder if there any way we can add an
assert()somewhere to ensure no machine will ever allow CPU removal while not initializingcpu_indexexplicitly.(This shouldn't hold this patch, it's just a suggestion for a possible follow-up patch).
I'll try to post it shortly on top of this patch
Quoted 32 lines
Additional comment:
Quoted 3 lines
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by David Gibson <[email protected]>[...]
exec.c AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) · line 612
Quoted 9 lines
exec.c +0
-9-static int cpu_get_free_index (Error **errp) -{ -int cpu =find_first_zero_bit (cpu_index_map,MAX_CPUMASK_BITS ); - -if (cpu >=MAX_CPUMASK_BITS ) { -error_setg (errp,"Trying to use more CPUs than max of %d" , -MAX_CPUMASK_BITS ); -return -1 ; - }We are now relying on the rest of the QEMU code to make sure
cpu_indexwill be always <MAX_CPUMASK_BITS. In this case, I suggest we add anassert()below:[...]
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 666
Quoted 9 lines
exec.c +3
-5- cpu->cpu_index =cpu_get_free_index (&local_err); -if (local_err) { -error_propagate (errp, local_err); -cpu_list_unlock (); -return ; +if (cpu->cpu_index ==UNASSIGNED_CPU_INDEX ) { + cpu->cpu_index =cpu_get_free_index (); +assert (cpu->cpu_index !=UNASSIGNED_CPU_INDEX ); }
Quoted 2 lines
Here:
assert(cpu->cpu_index <= MAX_CPUMASK_BITS)
I'd rather get rid of MAX_CPUMASK_BITS but I haven't looked at how hard it will be yet.
Quoted 6 lines
Both comments can be addressed in a follow-up patch, so:
Reviewed-by Eduardo Habkost <[email protected]>
PATCH v2 4/6 qdev: fix object reference leak in case device.realize() fails
In reply to Igor MammedovIf device doesn't have parent assined before its realize is called, device_set_realized() will implicitly set parent to '/machine/unattached'.
However device_set_realized() may fail after that point at several other points leaving not realized object dangling in '/machine/unattached' and as result caller of
obj = object_new()
obj->ref == 1
object_property_set_bool(obj,..., true, "realized",...)
obj->ref == 2
if (fail)
object_unref(obj);
obj->ref == 1will get object leak instead of expected object destruction.
Fix it by making device_set_realized() to cleanup after itself in case of failure.
--- hw/core/qdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/core/qdev.c +7 -1
@@ -885,6 +885,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp)HotplugHandler *hotplug_ctrl;BusState *bus;Error *local_err =NULL ; +bool unattached_parent = false; +static int unattached_count;if (dev->hotplugged && !dc->hotpluggable) {error_setg (errp,QERR_DEVICE_NO_HOTPLUG ,object_get_typename (obj));
@@ -893,12 +895,12 @@ static void device_set_realized(Object *obj, bool value, Error **errp)if (value && !dev->realized) {if (!obj->parent) { -static int unattached_count;gchar *name =g_strdup_printf ("device[%d]" , unattached_count++);object_property_add_child (container_get (qdev_get_machine (),"/unattached" ), name, obj, &error_abort); + unattached_parent = true;g_free (name); }
@@ -987,6 +989,10 @@ post_realize_fail: fail:error_propagate (errp, local_err); +if (unattached_parent) { +object_unparent (OBJECT (dev)); + unattached_count--; + } }static bool device_get_hotpluggable (Object *obj,Error **errp)
Signature · 1 line
2.7.4
PATCH v2 5/6 pc: init CPUState->cpu_index with index in possible_cpus[]
In reply to Igor MammedovIt will enshure that cpu_index for a given cpu stays the same regardless of the order cpus has been created/deleted.
No compat code is needed as for initial cpus index in possible_cpus[] matches cpu_index that's been auto-allocated in cpu_exec_init().
Tha same applies for hotplug with cpu-add command if cpus are added sequentially in increasing order as 'id' matches cpu_index.
If cpu-add had been used for creating out-of-order cpus, that created unmigratable instance since it were not possible to start target with the same cpu_index using old way of migrating instance with hotplugged cpus:
* source QEMU with CLI (-smp 1,maxcpus=3 and cpu-add id=2) following set of cpu_index is allocated [0, 1] with apics set [0, 2] respectivelly
* target QEMU is started with CLI -smp 2,maxcpus=3 resulting in set of cpu_index [0, 1] but with set of apics [0, 1] wich doesn't match source.
So we don't need compat code in this case as it's never worked and newelly added device_add support would use stable cpu_index set by machine to begin with, so it won't have above limitation and source QEMU could be migrated to destination regardless of the order cpus were created.
--- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/pc.c +4 -0
@@ -1875,6 +1875,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) {int idx; +CPUState *cs;CPUArchId *cpu_slot;X86CPUTopoInfo topo;X86CPU *cpu =X86_CPU (dev);
@@ -1975,6 +1976,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,return ; } cpu->thread_id = topo.smt_id; + + cs =CPU (cpu); + cs->cpu_index = idx; } static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
Signature · 1 line
2.7.4
PATCH v2 6/6 Revert "pc: Enforce adding CPUs contiguously and removing them in opposite order"
In reply to Igor MammedovThis reverts commit 4da7faaeb0c7dd3f7f233165d336c878f78fd1eb.
However since commit:
pc: init CPUState->cpu_index with index in possible_cpus[]cpu_index is stable regardless of the order cpus were created and QEMU instance stays migratable always so limitation added by 4da7faaeb could be safely removed.
--- hw/i386/pc.c | 34 ---------------------------------- 1 file changed, 34 deletions(-)
hw/i386/pc.c +0 -34
@@ -1818,23 +1818,6 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, goto out; } -if (idx < pcms->possible_cpus->len -1 && - pcms->possible_cpus->cpus[idx +1 ].cpu !=NULL ) { -X86CPU *cpu; - -for (idx = pcms->possible_cpus->len -1 ; - pcms->possible_cpus->cpus[idx].cpu ==NULL ; idx--) { - ;; - } - - cpu =X86_CPU (pcms->possible_cpus->cpus[idx].cpu); -error_setg (&local_err,"CPU [socket-id: %u, core-id: %u," -" thread-id: %u] should be removed first" , - cpu->socket_id, cpu->core_id, cpu->thread_id); - goto out; - - } - hhc =HOTPLUG_HANDLER_GET_CLASS (pcms->acpi_dev); hhc->unplug_request (HOTPLUG_HANDLER (pcms->acpi_dev), dev, &local_err);
@@ -1932,23 +1915,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,return ; } -if (idx !=0 && pcms->possible_cpus->cpus[idx -1 ].cpu ==NULL ) { -PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms); - -for (idx =1 ; pcms->possible_cpus->cpus[idx].cpu !=NULL ; idx++) { - ;; - } - -x86_topo_ids_from_apicid (pcms->possible_cpus->cpus[idx].arch_id, - smp_cores, smp_threads, &topo); - -if (!pcmc->legacy_cpu_hotplug) { -error_setg (errp,"CPU [socket: %u, core: %u, thread: %u] should be" -" added first" , topo.pkg_id, topo.core_id, topo.smt_id); -return ; - } - } -/* if 'address' properties socket-id/core-id/thread-id are not set, set them * so that query_hotpluggable_cpus would show correct values */
Signature · 1 line
2.7.4
Quoted 9 lines · Igor Mammedov
Changes from v1:
- be conservative, drop QTAIL_*() macros hunks and do list element check/cleanup localy incpu_exec_exit()
- fix conflict caused by above
- update Reviewed-bys fom v1
- drop spapr patches as they will be a bit different and depend on not yet applied to master patch:
'spapr: disintricate core-id from DT semantics'
Quoted 6 lines
Series fixes migration issues caused by unstable
cpu_indexwhich depended on order cpus were created/destroyed. It follows David's idea to makecpu_indexassignable by selected boards if board supports cpu-hotplug withdevice_addand needs stable cpu_index/'migration id' but leaves behaviour of the same as before for users that don't care about cpu-hot(un)plug making changes low-risk.
Looks good. I'd like to see this merged ASAP, and then I can sort out the ppc / spapr changes we need based on it.
Quoted 49 lines
tested with:
SRC -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,id=cpudel,apic-id=1 \ -device qemu64-x86_64-cpu,apic-id=2(qemu)
device_delcpudel
(qemu) stop
(qemu) migrate "exec:gzip -c > STATEFILE.gz"DST -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,apic-id=2 \ -incoming "exec: gzip -c -d STATEFILE.gz"git tree to test with:
https://github.com/imammedo/qemu cpu-index-stable-v2
to view
https://github.com/imammedo/qemu/commits/cpu-index-stable-v2CC Paolo Bonzini <[email protected]>CC Peter Crosthwaite <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC David Gibson <[email protected]>CC Alexander Graf <[email protected]>CC Riku Voipio <[email protected]>CC Bharata B Rao <[email protected]>Igor Mammedov (6):
exec: reduceCONFIG_USER_ONLYifdeffenery
exec: don't usecpu_indexto detect if cpu_exec_init()'s been called
for cpu
exec: setcpu_indexonly if it's not been explictly set
qdev: fix object reference leak in casedevice.realize()fails
pc: initCPUState->cpu_indexwith index in possible_cpus[] Revert "pc: Enforce adding CPUs contiguously and removing them in
opposite order"bsd-user/qemu.h | 2 -- include/exec/exec-all.h | 12 +++++++++ include/qom/cpu.h | 2 ++ linux-user/qemu.h | 2 -- exec.c | 66 +++++++++---------------------------------------- hw/core/qdev.c | 8 +++++- hw/i386/pc.c | 38 +++------------------------- qom/cpu.c | 2 +- 8 files changed, 38 insertions(+), 94 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 24 lines · Igor Mammedov
Changes from v1:
- be conservative, drop QTAIL_*() macros hunks and do list element check/cleanup localy incpu_exec_exit()
- fix conflict caused by above
- update Reviewed-bys fom v1
- drop spapr patches as they will be a bit different and depend on not yet applied to master patch:
'spapr: disintricate core-id from DT semantics'Series fixes migration issues caused by unstable
cpu_indexwhich depended on order cpus were created/destroyed. It follows David's idea to makecpu_indexassignable by selected boards if board supports cpu-hotplug withdevice_addand needs stable cpu_index/'migration id' but leaves behaviour of the same as before for users that don't care about cpu-hot(un)plug making changes low-risk.tested with:
SRC -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,id=cpudel,apic-id=1 \ -device qemu64-x86_64-cpu,apic-id=2(qemu)
device_delcpudel
(qemu) stop
(qemu) migrate "exec:gzip -c > STATEFILE.gz"
Quoted 8 lines
DST -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,apic-id=2 \ -incoming "exec: gzip -c -d STATEFILE.gz"git tree to test with:
https://github.com/imammedo/qemu cpu-index-stable-v2
to view
https://github.com/imammedo/qemu/commits/cpu-index-stable-v2
Eduardo,
Igor said he thought these would probably go in via your tree. Do you have any kind of ETA for this?
I've put these into my ppc-for-2.7 tree, not because I intend to push them from there, but so I can do the ppc specific fixups on top of them. I'm hoping these will disappear in a rebase before my next pull request.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 34 lines · David Gibson
Quoted 24 lines · Igor Mammedov
Changes from v1:
- be conservative, drop QTAIL_*() macros hunks and do list element check/cleanup localy incpu_exec_exit()
- fix conflict caused by above
- update Reviewed-bys fom v1
- drop spapr patches as they will be a bit different and depend on not yet applied to master patch:
'spapr: disintricate core-id from DT semantics'Series fixes migration issues caused by unstable
cpu_indexwhich depended on order cpus were created/destroyed. It follows David's idea to makecpu_indexassignable by selected boards if board supports cpu-hotplug withdevice_addand needs stable cpu_index/'migration id' but leaves behaviour of the same as before for users that don't care about cpu-hot(un)plug making changes low-risk.tested with:
SRC -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,id=cpudel,apic-id=1 \ -device qemu64-x86_64-cpu,apic-id=2(qemu)
device_delcpudel
(qemu) stop
(qemu) migrate "exec:gzip -c > STATEFILE.gz"Quoted 8 lines
DST -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,apic-id=2 \ -incoming "exec: gzip -c -d STATEFILE.gz"git tree to test with:
https://github.com/imammedo/qemu cpu-index-stable-v2
to view
https://github.com/imammedo/qemu/commits/cpu-index-stable-v2
Quoted 4 lines
Eduardo,
Igor said he thought these would probably go in via your tree. Do you have any kind of ETA for this?
I will merge it today and send a pull request today or tomorrow.
Quoted 5 lines
I've put these into my ppc-for-2.7 tree, not because I intend to push them from there, but so I can do the ppc specific fixups on top of them. I'm hoping these will disappear in a rebase before my next pull request.
No problem. Thanks!
Signature · 1 line
Eduardo
Quoted 33 lines · Igor Mammedov
Changes from v1:
- be conservative, drop QTAIL_*() macros hunks and do list element check/cleanup localy incpu_exec_exit()
- fix conflict caused by above
- update Reviewed-bys fom v1
- drop spapr patches as they will be a bit different and depend on not yet applied to master patch:
'spapr: disintricate core-id from DT semantics'Series fixes migration issues caused by unstable
cpu_indexwhich depended on order cpus were created/destroyed. It follows David's idea to makecpu_indexassignable by selected boards if board supports cpu-hotplug withdevice_addand needs stable cpu_index/'migration id' but leaves behaviour of the same as before for users that don't care about cpu-hot(un)plug making changes low-risk.tested with:
SRC -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,id=cpudel,apic-id=1 \ -device qemu64-x86_64-cpu,apic-id=2(qemu)
device_delcpudel
(qemu) stop
(qemu) migrate "exec:gzip -c > STATEFILE.gz"DST -snapshot -enable-kvm -smp 1,maxcpus=3 -m 256M guest.img -monitor stdio \ -device qemu64-x86_64-cpu,apic-id=2 \ -incoming "exec: gzip -c -d STATEFILE.gz"git tree to test with:
https://github.com/imammedo/qemu cpu-index-stable-v2
to view
https://github.com/imammedo/qemu/commits/cpu-index-stable-v2
Quoted 11 lines
CC Paolo Bonzini <[email protected]>CC Peter Crosthwaite <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC David Gibson <[email protected]>CC Alexander Graf <[email protected]>CC Riku Voipio <[email protected]>CC Bharata B Rao <[email protected]>
For PC bits:
Quoted 22 lines
Igor Mammedov (6):
exec: reduceCONFIG_USER_ONLYifdeffenery
exec: don't usecpu_indexto detect if cpu_exec_init()'s been called
for cpu
exec: setcpu_indexonly if it's not been explictly set
qdev: fix object reference leak in casedevice.realize()fails
pc: initCPUState->cpu_indexwith index in possible_cpus[] Revert "pc: Enforce adding CPUs contiguously and removing them in
opposite order"bsd-user/qemu.h | 2 -- include/exec/exec-all.h | 12 +++++++++ include/qom/cpu.h | 2 ++ linux-user/qemu.h | 2 -- exec.c | 66 +++++++++---------------------------------------- hw/core/qdev.c | 8 +++++- hw/i386/pc.c | 38 +++------------------------- qom/cpu.c | 2 +- 8 files changed, 38 insertions(+), 94 deletions(-)Signature · 1 line
2.7.4
Eduardo Habkost
AppliedOn Mon, Jul 25, 2016 at 11:59:18AM +0200, Igor Mammedov wrote:
[...]
Quoted 9 lines
Igor Mammedov (6):
exec: reduceCONFIG_USER_ONLYifdeffenery
exec: don't usecpu_indexto detect if cpu_exec_init()'s been called
for cpu
exec: setcpu_indexonly if it's not been explictly set
qdev: fix object reference leak in casedevice.realize()fails
pc: initCPUState->cpu_indexwith index in possible_cpus[] Revert "pc: Enforce adding CPUs contiguously and removing them in
opposite order"
Applied to x86-next. Thanks!
Subject line of patch 2/6 was changed to:
"exec: Don't use cpu_index to detect if cpu_exec_init()'s been called"
to make it shorter.
Signature · 1 line
Eduardo
[Qemu-devel] [PATCH v2 7/6] exec: ensure the only one cpu_index allocation method is used
In reply to Igor MammedovMake sure that cpu_index auto allocation isn't used in combination with manual cpu_index assignment. And dissallow out of order cpu removal if auto allocation is in use.
Target that wishes to support out of order unplug should switch to manual cpu_index assignment. Following patch could be used as an example:
(pc: init CPUState->cpu_index with index in possible_cpus[]))
--- exec.c | 7 +++++++ 1 file changed, 7 insertions(+)
exec.c +7 -0
@@ -598,11 +598,14 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) }#endif +static bool cpu_index_auto_assigned; +static int cpu_get_free_index (void ) {CPUState *some_cpu;int cpu_index =0 ; + cpu_index_auto_assigned = true;CPU_FOREACH (some_cpu) { cpu_index++; }
@@ -620,6 +623,8 @@ void cpu_exec_exit(CPUState *cpu)return ; } +assert (!(cpu_index_auto_assigned && cpu !=QTAILQ_LAST (&cpus, CPUTailQ))); +QTAILQ_REMOVE (&cpus, cpu, node); cpu->cpu_index =UNASSIGNED_CPU_INDEX ;cpu_list_unlock ();
@@ -662,6 +667,8 @@ void cpu_exec_init(CPUState *cpu, Error **errp)if (cpu->cpu_index ==UNASSIGNED_CPU_INDEX ) { cpu->cpu_index =cpu_get_free_index ();assert (cpu->cpu_index !=UNASSIGNED_CPU_INDEX ); + }else { +assert (!cpu_index_auto_assigned); }QTAILQ_INSERT_TAIL (&cpus, cpu, node);cpu_list_unlock ();
Signature · 1 line
2.7.4
David Gibson
Reviewed-byRe: [Qemu-devel] [PATCH v2 7/6] exec: ensure the only one cpu_index allocation method is used
Quoted 11 lines · Igor Mammedov
Make sure that
cpu_indexauto allocation isn't used in combination with manualcpu_indexassignment. And dissallow out of order cpu removal if auto allocation is in use.Target that wishes to support out of order unplug should switch to manual
cpu_indexassignment. Following patch could be used as an example:
(pc: initCPUState->cpu_indexwith index in possible_cpus[]))Signed-off-by Igor Mammedov <[email protected]>
Quoted 41 lines
--- exec.c | 7 +++++++ 1 file changed, 7 insertions(+)exec.c +7
-0@@ -598,11 +598,14 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) }#endif +static bool cpu_index_auto_assigned; +static int cpu_get_free_index (void ) {CPUState *some_cpu;int cpu_index =0 ; + cpu_index_auto_assigned = true;CPU_FOREACH (some_cpu) { cpu_index++; }@@ -620,6 +623,8 @@ void cpu_exec_exit(CPUState *cpu)return ; } +assert (!(cpu_index_auto_assigned && cpu !=QTAILQ_LAST (&cpus, CPUTailQ))); +QTAILQ_REMOVE (&cpus, cpu, node); cpu->cpu_index =UNASSIGNED_CPU_INDEX ;cpu_list_unlock ();@@ -662,6 +667,8 @@ void cpu_exec_init(CPUState *cpu, Error **errp)if (cpu->cpu_index ==UNASSIGNED_CPU_INDEX ) { cpu->cpu_index =cpu_get_free_index ();assert (cpu->cpu_index !=UNASSIGNED_CPU_INDEX ); + }else { +assert (!cpu_index_auto_assigned); }QTAILQ_INSERT_TAIL (&cpus, cpu, node);cpu_list_unlock ();
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 7/6] exec: ensure the only one cpu_index allocation method is used
In reply to Igor MammedovQuoted 11 lines · Igor Mammedov
Make sure that
cpu_indexauto allocation isn't used in combination with manualcpu_indexassignment. And dissallow out of order cpu removal if auto allocation is in use.Target that wishes to support out of order unplug should switch to manual
cpu_indexassignment. Following patch could be used as an example:
(pc: initCPUState->cpu_indexwith index in possible_cpus[]))Signed-off-by Igor Mammedov <[email protected]>
Sorry for the delay, applied to x86-next. Thanks!
Signature · 1 line
Eduardo