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

RE: [PATCH v2 03/17] xen/arm: implement node distance helpers for Arm


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Thu, 12 Jan 2023 06:31:43 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w5MJBmVnVO9Knbigf1UQ+k5MGPHNfykIyXH4ko+N7FY=; b=agIBrEMm3g5Gyq/nB92jqxg2BBwMXx4kj/dY/w38oxpxIZq4SrHNTw9E1ZGC5lmXEx9cKwKH7aFrPl6ZpH2kexKNUcQYB3vJI/1a9H5IprFfTPbkeZKr1X2Ie4PFj8hR4lNnIYlMOK+Gto5Cup3S5fmBJS8jThz3UJZd42ZCH5WcMknDYpR5KOoOQw/sX5K8zUv8yNqxwYytNdbIiQ4GMPqtFh1Z7QCsWy68TCx3m8FXBXODn+LXLQMhPTvv4UHJFhna0UUtGfky0BKkm+YPEgyRNcVz9Ej0/SKnStPq0uESgJJYw6EKmrlraleoA7pbJe65b4ibPKDLlgguYJyJXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSjZ+2Gsl7jLzWty6iNRC6V5l51MHA50gdDs2QGH4HAvHe8CN/3diACot7xNLE9b3cmE6aKS8ufyIs/xLW46LaHsqRrquh9bRN7euiYNtRXWY1z4ugke6H/86x/EDBsnLh2l5nytUIiOvgAq6k51Dbjl+wvBVSx4SxlKuR4Dn9sm5RFWom6XB14gote+GSUgP0yHE30wzcOT34o7SOucFOR8gxeDaUrxy9BPGxNWpIOwJG7kXUw5/IrXrJDOyh2SCbgAiGBNtU8XTjHtd3y397m+7sg3m3etZJ+XXQX3Sqj7IVmAFjAa7UNK/mC48vYLvAcN+fl6EdXuX8Nr7Bry4g==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: nd <nd@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 12 Jan 2023 06:32:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZJNEfrPi0xon1hUWBAoFjpzsCdK6X3MQAgAJ3JNA=
  • Thread-topic: [PATCH v2 03/17] xen/arm: implement node distance helpers for Arm

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2023年1月11日 0:47
> To: Wei Chen <Wei.Chen@xxxxxxx>
> Cc: nd <nd@xxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>; Julien
> Grall <julien@xxxxxxx>; Bertrand Marquis <Bertrand.Marquis@xxxxxxx>;
> Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>; Wei
> Liu <wl@xxxxxxx>; Roger Pau Monné <roger.pau@xxxxxxxxxx>; xen-
> devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 03/17] xen/arm: implement node distance helpers for
> Arm
> 
> On 10.01.2023 09:49, Wei Chen wrote:
> > --- a/xen/arch/arm/include/asm/numa.h
> > +++ b/xen/arch/arm/include/asm/numa.h
> > @@ -28,6 +28,20 @@ enum dt_numa_status {
> >      DT_NUMA_OFF,
> >  };
> >
> > +/*
> > + * In ACPI spec, 0-9 are the reserved values for node distance,
> > + * 10 indicates local node distance, 20 indicates remote node
> > + * distance. Set node distance map in device tree will follow
> > + * the ACPI's definition.
> > + */
> > +#define NUMA_DISTANCE_UDF_MIN   0
> > +#define NUMA_DISTANCE_UDF_MAX   9
> > +#define NUMA_LOCAL_DISTANCE     10
> > +#define NUMA_REMOTE_DISTANCE    20
> 
> In the absence of a caller of numa_set_distance() it is entirely unclear
> whether this tying to ACPI used values is actually appropriate.
> 

From Kernel's NUMA device tree binding, it seems DT NUMA are reusing
ACPI used values for distances [1].

> > --- a/xen/arch/arm/numa.c
> > +++ b/xen/arch/arm/numa.c
> > @@ -2,7 +2,7 @@
> >  /*
> >   * Arm Architecture support layer for NUMA.
> >   *
> > - * Copyright (C) 2021 Arm Ltd
> > + * Copyright (C) 2022 Arm Ltd
> 
> I don't think it makes sense to change such after the fact. And certainly
> not in an unrelated patch.
> 

I will retore it, and add a SPDX header.

> > @@ -22,6 +22,11 @@
> >
> >  static enum dt_numa_status __read_mostly device_tree_numa;
> >
> > +static unsigned char __read_mostly
> > +node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = {
> > +    { 0 }
> > +};
> 
> __ro_after_init?
> 

Yes.

> > @@ -42,3 +47,48 @@ int __init arch_numa_setup(const char *opt)
> >  {
> >      return -EINVAL;
> >  }
> > +
> > +void __init numa_set_distance(nodeid_t from, nodeid_t to,
> > +                              unsigned int distance)
> > +{
> > +    if ( from >= MAX_NUMNODES || to >= MAX_NUMNODES )
> > +    {
> > +        printk(KERN_WARNING
> > +               "NUMA: invalid nodes: from=%"PRIu8" to=%"PRIu8"
> MAX=%"PRIu8"\n",
> > +               from, to, MAX_NUMNODES);
> > +        return;
> > +    }
> > +
> > +    /* NUMA defines 0xff as an unreachable node and 0-9 are undefined
> */
> > +    if ( distance >= NUMA_NO_DISTANCE ||
> > +        (distance >= NUMA_DISTANCE_UDF_MIN &&
> 
> Nit: Indentation.
> 

Ok.

> > +         distance <= NUMA_DISTANCE_UDF_MAX) ||
> > +        (from == to && distance != NUMA_LOCAL_DISTANCE) )
> > +    {
> > +        printk(KERN_WARNING
> > +               "NUMA: invalid distance: from=%"PRIu8" to=%"PRIu8"
> distance=%"PRIu32"\n",
> > +               from, to, distance);
> > +        return;
> > +    }
> > +
> > +    node_distance_map[from][to] = distance;
> > +}
> > +
> > +unsigned char __node_distance(nodeid_t from, nodeid_t to)
> > +{
> > +    /* When NUMA is off, any distance will be treated as remote. */
> > +    if ( numa_disabled() )
> > +        return NUMA_REMOTE_DISTANCE;
> > +
> > +    /*
> > +     * Check whether the nodes are in the matrix range.
> > +     * When any node is out of range, except from and to nodes are the
> > +     * same, we treat them as unreachable (return 0xFF)
> > +     */
> > +    if ( from >= MAX_NUMNODES || to >= MAX_NUMNODES )
> 
> I guess using ARRAY_SIZE() here would be more future-proof.
> 

I will use it in next version.

[1]https://www.kernel.org/doc/Documentation/devicetree/bindings/numa.txt

Thanks,
Wei Chen

> Jan

 


Rackspace

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