qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	qemu-devel@nongnu.org,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>
Subject: Re: [Qemu-devel] [PULL v2 05/22] cpu: Convert cpu_index into a bitmap
Date: Thu, 9 Jul 2015 08:46:20 +0530	[thread overview]
Message-ID: <20150709031619.GA3352@in.ibm.com> (raw)
In-Reply-To: <559D74F2.5000206@suse.de>

On Wed, Jul 08, 2015 at 09:07:30PM +0200, Andreas Färber wrote:
> Am 07.07.2015 um 19:16 schrieb Andreas Färber:
> > From: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > 
> > 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. Newly added
> > cpu_exec_exit() API handles the deallocation part and this routine is
> > called from generic CPU instance_finalize.
> > 
> > Note: This new CPU enumeration is for !CONFIG_USER_ONLY only.
> > CONFIG_USER_ONLY continues to have the old enumeration logic.
> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> > Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> > Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> > [AF: max_cpus -> MAX_CPUMASK_BITS]
> > Signed-off-by: Andreas Färber <afaerber@suse.de>
> > ---
> >  exec.c            | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
> >  include/qom/cpu.h |  1 +
> >  qom/cpu.c         |  7 +++++++
> >  3 files changed, 58 insertions(+), 5 deletions(-)
> > 
> > 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 **errp)
> >  #if defined(CONFIG_USER_ONLY)
> >      cpu_list_lock();
> >  #endif
> > -    cpu_index = 0;
> > -    CPU_FOREACH(some_cpu) {
> > -        cpu_index++;
> > +    cpu_index = cpu->cpu_index = 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 = 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);
> 

Sorry about this breakage, I should have been more careful.

If this doesn't involve additional effort, feel free to drop these 3 patches,
I will rework them in the next cycle.

Regards,
Bharata.

  reply	other threads:[~2015-07-09  3:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 17:16 [Qemu-devel] [PULL v2 00/22] QOM CPUState patch queue 2015-07-07 Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 01/22] cpu: No need to zero-initialize CPUState::numa_node Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 02/22] cpu: Initialize breakpoint/watchpoint lists in cpu_common_initfn() Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 03/22] cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 04/22] cpu: Add Error argument to cpu_exec_init() Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 05/22] cpu: Convert cpu_index into a bitmap Andreas Färber
2015-07-08 19:07   ` Andreas Färber
2015-07-09  3:16     ` Bharata B Rao [this message]
2015-07-09  3:25       ` Peter Crosthwaite
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 06/22] target-ppc: Move cpu_exec_init() call to realize function Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 07/22] translate-all: Change tb_flush() env argument to cpu Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 08/22] gdbstub: Change gdbserver_fork() to accept cpu instead of env Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 09/22] cpu: Change tcg_cpu_exec() arg to cpu, not env Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 10/22] cpu: Change cpu_exec_init() " Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 11/22] cpu-exec: Purge all uses of ENV_GET_CPU() Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 12/22] cpu: Add wrapper for the set_pc() hook Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 13/22] gdbstub: Use cpu_set_pc() helper Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 14/22] hw/arm/boot: Use cpu_set_pc() Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 15/22] microblaze: boot: " Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 16/22] disas: Add print_insn to disassemble info Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 17/22] disas: QOMify target specific setup Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 18/22] disas: arm-a64: Make printfer and stream variable Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 19/22] disas: arm: QOMify target specific disas setup Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 20/22] disas: microblaze: " Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 21/22] disas: cris: Fix 0 buffer length case Andreas Färber
2015-07-07 17:16 ` [Qemu-devel] [PULL v2 22/22] disas: cris: QOMify target specific disas setup Andreas Färber
2015-07-08 11:33 ` [Qemu-devel] [PULL v2 00/22] QOM CPUState patch queue 2015-07-07 Peter Maydell
2015-07-08 17:39   ` Andreas Färber
2015-07-08 18:50     ` Peter Maydell
2015-07-08 18:53       ` Andreas Färber
2015-07-08 19:01   ` Peter Crosthwaite
2015-07-08 19:23     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150709031619.GA3352@in.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=crosthwaite.peter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).