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

Re: [PATCH 2/2] NUMA: replace phys_to_nid()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Fri, 16 Dec 2022 14:27:39 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=VoQyCTuolKRfIzY1yBnNYiLiFuXiSaC81CbBoa+3PzU=; b=iuvRizHXx93y9+IXV3kfgbukydQHZWV9oLZkP8NkhQnlKYSyoXjYoeed2DVABOTFzHVbDSfEmbFtMuit7eT3GkcxjA1Pkoz4OOjCc2iohMZu8brkyzbKFQF9+F5yu/QDNm2SNaoB0DWblH/cEJhoOU3URkxM5IpILNc1DwagaidxN67CiNiHYmfLQZE0zfkPyYEoB5TSjpgbiuMTwewagoXOcdsK1eqchAm4C8G8SQg3yjxDN60kBvyF/g8Iy4j0PrfmgTyjyUPEweav7V0CceHh7yRaFhzP1WjIx881MhK/D1jPSpNYhGAEi3G+qgHMwYJy8lkKHohfmYfkuKmlIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TrwF2LvjSxce7PqdWFSwlAaF98xVLBaKG4FCCFNBuSzBYU+52fj8kFcaQOCuQ6aWCsPR+dXWmy1z4rvHX1/oCajFoxhH8JQ4ezOj+g3gLOV0yPJN5WCn505qLbvLpZixCuneYqT6Rz085m49uwWmX/+xZDfBBhGRemKXpdKZ3lKAqDob6iqexqWCqw9IS/DJ5Oc4qCCqZxOMagyDfS0CSaCnw+GAZIsotZ4PKGN6hWesGvMuaYXSc04ll0WUAhPuiYppg3nntUzaiiyT7wbByIJclQnioHtaN+V7p0JmLiTcxcLnHf5KTVMtZUTJsLmm4b1wtJFvj9P4aFwComRZOA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 16 Dec 2022 14:28:00 +0000
  • Ironport-data: A9a23:Cz7WnaL5p+uijqxRFE+RUZQlxSXFcZb7ZxGr2PjKsXjdYENShmRSm DNODTjUOa6CMzP1ct1/Oo/g8EIH68LcmoBnSlZlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5AVgPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5bGDgJ3 N07FwsBf0uAicXmyri1RO1V05FLwMnDZOvzu1lG5BSAVLMMZ8CGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dnpTGNnWSd05C0WDbRUvWMSd9YgQCzo WXe8n6iKhobKMae2XyO9XfEaurnzXykAt9JRezQGvhCmEy/+GBJCzYqWwWn/sO3qXCuBvsHN BlBksYphe1onKCxdfH/VRClpH+PvjYHRsFdVeY97WmlyLfQ4gufLngJSHhGctNOnNQtWTUg2 1uNntXoLT9iqruYTTSa7Lj8hSy2ETgYKykFfyBsZQEI+cX5qYc/yBfGVM9+EbWdh8fwXzr3x liisi86gLkCiN8R4K+y91vHnjGEq4DAS0g+4QC/dnKo6EZ1aZCoY6Ss6EPH9rBQIYCBVF6Ds XMY3c+E44gz4YqlkSWMRKAHGuGv7vPcaTnE2wcxTt8m6iin/GOlccZI+jZiKUx1M8ECPzj0f EvUvgAX75hWVJe3UZJKj0uKI5xC5cDd+R7ND5g4svImjkBNSTK6
  • Ironport-hdrordr: A9a23:52vZNKDNuPZ0CjzlHelW55DYdb4zR+YMi2TDt3oddfWaSKylfq GV7ZAmPHrP4gr5N0tOpTntAse9qBDnhPtICOsqTNSftWDd0QPFEGgL1+DfKlbbak/DH4BmtJ uJc8JFeaDN5VoRt7eH3OFveexQv+Vu88qT9JnjJ28Gd3AMV0n5hT0JcTpyFCdNNW97LKt8Lr WwzOxdqQGtfHwGB/7LfEXsD4D41qT2fIuNW29/OyIa
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZDudxkldNMZdm+EWY9M6n0vcTdK5wawGAgAAC8ACAAClZgA==
  • Thread-topic: [PATCH 2/2] NUMA: replace phys_to_nid()

On 16/12/2022 11:59 am, Jan Beulich wrote:
> On 16.12.2022 12:49, Andrew Cooper wrote:
>> On 13/12/2022 11:38 am, Jan Beulich wrote:
>>> All callers convert frame numbers (perhaps in turn derived from struct
>>> page_info pointers) to an address, just for the function to convert it
>>> back to a frame number (as the first step of paddr_to_pdx()). Replace
>>> the function by mfn_to_nid() plus a page_to_nid() wrapper macro. Replace
>>> call sites by the respectively most suitable one.
>>>
>>> While there also introduce a !NUMA stub, eliminating the need for Arm
>>> (and potentially other ports) to carry one individually.
>> Thanks.  This will help RISC-V too.
>>
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>,
> Thanks. You realize though that the patch may change depending on the
> verdict on patch 1 (and, if that one's to change, the two likely
> flipped with the actual fix moving here in the form of more relaxed
> assertions, one way or another)?

Yeah, the tweak sounded entirely reasonable.

>
>> albeit with one deletion.
>>
>>> --- a/xen/include/xen/numa.h
>>> +++ b/xen/include/xen/numa.h
>>> @@ -1,6 +1,7 @@
>>>  #ifndef _XEN_NUMA_H
>>>  #define _XEN_NUMA_H
>>>  
>>> +#include <xen/mm-frame.h>
>>>  #include <asm/numa.h>
>>>  
>>>  #define NUMA_NO_NODE     0xFF
>>> @@ -68,12 +69,15 @@ struct node_data {
>>>  
>>>  extern struct node_data node_data[];
>>>  
>>> -static inline nodeid_t __attribute_pure__ phys_to_nid(paddr_t addr)
>>> +static inline nodeid_t __attribute_pure__ mfn_to_nid(mfn_t mfn)
>>>  {
>>>      nodeid_t nid;
>>> -    ASSERT((paddr_to_pdx(addr) >> memnode_shift) < memnodemapsize);
>>> -    nid = memnodemap[paddr_to_pdx(addr) >> memnode_shift];
>>> +    unsigned long pdx = mfn_to_pdx(mfn);
>>> +
>>> +    ASSERT((pdx >> memnode_shift) < memnodemapsize);
>>> +    nid = memnodemap[pdx >> memnode_shift];
>>>      ASSERT(nid < MAX_NUMNODES && node_data[nid].node_spanned_pages);
>>> +
>>>      return nid;
>>>  }
>>>  
>>> @@ -102,6 +106,15 @@ extern bool numa_update_node_memblks(nod
>>>                                       paddr_t start, paddr_t size, bool 
>>> hotplug);
>>>  extern void numa_set_processor_nodes_parsed(nodeid_t node);
>>>  
>>> +#else
>>> +
>>> +static inline nodeid_t __attribute_pure__ mfn_to_nid(mfn_t mfn)
>>> +{
>>> +    return 0;
>>> +}
>> pure is useless on a stub like this, whereas its false on the non-stub
>> form (uses several non-const variables) in a way that the compiler can
>> prove (because it's static inline), and will discard.
>>
>> As you're modifying both lines anyway, just drop the attribute.
> Hmm, yes, I agree for the stub, so I've dropped it there. "Several non-
> const variables", however, is only partly true. These are __ro_after_init
> and not written anymore once set.

They're still read-write as far as C is concerned, and some of these
uses are before modifications finish.

>  Are you sure the compiler will ignore
> a "pure" attribute if it finds it (formally) violated?

Yes, very sure.  It got discussed at length on one of the speculation lists.

When the compiler can prove that the programmer doesn't know the rules
concerning pure/const, the attributes will be discarded.

To abuse the rules, you really do need the operation hidden in a place
that GCC can't see, so either a separate translation unit, or in inline
assembly.

~Andrew

 


Rackspace

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