[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: Mon, 24 Apr 2023 09:41:51 +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=9O3QSKKiMQmag2nEoAv4P6qdeA1sEqoAcHERrvq+sQM=; b=LoepIrKTgZkDrK/hSKPMVMavFwrj5HRj530K3LDceOR9J1LTuH2HwIXL3mzC627HzbuuvfYpZiUrzkH/DSI6r+A83w07UnqSNAKeLkhJ/crLve/z+HfAmbM7FMP4FBepAouUwU/tWMp4D63nUCtXG9WChxzjVh3EDr9ZGCHO8ZtulPCb2Yd37pBbnOY/oQjRe2+kPkKMIOgLH73cR12NxbHnDGFFYix5dN23HrU3jlZlva6oZvFya/FYXIkmkhLNe+HoZP7pcN76ck894dF50REAtJuQ81I+K70RRR0CbIzxWkthB8+Xi6/zsEj/mANjptsgIs0vAw8UClGF1wUKgA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MgSAb5kjAxsFdggzGHOXIAFcZh1G+HKgySFx01iKA8NDPCVfd1z2gUPEd5zoluL+PG/bDZ+HN7HM41Y4MWtkifx1Z/IFo4k7cGgCqREPWcBajywcPZWs5l11+zJf5Ff/U0CtFAFr9W5YiBIdC9uuikvjcRpf8HJiDUXT/z1s9Aw5oByjvYkoYAZYVLb6nB8dbgZG/97ABR5Ih7mjzYkQervSzWV96Iykkno/Ny8B1lF8fqU+QGZoNmecpDu7jmDfQzclRCa1bE+8tovgns3pyvrIeU0L6RStJ02M5h/tPHafSRy1aaCWwRnaM9wmX3Y++02DYhgG7wNU+81/oIqnNw==
  • 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: Mon, 24 Apr 2023 07:42:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 23.04.2023 07:36, Henry Wang wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@xxxxxxxx>
>>>> 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).
> 
> Correct, I agree. I added a numa_init_distance() function (in patch #12) to
> set all values to NUMA_NO_DISTANCE. The numa_init_distance() will be
> called in the beginning of numa_init().

Why do you need a function for this? As said, this array can be pre-set at
compile time (unless I'm overlooking something).

>>>>> +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. ...
>>
>>>      /* 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).
> 
> Thanks for the explanation! I think I now understand :) Would this diff below
> look good to you then? Appreciate your patience.

Looks largely okay, but possibly one part can now be omitted (see below).

> unsigned char __node_distance(nodeid_t from, nodeid_t to)
>  {
> -    /* When NUMA is off, any distance will be treated as remote. */
> +    if ( from == to )
> +        return NUMA_LOCAL_DISTANCE;
> +
> +    /* When NUMA is off, any distance will be treated as unreachable (0xFF). 
> */

Please avoid mentioning the actual value of 0xFF: This serves no real
purpose (afaict) and is liable to go stale at some point.

>      if ( numa_disabled() )
> -        return NUMA_REMOTE_DISTANCE;
> +        return NUMA_NO_DISTANCE;

With the code below this is now only an optimization. Might be worth
saying so in the comment (assuming having this optimization is deemed
worth it).

Jan

>      /*
>       * 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)
> +     * same, we treat them as unreachable (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 NUMA_NO_DISTANCE;
> 
>      return node_distance_map[from][to];
>  }
> 
> Kind regards,
> Henry
> 
>>
>> Jan
>>




 


Rackspace

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