From patchwork Mon Sep 5 19:50:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9315127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E323F6075E for ; Mon, 5 Sep 2016 19:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2A72288B8 for ; Mon, 5 Sep 2016 19:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5165288CD; Mon, 5 Sep 2016 19:51:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48041288B8 for ; Mon, 5 Sep 2016 19:51:44 +0000 (UTC) Received: from localhost ([::1]:56753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzvj-0008S1-3A for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Sep 2016 15:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzvA-0008PA-NI for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgzv8-0003QF-RW for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:51:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzv8-0003QA-LR for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:51:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 316AC747; Mon, 5 Sep 2016 19:51:06 +0000 (UTC) Received: from localhost (ovpn-116-23.phx2.redhat.com [10.3.116.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u85Jp5Ja003247; Mon, 5 Sep 2016 15:51:05 -0400 From: Eduardo Habkost To: Peter Maydell Date: Mon, 5 Sep 2016 16:50:44 -0300 Message-Id: <1473105047-13083-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1473105047-13083-1-git-send-email-ehabkost@redhat.com> References: <1473105047-13083-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 05 Sep 2016 19:51:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] exec: Ensure the only one cpu_index allocation method is used X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , qemu-devel@nongnu.org, Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Igor Mammedov 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 Signed-off-by: Eduardo Habkost --- exec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exec.c b/exec.c index 8ffde75..80398b0 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->node.tqe_prev = NULL; cpu->cpu_index = UNASSIGNED_CPU_INDEX; @@ -663,6 +668,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();