All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: mjrosato@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	ehabkost@redhat.com, aik@ozlabs.ru, agraf@suse.de,
	mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org,
	tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com,
	pbonzini@redhat.com, afaerber@suse.de,
	david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PATCH v7 12/13] qmp: Add query-ppc-cpu-cores command
Date: Mon, 1 Feb 2016 14:13:58 +0530	[thread overview]
Message-ID: <20160201084358.GA8516@in.ibm.com> (raw)
In-Reply-To: <20160129164506.4402dab3@nial.brq.redhat.com>

On Fri, Jan 29, 2016 at 04:45:06PM +0100, Igor Mammedov wrote:
> On Thu, 28 Jan 2016 11:19:54 +0530
> Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> 
> > Show the details of PPC CPU cores via a new QMP command.
> > 
> > TODO: update qmp-commands.hx with example
> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > ---
> >  hw/ppc/cpu-core.c               | 77 +++++++++++++++++++++++++++++++++++++++++
> >  qapi-schema.json                | 31 +++++++++++++++++
> >  qmp-commands.hx                 | 51 +++++++++++++++++++++++++++
> >  stubs/Makefile.objs             |  1 +
> >  stubs/qmp_query_ppc_cpu_cores.c | 10 ++++++
> >  5 files changed, 170 insertions(+)
> >  create mode 100644 stubs/qmp_query_ppc_cpu_cores.c
> > 
> > diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c
> > index aa96e79..652a5aa 100644
> > --- a/hw/ppc/cpu-core.c
> > +++ b/hw/ppc/cpu-core.c
> > @@ -9,7 +9,84 @@
> >  #include "hw/ppc/cpu-core.h"
> >  #include "hw/boards.h"
> >  #include <sysemu/cpus.h>
> > +#include <sysemu/kvm.h>
> >  #include "qemu/error-report.h"
> > +#include "qmp-commands.h"
> > +
> > +/*
> > + * QMP: info ppc-cpu-cores
> > + */
> > +static int qmp_ppc_cpu_list(Object *obj, void *opaque)
> > +{
> > +    CpuInfoList ***prev = opaque;
> > +
> > +    if (object_dynamic_cast(obj, TYPE_POWERPC_CPU)) {
> > +        CpuInfoList *elem = g_new0(CpuInfoList, 1);
> > +        CpuInfo *s = g_new0(CpuInfo, 1);
> > +        CPUState *cs = CPU(obj);
> > +        PowerPCCPU *cpu = POWERPC_CPU(cs);
> > +        CPUPPCState *env = &cpu->env;
> > +
> > +        cpu_synchronize_state(cs);
> > +        s->arch = CPU_INFO_ARCH_PPC;
> > +        s->current = (cs == first_cpu);
> > +        s->CPU = cs->cpu_index;
> > +        s->qom_path = object_get_canonical_path(obj);
> > +        s->halted = cs->halted;
> > +        s->thread_id = cs->thread_id;
> > +        s->u.ppc = g_new0(CpuInfoPPC, 1);
> > +        s->u.ppc->nip = env->nip;
> > +
> > +        elem->value = s;
> > +        elem->next = NULL;
> > +        **prev = elem;
> > +        *prev = &elem->next;
> > +    }
> > +    object_child_foreach(obj, qmp_ppc_cpu_list, opaque);
> > +    return 0;
> > +}
> > +
> > +static int qmp_ppc_cpu_core_list(Object *obj, void *opaque)
> > +{
> > +    PPCCPUCoreList ***prev = opaque;
> > +
> > +    if (object_dynamic_cast(obj, TYPE_POWERPC_CPU_CORE)) {
> > +        DeviceClass *dc = DEVICE_GET_CLASS(obj);
> > +        DeviceState *dev = DEVICE(obj);
> > +
> > +        if (dev->realized) {
> > +            PPCCPUCoreList *elem = g_new0(PPCCPUCoreList, 1);
> > +            PPCCPUCore *s = g_new0(PPCCPUCore, 1);
> > +            CpuInfoList *cpu_head = NULL;
> > +            CpuInfoList **cpu_prev = &cpu_head;
> > +
> > +            if (dev->id) {
> > +                s->has_id = true;
> > +                s->id = g_strdup(dev->id);
> > +            }
> > +            s->hotplugged = dev->hotplugged;
> > +            s->hotpluggable = dc->hotpluggable;
> > +            qmp_ppc_cpu_list(obj, &cpu_prev);
> > +            s->threads = cpu_head;
> > +            elem->value = s;
> > +            elem->next = NULL;
> > +            **prev = elem;
> > +            *prev = &elem->next;
> > +        }
> > +    }
> > +
> > +    object_child_foreach(obj, qmp_ppc_cpu_core_list, opaque);
> > +    return 0;
> > +}
> > +
> > +PPCCPUCoreList *qmp_query_ppc_cpu_cores(Error **errp)
> > +{
> > +    PPCCPUCoreList *head = NULL;
> > +    PPCCPUCoreList **prev = &head;
> > +
> > +    qmp_ppc_cpu_core_list(qdev_get_machine(), &prev);
> > +    return head;
> > +}
> >  
> >  static int ppc_cpu_core_realize_child(Object *child, void *opaque)
> >  {
> > diff --git a/qapi-schema.json b/qapi-schema.json
> > index 8d04897..0902697 100644
> > --- a/qapi-schema.json
> > +++ b/qapi-schema.json
> > @@ -4083,3 +4083,34 @@
> >  ##
> >  { 'enum': 'ReplayMode',
> >    'data': [ 'none', 'record', 'play' ] }
> > +
> > +##
> > +# @PPCCPUCore:
> > +#
> > +# Information about PPC CPU core devices
> > +#
> > +# @hotplugged: true if device was hotplugged
> > +#
> > +# @hotpluggable: true if device if could be added/removed while machine is running
> > +#
> > +# Since: 2.6
> > +##
> > +
> > +{ 'struct': 'PPCCPUCore',
> > +  'data': { '*id': 'str',
> > +            'hotplugged': 'bool',
> > +            'hotpluggable': 'bool',
> > +            'threads' : ['CpuInfo']
> > +          }
> > +}
> Could it be made more arch independent?

Except that it is called PPCCPUCore, the fields are actually arch
neutral with 'threads' element defined as CpuInfo that gets interpreted
as arch-specific CpuInfo based on the target architecture.

In any case, this patchset adds PowerPC specific CPU core device that
sPAPR target implements. This is kept arch-specific in order to make it
more acceptable in short term in case arch-neutral, generic CPU hotplug
solutions take long time for reaching consensus.

> Perhaps it might make sense to replace 'threads'
> with qom-path so tools could inspect it in more detail
> if needed?

Hmm 'threads' is of CpuInfo type which already has qom-path inside it.
Did I get your question right ?

> 
> Also looking from cpu hotplug pov it would be nice
> to have at top level
>   - device type that tools could use with device_add
>   - display supported least granularity from topology pov
>     like node,socket[,core,[thread]] 'address' parameters
>   - display in CPU list also possible CPUs where only
>     'type' and 'address' parameters are present.
> 
> so above could look like:
> { 'struct': 'CPU',
>   'data': {
>             'type': 'str'
>             'node': 'int',
>             'socket': 'int',
>             '*core' : 'int',
>             '*thread' : 'int',
>             '*id': 'str',
>             '*hotplugged': 'bool',
>             '*hotpluggable': 'bool',
>             '*qom-path' : 'str'
>           }
> }

This is PowerPC specific where only core granularity hotplug makes
sense, but if it helps libvirt or other tools, I could add those fields.

Regards,
Bharata.

  reply	other threads:[~2016-02-01  8:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28  5:49 [Qemu-devel] [PATCH v7 00/13] sPAPR CPU hotplug Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 01/13] machine: Don't allow CPU toplogies with partially filled cores Bharata B Rao
2016-01-28 19:04   ` Eduardo Habkost
2016-01-29  3:52   ` David Gibson
2016-01-29 14:24     ` Eduardo Habkost
2016-01-29 15:10       ` Igor Mammedov
2016-01-29 15:36         ` Eduardo Habkost
2016-01-29 16:52           ` Igor Mammedov
2016-01-29 17:24             ` Eduardo Habkost
2016-02-01  9:41               ` Igor Mammedov
2016-02-03 17:38                 ` Eduardo Habkost
2016-02-04  9:38                   ` Igor Mammedov
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 02/13] exec: Remove cpu from cpus list during cpu_exec_exit() Bharata B Rao
2016-01-28 19:19   ` Eduardo Habkost
2016-01-29  6:14     ` Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 03/13] exec: Do vmstate unregistration from cpu_exec_exit() Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 04/13] cpu: Don't realize CPU from cpu_generic_init() Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 05/13] cpu: Reclaim vCPU objects Bharata B Rao
2016-02-19 15:21   ` Thomas Huth
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 06/13] cpu: Add a sync version of cpu_remove() Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 07/13] xics, xics_kvm: Handle CPU unplug correctly Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 08/13] target-ppc: Introduce PowerPC specific CPU core device Bharata B Rao
2016-02-01  2:39   ` David Gibson
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 09/13] spapr: Enable CPU hotplug for pseries-2.6 and add CPU DRC DT entries Bharata B Rao
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 10/13] spapr: CPU hotplug support Bharata B Rao
2016-02-01  3:07   ` David Gibson
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 11/13] spapr: CPU hot unplug support Bharata B Rao
2016-02-01  3:13   ` David Gibson
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 12/13] qmp: Add query-ppc-cpu-cores command Bharata B Rao
2016-01-28 20:52   ` Eric Blake
2016-01-29  6:34     ` Bharata B Rao
2016-01-29 15:45   ` Igor Mammedov
2016-02-01  8:43     ` Bharata B Rao [this message]
2016-02-01  9:56       ` Igor Mammedov
2016-01-28  5:49 ` [Qemu-devel] [PATCH v7 13/13] hmp: Add "info ppc-cpu-cores" command Bharata B Rao
2016-01-28 21:56   ` Eric Blake
2016-01-29  6:49     ` Bharata B Rao

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=20160201084358.GA8516@in.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mjrosato@linux.vnet.ibm.com \
    --cc=nfont@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=tyreld@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.