[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 09:07:29 +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=u73J4pR9h6BZim13/FmvTniUy5L8IiACuXft2MAZqT8=; b=BevTrURPyQrZ895h3qGNRoedxCloGbOW227P/TAZ9meq+qi4Xd1UtbltxIAdeC+jW1nUILEE1cMGsUeQF8vpGSU8DYkISaVnbTq7HhxFwXYilD+yjs/Lg2cSc0y+4400dxYv4gjSHtVoO3G9x+Q0zKjcG+LdKj/8bR9o7m+PfPzvLfNbTyqu59GAu3T9JIi4GB4Q8t+CR+6UTVNn2id+sg3YFi4dF2+8+Bhb+GR8824zHwQq9n0GstbNa85czSKgO7DKRTsPRuOobnUMqqm1eX0O8a8i2i5SoxNbO8fvAj5FzoT7MDBj7OZD/VPYSTICSBhI1r/cahMqOp2x0jjXTA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eZVY8BTne0gQp7pLdKvsQZwtzZHoQYUn9abIXqhSHbmD02TdeJ35iMVN8hPmLfswdyN3fLPI0zjTD6NS0a90GXvsd2GZNrv4HEKNx3GUPRpxQneaR2dcdImzc+6sb/7tI0LZp50hi57NBIa2c/76HsNvjp4xrNHe5nSfodADAjAjpFc6UOk/cHf1NGeKsXEvsxK5vawq4a8b3MMpMKspthd9OKAbDhRAJO/6RiVfpMd20zUev/eiKuzz5q4MjbA8siuH/V80uZofseoUEUD7qz1deZ8T59Owl5WhM353rG4I76D1pu8LqYHhGoEd1ax7i1m7ZwI4JKTIir+P7/mKOw==
  • 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 07:08:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Jan

> [1] https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg01175.html
> 
> Kind regards,
> Henry




 


Rackspace

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