[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: Henry Wang <Henry.Wang@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 20 Apr 2023 14:38:31 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=4To2x6HVjUmz8BqSUY476S/NfcKyHY0DK5xyL1YWgTU=; b=ZryiYXxG8ax7+V8vLQYQ6J8VOd9E9AOIPL4D/2nRLPVK144SxoaX6J/wS826P8IXFsOuVWweSotRq/df7OXfjAB+K6ff5GWzBlLdPU1rVchFFyiZbL9ctJdpYMXNw/HjRwvWUlo5jGbynd+q4TGWrISTBMrkTJ4t0XTPyEcuH39QKswb2X8ijpOMO+SrOEy1QN5QJ8tnubhuEO4/FqG05zjv0EF4Sy64WnzmXZ8rPHqz4ngoEn92tGaAETDWQiYexWHb42QI8Fy9U9vJsNIEYEUdGjnuXNGzHLYMXNva6VZiTcyqUiyekUQwCYbElD95dLm91OdlFzs4RaAyGBvalw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fLp900ZfRDhbiUKwT77Mx2VF15lp1wqI+ZOCjpSv2Wvw/Q6SL3EZGYU5FG1b8m2/TWxu5aydywyNxxhf9GmV9GSdLXvFiAPZGlMOZzPibzCXNkgXhRwNu+/glk4pLVgcdAH6V0xYgzxG8FR3HJNhLkIT2k1C94n9f31BOm2IPFLXLmJUx8E4VDPA1x7Z1PeEaU2eBhNeuUJJc+7LLpg4ypu59vUflabMXe+HxkP9uE2WUKh/LomiF0gDcyzYV73JlGZ1xKEj+b6k8WXsqfQ02J8/+uEm25X4Th+gmg+WNwBN1rmKK1qd66TkRes7OpSVnTDI0yTIiUXEW5lg35r7oA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.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
  • Delivery-date: Thu, 20 Apr 2023 12:38:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.04.2023 13:25, Henry Wang wrote:
> From: Wei Chen <wei.chen@xxxxxxx>
> 
> We will parse NUMA nodes distances from device tree. So we need
> a matrix to record the distances between any two nodes we parsed.
> Accordingly, we provide this node_set_distance API for device tree
> NUMA to set the distance for any two nodes in this patch. When
> NUMA initialization failed, __node_distance will return
> NUMA_REMOTE_DISTANCE, this will help us avoid doing rollback
> for distance maxtrix when NUMA initialization failed.
> 
> 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".

> 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>

> --- 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.

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

> @@ -48,3 +53,50 @@ 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 >= ARRAY_SIZE(node_distance_map) ||
> +         to >= ARRAY_SIZE(node_distance_map[0]) )
> +    {
> +        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 &&

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?

> +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?

> +    /*
> +     * 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?

Jan



 


Rackspace

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