[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v1 PATCH 2/3] cpus: Convert cpu_index into a bitma
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [RFC v1 PATCH 2/3] cpus: Convert cpu_index into a bitmap |
Date: |
Fri, 8 May 2015 11:55:00 -0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, May 08, 2015 at 03:21:35PM +0530, Bharata B Rao wrote:
> 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 PowerPC
> which derives its CPU identifier (device tree ID) from cpu_index, the
> existing logic of generating cpu_index values causes problems.
>
> 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.html),
> generating cpu_index this way will not work for PowerPC.
>
> 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.
>
> The CPU bitmap allocation logic is part of cpu_exec_init() which is
> called by instance_init routines of various CPU targets. This patch
> also adds corresponding instance_finalize routine if needed for these
> CPU targets so that CPU can be marked free when it is removed.
>
> Signed-off-by: Bharata B Rao <address@hidden>
> ---
> exec.c | 37 ++++++++++++++++++++++++++++++++++---
> include/qom/cpu.h | 8 ++++++++
> target-alpha/cpu.c | 6 ++++++
> target-arm/cpu.c | 1 +
> target-cris/cpu.c | 6 ++++++
> target-i386/cpu.c | 6 ++++++
> target-lm32/cpu.c | 6 ++++++
> target-m68k/cpu.c | 6 ++++++
> target-microblaze/cpu.c | 6 ++++++
> target-mips/cpu.c | 6 ++++++
> target-moxie/cpu.c | 6 ++++++
> target-openrisc/cpu.c | 6 ++++++
> target-ppc/translate_init.c | 6 ++++++
> target-s390x/cpu.c | 1 +
> target-sh4/cpu.c | 6 ++++++
> target-sparc/cpu.c | 1 +
> target-tricore/cpu.c | 5 +++++
> target-unicore32/cpu.c | 6 ++++++
> target-xtensa/cpu.c | 6 ++++++
> 19 files changed, 128 insertions(+), 3 deletions(-)
Why not simply call cpu_exec_exit() on generic CPU::instance_finalize,
to avoid forcing every architecture to call it manually? Calling
cpu_exec_exit() twice would be harmless, anyway.
(It would just need an additional check to make sure the bit will be
cleared only if cpu_exec_init() was really called and cpu_index was
properly set.)
--
Eduardo
[Qemu-devel] [RFC v1 PATCH 3/3] ppc: Move cpu_exec_init() call to realize function, Bharata B Rao, 2015/05/08