[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: Fri, 21 Apr 2023 11:40:57 +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=qmAZ9p1cRfWGhYOZ2UGE3s1GOrkkTeFoeuzkkqjL3Ck=; b=aOOmI20xgqJL/qnbVIY/E3DGOEfx3z1l6F06TLcyasAC9a3TWWui6sO6zzS3Z/Zs1Yu5fyXjR+JhE2OqzQsQK3HOXXOdwR2vh7esfheVU3UiNoZADiAlwqQSnt3JO8uH1QjHFC9iJvNvwXod7L6KPR7q01Gg/5w1YdN4MZJ2wC6rNlEVFFweUmHMnWgGxD2yVj6hB6vQG0ore4z0NtYEZHVW6cqQmCfP0prr8IguQNQiC1DnbMGKG2ey+2xPbuKZ1yWkgkFKJSeJ9dlsUA7c52hAJ9Rw1uGcUV49bApR2QVG6exXRILjYeWJaqHEmOvX0YDBA0WHXHv/xWuTJE0lxw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PLeUKQJ2cdPNFHu1Wo+KPVYkdtNaKlzkqgGg7wcYfshJdHquYb0lEmUfe0sAxn4xPSaBJkXjjJzJiP2YY2kFdPcTuSCz+sEiL/D560tNIV8qTUe4mqirpTpN7QTlkIByJed0UcEEfhS04p6zFIwDt3myU6IaUfHyzMHN04tC1sJAqYkh2+GsvnNpvj+ej8P5hbdXAncIoMQ5/b/3TNgIWU/Z0GkVER3DFESPsk8P8olFiNTrE+7auQCctTlJTi5qgxLLtb/IBxWSYgBcVnsew0US1rboU4WJgEVxojOKm4aoMNR0lVXgUmV6Adllm4Ek57z9CPvlYAR9A6qxqhmRwQ==
  • 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" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 21 Apr 2023 09:41:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.04.2023 11:23, Henry Wang wrote:
>> -----Original Message-----
>> From: 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.
> 
> 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.

>From this patch alone it doesn't become clear whether indeed all array
slots (and not just ones for valid nodes) would be populated. I think
the code in the patch here would better not make itself dependent on
behavior of code added subsequently (which may change; recall that a
series may be committed in pieces).

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

When NUMA is off, there's only one node - node 0. Hence 0 has special
meaning in that case.

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

Provided that's set correctly. IOW this interacts with the other comment
(which really I made only after the one here, just that that's of course
not visible from the reply that I sent).

> (3) Other cases we return NUMA_NO_DISTANCE.

And when NUMA is off, it should be NUMA_NO_DISTANCE in _all_ other cases,
i.e. ...

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

... this return is wrong in that case (even if in reality this likely
wouldn't matter much).

Jan

> @@ -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!
> 
> Kind regards,
> Henry




 


Rackspace

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