All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: stewart@linux.vnet.ibm.com, benh@au1.ibm.com, aik@ozlabs.ru,
	agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	paulus@au1.ibm.com,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/1] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO)
Date: Tue, 10 Nov 2015 16:56:38 -0800	[thread overview]
Message-ID: <20151111005638.GB4644@linux.vnet.ibm.com> (raw)
In-Reply-To: <20151111001758.GK18558@voom.redhat.com>

On 11.11.2015 [11:17:58 +1100], David Gibson wrote:
> On Mon, Nov 09, 2015 at 08:22:32PM -0800, Sukadev Bhattiprolu wrote:
> > David Gibson [david@gibson.dropbear.id.au] wrote:
> > | On Wed, Nov 04, 2015 at 03:06:05PM -0800, Sukadev Bhattiprolu wrote:
> > | > Implement RTAS_SYSPARM_PROCESSOR_MODULE_INFO parameter to rtas_get_sysparm()
> > | > call in qemu. This call returns the processor module (socket), chip and core
> > | > information as specified in section 7.3.16.18 of PAPR v2.7.
> > | 
> > | PAPR v2.7 isn't available publically.  For upstream patches, please
> > | reference LoPAPR instead (where it's section 7.3.16.17 AFAICT).
> > 
> > Ok.
> > 
> > | 
> > | > We walk the /proc/device-tree to determine the number of chips, cores and
> > | > modules in the _host_ system and return this info to the guest application
> > | > that makes the rtas_get_sysparm() call.
> > | > 
> > | > We currently hard code the number of module_types to 1, but we should determine
> > | > that dynamically somehow later.
> > | > 
> > | > Thanks to input from Nishanth Aravamudan and Alexey Kardashevsk.
> > | > 
> > | > Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> > | 
> > | This isn't ready to go yet - you need to put some more consideration
> > | into the uncommon cases: PR KVM, TCG and non-Power hosts.
> > 
> > Ok. Is there a we can make this code applicable only a Powerpc host?
> > (would moving this code to target-ppc/kvm.c do that?)
> 
> Yes, moving it to target-ppc/kvm.c would mostly do that.  You'd need
> some logic to make sure it fails gracefully in other cases, of course.
> 
> [snip]
> > | >      switch (parameter) {
> > | > +    case RTAS_SYSPARM_PROCESSOR_MODULE_INFO: {
> > | > +        int i;
> > | > +        int offset = 0;
> > | > +        int size;
> > | > +        struct rtas_module_info modinfo;
> > | > +
> > | > +        if (rtas_get_module_info(&modinfo)) {
> > | > +            break;
> > | > +        }
> > | 
> > | So, you handle the variable size of this structure before sending it
> > | to the guest, but you don't handle it in allocation of the structure
> > | right here.  You'll get away with that because for now you only ever
> > | have one entry in the sockets array, but it's a bit icky.
> > 
> > Can we assume that the size is static for now...
> > | 
> > | > +
> > | > +        size = sizeof(modinfo);
> > | > +        size += (modinfo.module_types - 1) * sizeof(struct rtas_socket_info);
> > | 
> > | More seriously, this calculation will break horribly if you change the
> > | size of the array in struct rtas_module_info.
> > 
> > and just set 'size' to sizeof(modinfo)?.
> 
> For purposes of allocation you could just use a fixed size.  But the
> guest might get confused by additional data beyond the declared size,
> so you do need to get the value correct that you send back to the guest.
> 
> [snip]
> > | > +/*
> > | > + * Each module's (aka socket's) id is contained in the 'ibm,hw-module-id'
> > | > + * file in the "xscom" directory (/proc/device-tree/xscom*). Similarly each
> > | > + * chip's id is contained in the 'ibm,chip-id' file in the xscom directory.
> > | > + *
> > | > + * A module can contain more than one chip and a chip can contain more
> > | > + * than one core. So there are likely to be duplicates in the module
> > | > + * and chip identifiers (i.e more than one xscom directory can contain
> > | > + * the same module/chip id).
> > | > + *
> > | > + * Search the xscom directories and count the number of _UNIQUE_ module
> > | > + * and chip identifiers in the system.
> > | 
> > | There's no direct way to go from a core
> > | (i.e. /proc/device-tree/cpus/cpu@NNN) to the corresponding chip and/or
> > | module?
> > 
> > Yes, it would logical to find the chip and module from the core :-)
> > 
> > While 'ibm,chip-id' is in the core dir (/proc/device-tree/cpus/PowerPC,*/), 
> > the 'ibm,hw-module-id' is not there (on my Tuleta system). Maybe the
> > 'ibm,hw-module-id' will be added in the future?
> 
> Hm, I see.  Is there any device node that represents the "chip"?
> 
> > I am using the xscom node to be consistent in counting chips and modules.
> 
> The trouble with xscom is that it's extremely specific to the way the
> current IBM servers present things.  It won't work on other types of
> host machine (which could happen with PR KVM), and could even break if
> IBM changes the way it organizes the SCOMs in a future machine.
> 
> Working from the nodes in /cpus still has some dependencies on IBM
> specific properties, but it's at least partially based on OF
> standards.
> 
> There's also another possible approach here, though I don't know if it
> will work.  Instead of looking directly in the device tree, try to get
> the information from lscpu, or libosinfo.  That would at least give
> you some hope of providing meaningful information on other host types.

Heh, the issue that is underlying all of this, is that `lscpu` itself is
quite wrong.

On PAPR-compliant hypervisors (well, PowerVM, at least), the only
supported means of determining the underlying hardware CPU information
(which is what licensing models want in the end), is to use this RTAS
call in an LPAR. `lscpu` is explicitly incorrect in these environments
(it's values are "derived" from sysfs and some are adjusted to ensure
the division of values works out).

So, we are trying to at least resolve what PowerKVM guest can see by
supporting this RTAS call there. We should report *something* to the
guest, if possible, and we can adjust what is reported to the guests as
we go, from the host perspective.

I haven't followed along too closely in this thread, but woudl it be
reasonable to only report this RTAS call as being supported under KVM?
How are other RTAS calls dealt with for PR and non-IBM models currently?

-Nish

  reply	other threads:[~2015-11-11  0:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 23:06 [Qemu-devel] [PATCH v2 1/1] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO) Sukadev Bhattiprolu
2015-11-09  1:57 ` Alexey Kardashevskiy
2015-11-09  5:01   ` David Gibson
2015-11-10  3:57   ` Sukadev Bhattiprolu
2015-11-10  4:25     ` Alexey Kardashevskiy
2015-11-10  4:46       ` Sukadev Bhattiprolu
2015-11-10  6:58         ` Alexey Kardashevskiy
2015-11-10 18:27           ` Sukadev Bhattiprolu
2015-11-09  4:58 ` David Gibson
2015-11-10  4:22   ` Sukadev Bhattiprolu
2015-11-10  9:53     ` Thomas Huth
2015-11-13 20:29       ` Sukadev Bhattiprolu
2015-11-11  0:17     ` David Gibson
2015-11-11  0:56       ` Nishanth Aravamudan [this message]
2015-11-11  1:41         ` David Gibson
2015-11-11 22:10           ` Nishanth Aravamudan
2015-11-12  4:47             ` David Gibson
2015-11-12 16:46               ` Nishanth Aravamudan
2015-12-01  3:41                 ` David Gibson
2015-12-05  1:04                   ` Nishanth Aravamudan
2015-12-10  3:55                     ` David Gibson
2015-11-13 20:21       ` Sukadev Bhattiprolu

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=20151111005638.GB4644@linux.vnet.ibm.com \
    --to=nacc@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=benh@au1.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=paulus@au1.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stewart@linux.vnet.ibm.com \
    --cc=sukadev@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.