From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSL5L-0000Rj-Qm for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:25:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSL5H-0000Tl-Mv for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:25:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSL5H-0000Tb-H8 for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:24:59 -0400 From: Igor Mammedov Date: Wed, 27 Jul 2016 11:24:54 +0200 Message-Id: <1469611494-163855-1-git-send-email-imammedo@redhat.com> In-Reply-To: <1469440764-61619-1-git-send-email-imammedo@redhat.com> References: <1469440764-61619-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 7/6] exec: ensure the only one cpu_index allocation method is used List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ehabkost@redhat.com, david@gibson.dropbear.id.au, bharata@linux.vnet.ibm.com, Paolo Bonzini , Peter Crosthwaite , Richard Henderson Make 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[])) Signed-off-by: Igor Mammedov --- exec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exec.c b/exec.c index 8e8416b..e0d8f18 100644 --- a/exec.c +++ b/exec.c @@ -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(); -- 2.7.4