From: Igor Mammedov <imammedo@redhat.com>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Andreas Färber" <afaerber@suse.de>,
david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PULL v3 05/22] cpu: Convert cpu_index into a bitmap
Date: Tue, 14 Jul 2015 13:47:48 +0200 [thread overview]
Message-ID: <20150714134748.5331caaa@nial.brq.redhat.com> (raw)
In-Reply-To: <20150714103854.GB4827@in.ibm.com>
On Tue, 14 Jul 2015 16:08:54 +0530
Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> On Thu, Jul 09, 2015 at 03:23:55PM +0200, Andreas Färber wrote:
> > 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 | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
> > include/qom/cpu.h | 1 +
> > qom/cpu.c | 7 +++++++
> > 3 files changed, 61 insertions(+), 5 deletions(-)
> >
> > diff --git a/exec.c b/exec.c
> > index ce5fadd..d817e5f 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -526,12 +526,57 @@ void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as)
> > }
> > #endif
> >
> > +#ifndef CONFIG_USER_ONLY
> > +static DECLARE_BITMAP(cpu_index_map, MAX_CPUMASK_BITS);
> > +
> > +static int cpu_get_free_index(Error **errp)
> > +{
> > + int cpu = find_first_zero_bit(cpu_index_map, MAX_CPUMASK_BITS);
> > +
> > + if (cpu >= MAX_CPUMASK_BITS) {
> > + error_setg(errp, "Trying to use more CPUs than max of %d",
> > + MAX_CPUMASK_BITS);
> > + return -1;
> > + }
>
> If this routine and hence cpu_exec_init() (which is called from realize
> routine) don't error out when max_cpus is reached, archs supporting CPU
> hotplug using device_add will find it difficult to fail the realization of
> CPU when hotplugging of more than max_cpus is attempted.
>
> An alternative is to explicitly check for the returned cpu_index
> in realize call within each arch and fail if the cpu_index obtained
> is greater than max_cpus. So for ppc, I could put such a check in
> target-ppc/translate_init:ppc_cpu_realizefn(), but ppc_cpu_realizefn()
> is a common routine for all targets under ppc and some targets like
> ppc64abi32-linux-user don't have visibility to max_cpus which is
> in vl.c.
>
> Any thoughts on the above problem ?
we already have MachineClass.max_cpus which is max
supported limit of machine type.
Perhaps make max_cpus a property of MashineState
>
> Also, is it possible to revisit the problem that use of max_cpus instead
> of MAX_CPUMASK_BITS caused to xlnx-ep108 ?
>
> Regards,
> Bharata.
>
>
next prev parent reply other threads:[~2015-07-14 11:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1436448252-1916-1-git-send-email-afaerber@suse.de>
2015-07-09 13:23 ` [Qemu-devel] [PULL v3 03/22] cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init Andreas Färber
2015-07-09 13:24 ` [Qemu-devel] [PULL v3 13/22] gdbstub: Use cpu_set_pc() helper Andreas Färber
2015-07-09 13:24 ` [Qemu-devel] [PULL v3 21/22] disas: cris: Fix 0 buffer length case Andreas Färber
2015-07-09 13:24 ` [Qemu-devel] [PULL v3 22/22] disas: cris: QOMify target specific disas setup Andreas Färber
2015-07-09 15:22 ` [Qemu-devel] [PULL v3 00/22] QOM CPUState patch queue 2015-07-09 Peter Maydell
2015-07-09 16:32 ` Peter Maydell
[not found] ` <1436448252-1916-6-git-send-email-afaerber@suse.de>
2015-07-14 10:38 ` [Qemu-devel] [PULL v3 05/22] cpu: Convert cpu_index into a bitmap Bharata B Rao
2015-07-14 11:47 ` Igor Mammedov [this message]
2015-07-15 3:42 ` Bharata B Rao
2015-07-15 8:09 ` Igor Mammedov
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=20150714134748.5331caaa@nial.brq.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=bharata@linux.vnet.ibm.com \
--cc=crosthwaite.peter@gmail.com \
--cc=david@gibson.dropbear.id.au \
--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).