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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 21 Apr 2023 09:23:42 +0000
  • Accept-language: zh-CN, 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=WJzPHrLFK3QUDnsTvRJXvfb1sdWR+FKnafCYtNj4YeQ=; b=R1CU0yVvi4R6zX8tIFTSxZGxP3XO/5gxOqv+ndMHBx/wwsqGN1p9l4Sc1CZFqBTAiUZ6CZ7I1fjlhFZ+R2tsjPu7OmuHBVkyDoAkKOeHUCDj8lLcbzLDokEM8NPTUhVaa+v/13W1Gg0IglROy8lNkSSKWV58a7ksQm8mV4GiPqtrUfVLouZlgIhZGPqif9X/0l5dyiVFb76/zSaui+1LtekgKZwpKyxJe+XqFEGakT/rLXq1xbYDzpo8EMW60zpB2taHBJhYyCZirvyvxBVCLvxUUYh6lu5ySFYlWhs+LIeNz/9L9KeEX/vNDIt8p7RFoi638FbAjuzYJ+KIP6bW+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eN8vbNwyPsSQ8eWUPQGJBV6uqCRk6tVlMIjbUC0dwiPMSMt8/IaxdmW1ZlxRTcGFB4QX00l0kbC4EJxuHEm5W3dJL5L+SHM3a4OwjiOYQhB2gtrRNMEiITm0MZvuLdxcqtvza+fKi4uO8tgb4eaDzg6t8y4mIrEC2fLWdqC7fQ27bDrHlZoz5IMzlf7IrV7tUtOmRDln0bEIOffyCvFuqxWvMiQfx4QYY0Y8Z7ig2DNIseZuOgovn3bzgJCKkqaaoLX3kd5xiHXXV5pxZahm+d49LBoh1zcyuOd7xCzb/f9DYMsvOgGxerwyz7GwgvXg+5Lzf0HE05u/NZ+xuSB79w==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <Wei.Chen@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: Fri, 21 Apr 2023 09:24:31 +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: AQHZc3rmCrt50C+BaEmmIgaK9uo9ea80IxGAgAFPzpA=
  • Thread-topic: [PATCH v3 03/17] xen/arm: implement node distance helpers for Arm

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Subject: Re: [PATCH v3 03/17] xen/arm: implement node distance helpers for
> Arm
> > As both x86 and Arm have implemented __node_distance, so we move
> > its definition from asm/numa.h to xen/numa.h.
> 
> Nit: You mean "declaration", not "definition".

Correct, I overlooked this miswording in commit message while going
through your comments in v2. will correct in v4.

> 
> > At same time, the
> > outdated u8 return value of x86 has been changed to unsigned char.
> >
> > Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> > Signed-off-by: Henry Wang <Henry.Wang@xxxxxxx>
> 
> non-Arm parts; to more it's not applicable anyway:
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>

I will add # non-Arm parts in the end of the tag and take the tag.

> 
> > --- a/xen/arch/arm/numa.c
> > +++ b/xen/arch/arm/numa.c
> > @@ -28,6 +28,11 @@ enum dt_numa_status {
> >
> >  static enum dt_numa_status __ro_after_init device_tree_numa =
> DT_NUMA_DEFAULT;
> >
> > +static unsigned char __ro_after_init
> > +node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = {
> > +    { 0 }
> > +};
> 
> Nit: There's no (incomplete or complete) initializer needed here, if
> all you're after is having all slots set to zero.

Yeah, I agree with you, so I will drop the initializer in v4, however...

> 
> However, looking at the code below, don't you mean to have the array
> pre-set to all NUMA_NO_DISTANCE?

...I am a bit puzzled about why pre-setting the array to all
NUMA_NO_DISTANCE matters here, as I think the node distance map will
be populated when parsing the device tree anyway no matter what their
initial values.

> 
> > +    /* NUMA defines 0xff as an unreachable node and 0-9 are undefined */
> > +    if ( distance >= NUMA_NO_DISTANCE ||
> > +         (distance >= NUMA_DISTANCE_UDF_MIN &&
> 
> Compilers may warn about comparison of "unsigned int" to be >= 0. I'm
> not sure about the usefulness of the NUMA_DISTANCE_UDF_MIN define in
> the first place, so maybe best drop it and its use here?

Yeah, will do that in v4.

> 
> > +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;
> 
> Wouldn't it make sense to have the "from == to" special case ahead of
> this (rather than further down), thus yielding a sensible result for
> from == to == 0? And else return NUMA_NO_DISTANCE, thus having a
> sensible result also for any from/to != 0?

Could you please elaborate a bit more about why 0 matters here? As from
my understanding,
(1) If from == to, then we set the distance to NUMA_LOCAL_DISTANCE
which represents the diagonal of the matrix.
(2) If from and to is in the matrix range, then we return
node_distance_map[from][to].
(3) Other cases we return NUMA_NO_DISTANCE.

So this diff is enough:
diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
@@ -98,6 +98,9 @@ void numa_detect_cpu_node(unsigned int cpu)

 unsigned char __node_distance(nodeid_t from, nodeid_t to)
 {
+    if ( from == to )
+        return NUMA_LOCAL_DISTANCE;
+
     /* When NUMA is off, any distance will be treated as remote. */
     if ( numa_disabled() )
         return NUMA_REMOTE_DISTANCE;
@@ -109,7 +112,7 @@ unsigned char __node_distance(nodeid_t from, nodeid_t to)
      */
     if ( from >= ARRAY_SIZE(node_distance_map) ||
          to >= ARRAY_SIZE(node_distance_map[0]) )
-        return from == to ? NUMA_LOCAL_DISTANCE : NUMA_NO_DISTANCE;
+        return NUMA_NO_DISTANCE;

     return node_distance_map[from][to];
 }

Would you mind pointing out why my understanding is wrong? Thanks!

> 
> > +    /*
> > +     * 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 >= ARRAY_SIZE(node_distance_map) ||
> > +         to >= ARRAY_SIZE(node_distance_map[0]) )
> > +        return from == to ? NUMA_LOCAL_DISTANCE : NUMA_NO_DISTANCE;
> > +
> > +    return node_distance_map[from][to];
> > +}
> > +
> > +EXPORT_SYMBOL(__node_distance);
> 
> What is this needed for?

Will drop it.

Kind regards,
Henry

> 
> Jan

 


Rackspace

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