From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCuh4-00055e-Hq for qemu-devel@nongnu.org; Wed, 08 Jul 2015 15:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCugw-0004Jh-2s for qemu-devel@nongnu.org; Wed, 08 Jul 2015 15:07:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43452 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCugv-0004JC-6I for qemu-devel@nongnu.org; Wed, 08 Jul 2015 15:07:34 -0400 Message-ID: <559D74F2.5000206@suse.de> Date: Wed, 08 Jul 2015 21:07:30 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1436289389-5403-1-git-send-email-afaerber@suse.de> <1436289389-5403-6-git-send-email-afaerber@suse.de> In-Reply-To: <1436289389-5403-6-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PULL v2 05/22] cpu: Convert cpu_index into a bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Crosthwaite , Bharata B Rao Cc: Paolo Bonzini , Alexander Graf Am 07.07.2015 um 19:16 schrieb Andreas F=C3=A4rber: > From: Bharata B Rao >=20 > Currently CPUState::cpu_index is monotonically increasing and a newly > created CPU always gets the next higher index. The next available > index is calculated by counting the existing number of CPUs. This is > fine as long as we only add CPUs, but there are architectures which > are starting to support CPU removal, too. For an architecture like Powe= rPC > which derives its CPU identifier (device tree ID) from cpu_index, the > existing logic of generating cpu_index values causes problems. >=20 > With the currently proposed method of handling vCPU removal by parking > the vCPU fd in QEMU > (Ref: http://lists.gnu.org/archive/html/qemu-devel/2015-02/msg02604.htm= l), > generating cpu_index this way will not work for PowerPC. >=20 > This patch changes the way cpu_index is handed out by maintaining > a bit map of the CPUs that tracks both addition and removal of CPUs. >=20 > The CPU bitmap allocation logic is part of cpu_exec_init(), which is > called by instance_init routines of various CPU targets. Newly added > cpu_exec_exit() API handles the deallocation part and this routine is > called from generic CPU instance_finalize. >=20 > Note: This new CPU enumeration is for !CONFIG_USER_ONLY only. > CONFIG_USER_ONLY continues to have the old enumeration logic. >=20 > Signed-off-by: Bharata B Rao > Reviewed-by: Eduardo Habkost > Reviewed-by: Igor Mammedov > Reviewed-by: David Gibson > Reviewed-by: Peter Crosthwaite > Acked-by: Paolo Bonzini > Signed-off-by: Peter Crosthwaite > [AF: max_cpus -> MAX_CPUMASK_BITS] > Signed-off-by: Andreas F=C3=A4rber > --- > exec.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++= +++----- > include/qom/cpu.h | 1 + > qom/cpu.c | 7 +++++++ > 3 files changed, 58 insertions(+), 5 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 8abac69..02602b6 100644 > --- a/exec.c > +++ b/exec.c [...] > @@ -542,11 +587,11 @@ void cpu_exec_init(CPUArchState *env, Error **err= p) > #if defined(CONFIG_USER_ONLY) > cpu_list_lock(); > #endif > - cpu_index =3D 0; > - CPU_FOREACH(some_cpu) { > - cpu_index++; > + cpu_index =3D cpu->cpu_index =3D cpu_get_free_index(&local_err); > + if (local_err) { > + error_propagate(errp, local_err); This is lacking a matching cpu_list_unlock() in the CONFIG_USER_ONLY case= : diff --git a/exec.c b/exec.c index ee5bf7c..d817e5f 100644 --- a/exec.c +++ b/exec.c @@ -590,6 +590,9 @@ void cpu_exec_init(CPUArchState *env, Error **errp) cpu_index =3D cpu->cpu_index =3D 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); Regards, Andreas > + return; > } > - cpu->cpu_index =3D cpu_index; > QTAILQ_INSERT_TAIL(&cpus, cpu, node); > #if defined(CONFIG_USER_ONLY) > cpu_list_unlock(); [snip] --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Dilip Upmanyu, Graham Norton; = HRB 21284 (AG N=C3=BCrnberg)