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

Re: [PATCH v4 09/17] xen/arm: introduce a helper to parse device tree NUMA distance map


  • To: Henry Wang <Henry.Wang@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 26 Apr 2023 10:15:33 +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=AUVIJJ8M4zMA2gdqaaEFVL9XVXUvzQBeqI9JnyTXkv0=; b=DubAwJ8Bz8myQQPSmkN+0qFqcn75WyahI62JGcHonsZGA78LiZM4NRypdD7fMa0Hxe3ebBfU5XK+5V/GGfieR2hGX4BW5SYWci8L/fary42Sk9Sz3FqYytaqf5seNN2dXPecQBgM99J1ohzx5yH6DEqmgzrS5lW8g8Tcksi1K1l8Z0DzqhYWvMYbIEhttk63nmDxJldut0niUMZXcU1gwd4tFGRWQi3a2SOYc6JlQnNJ/00foNsaulZukMppwybSTuMoTLrRnhPCDhtEOAvYS1VNq/0dM/DygiybaVkX67w90eYCNi8Vv5vKDDsOIK0hmdZv7XOPV35xe68Kws6Vng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fV8eUIoxeD8dpX7aHLfsmuX5F/A1uCGWYGC0BzVk3bVDNxNTclemmj+pH+oj2w5U0wLkXDA/vv9ZP1WUSdx//rNC6FgmWmzElo2A6duadZggmhguC+5L1uyBORgXU6cEHKpNEsB6CnpGDhuoit7fnKjwVjmCQeWUJunRYYt4X4I2FfuNLdgFRH2U5x2K3umgvmtvJZqzblhprzRHFSts7Of92re2ixvzkyeKVjUf/uuAwVfTCPFgvk4V+WLZsJA3AcbRFiBnqUGwj1gJ9Ol7OgUAfjme4obHUEVUJePz38F6HJJ4BTvdB7hc2ED42fghtpu6SwIXB6GOycMqZizuxA==
  • 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>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 26 Apr 2023 08:15:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.04.2023 09:36, Henry Wang wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@xxxxxxxx>
>>
>> On 26.04.2023 08:29, Henry Wang wrote:
>>>> -----Original Message-----
>>>> From: Jan Beulich <jbeulich@xxxxxxxx>
>>>>
>>>>> +        distance = dt_next_cell(1, &matrix);
>>>>
>>>> Upon second thought I checked what dt_next_cell() returns: You're silently
>>>> truncating here and then ...
>>>>
>>>>> +            /* Bi-directions are not set, set both */
>>>>> +            numa_set_distance(from, to, distance);
>>>>> +            numa_set_distance(to, from, distance);
>>>>
>>>> ... here again. Is that really the intention?
>>>
>>> By hunting down the historical discussions I found that using dt_next_cell()
>> is
>>> what Julien suggested 2 years ago in the RFC series [1]. Given the 
>>> truncation
>>> here is for node id (from/to) and distance which I am pretty sure will not
>>> exceed 32-bit range, I think the silent truncation is safe.
>>
>> That discussion is orthogonal; the previously used dt_read_number() is no
>> different in the regard I'm referring to.
>>
>>> However I understand your point here, the silent truncation is not ideal, so
>>> I wonder if you have any suggestions to improve, do you think I should
>> change
>>> these variables to u64 or maybe I need to do the explicit type cast or any
>>> better suggestions from you? Thanks!
>>
>> So one thing I overlooked is that by passing 1 as the first argument, you
>> only request a 32-bit value. Hence there's no (silent) truncation then on
>> the dt_next_cell() uses. But the numa_set_distance() calls still truncate
>> to 8 bits. Adding explicit type casts won't help at all - truncation will
>> remain as silent as it was before. However, numa_set_distance()'s first
>> two arguments could easily become "unsigned int", resulting in its node
>> related bounds checking to take care of all truncation issues. The
>> "distance" parameter already is unsigned int, and is already being bounds
>> checked against NUMA_NO_DISTANCE.
> 
> Great points! Thanks for pointing the 8-bit truncation out. You are correct.
> Somehow my impression of numa_set_distance()'s first two arguments are
> already "unsigned int" so I missed this part...Sorry.
> 
> In that case, I think I will add a check between "from, to" and MAX_NUMNODES
> as soon as the values of "from" and "to" are populated by dt_next_cell().
> Hopefully this will address your concern.

While this would address by concern, I don't see why you want to repeat
the checking that numa_set_distance() already does.

Jan



 


Rackspace

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