[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [XEN RFC PATCH 22/40] xen/arm: introduce a helper to parse device tree processor node


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Mon, 23 Aug 2021 08:42:42 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T1pkVL8K5qZgRRoA+z/hH++1DUNfMlc5B3covajGPac=; b=dICoyaBRDnySgnpDW75IJ0+f/QP7LlFXHxRyBCxDbN4Ku4phuuF5jiUQgsHxj+MNPPq/lLgy0x0x9Gf3DASIHhvd3q3IDlBz4q81dca/peSAle+QgpwbBRmUwYc7BA1OsQWqBsyJR+x3IKRLtGAab7hMy4kRi/phZV5N2W2rgFzxEWzmoxr+XhsSG79aGYpcNLrjCh6m+NqiuvRJuFDh1eYgTfFs14VMj44CH+RydmxTlNRA93rYud9uA9eCHo85egwnCrPiSj6lYgUoWBaMoiyJVVMromkmjnwRakc+88R1bwLTwHJRDQib0Qe4MeXxleC61Pcq9G6iLTb4aBFonw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YYKtuQv6YX9SHMsMA6fRcc5es2x0jC14SMpMM/n6NpO4GyIkAy8JgsTE3oJl4LJ56WYjZccsJchJpYyLDPy8bO0Y70lNpljrKPzmI6uJgHjOW/8eyTpSGqhww9AM+5gfvEhzbMGIf9WsDeFtQaH0ZgrGuuR4xtqJ2PeEGGfcFhdMcIXw4B2zdpKhJh9z6Rgtm54cnZAScOYygZ47+tVWNIEehL6hL8UMhgT7YB7WUBXNhZc8JKfSalqlQa2Q/x7iq+fG7fGDq09z7xXDHvxcRdxFINP7k9WOIE+LH0eWwd8GqUSxsn6lZHl0T7fqIwEeuNIQnp5SxGPi+d/g/TAKZg==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Delivery-date: Mon, 23 Aug 2021 08:42:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXjps9W9pBfq916EKAfG5ObJRyjat7LYKAgAWqNNA=
  • Thread-topic: [XEN RFC PATCH 22/40] xen/arm: introduce a helper to parse device tree processor node

Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: 2021年8月20日 2:10
> To: Wei Chen <Wei.Chen@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx;
> sstabellini@xxxxxxxxxx; jbeulich@xxxxxxxx
> Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
> Subject: Re: [XEN RFC PATCH 22/40] xen/arm: introduce a helper to parse
> device tree processor node
> 
> Hi Wei,
> 
> On 11/08/2021 11:24, Wei Chen wrote:
> > Processor NUMA ID information is stored in device tree's processor
> > node as "numa-node-id". We need a new helper to parse this ID from
> > processor node. If we get this ID from processor node, this ID's
> > validity still need to be checked. Once we got a invalid NUMA ID
> > from any processor node, the device tree will be marked as NUMA
> > information invalid.
> >
> > Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> > ---
> >   xen/arch/arm/numa_device_tree.c | 41 +++++++++++++++++++++++++++++++--
> >   1 file changed, 39 insertions(+), 2 deletions(-)
> >
> > diff --git a/xen/arch/arm/numa_device_tree.c
> b/xen/arch/arm/numa_device_tree.c
> > index 1c74ad135d..37cc56acf3 100644
> > --- a/xen/arch/arm/numa_device_tree.c
> > +++ b/xen/arch/arm/numa_device_tree.c
> > @@ -20,16 +20,53 @@
> >   #include <xen/init.h>
> >   #include <xen/nodemask.h>
> >   #include <xen/numa.h>
> > +#include <xen/device_tree.h>
> > +#include <asm/setup.h>
> >
> >   s8 device_tree_numa = 0;
> > +static nodemask_t processor_nodes_parsed __initdata;
> >
> > -int srat_disabled(void)
> > +static int srat_disabled(void)
> >   {
> >       return numa_off || device_tree_numa < 0;
> >   }
> >
> > -void __init bad_srat(void)
> > +static __init void bad_srat(void)
> >   {
> >       printk(KERN_ERR "DT: NUMA information is not used.\n");
> >       device_tree_numa = -1;
> >   }
> > +
> > +/* Callback for device tree processor affinity */
> > +static int __init dtb_numa_processor_affinity_init(nodeid_t node)
> > +{
> > +    if ( srat_disabled() )
> > +        return -EINVAL;
> > +    else if ( node == NUMA_NO_NODE || node >= MAX_NUMNODES ) {
> > +           bad_srat();
> > +           return -EINVAL;
> 
> You seem to have a mix of soft and hard tab in this file. Is there a lot
> of the code that was directly copied from Linux? If not, then the file
> should be using Xen coding style.
> 

I copied some code from x86, and x86 is Linux style.
So, yes, I should adjust them it Xen coding style.
I will do it in next version.

> > +   }
> > +
> > +    node_set(node, processor_nodes_parsed);
> > +
> > +    device_tree_numa = 1;
> > +    printk(KERN_INFO "DT: NUMA node %u processor parsed\n", node);
> > +
> > +    return 0;
> > +}
> > +
> > +/* Parse CPU NUMA node info */
> > +int __init device_tree_parse_numa_cpu_node(const void *fdt, int node)
> 
> AFAICT, you are going to turn this helper static in a follow-up patch.
> This is a bad practice. Instead, the function should be static from the
> beginning. If it is not possible, then you should re-order the code.
> 
> In this case, I think you can add the boilerplate to parse the NUMA
> information (patch #25) here and then extend it in each patch.
> 
> 

That's make sense, I will try to address it in next version.

> > +{
> > +    uint32_t nid;
> > +
> > +    nid = device_tree_get_u32(fdt, node, "numa-node-id", MAX_NUMNODES);
> > +    printk(XENLOG_WARNING "CPU on NUMA node:%u\n", nid);
> > +    if ( nid >= MAX_NUMNODES )
> > +    {
> > +        printk(XENLOG_WARNING "Node id %u exceeds maximum value\n",
> nid);
> > +        return -EINVAL;
> > +    }
> > +
> > +    return dtb_numa_processor_affinity_init(nid);
> > +}
> >
> 
> Cheers,
> 
> --
> Julien Grall

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.