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

RE: [PATCH v9 3/6] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Tue, 13 Dec 2022 10:40:18 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=H05V9UWEn9+HrRt78Sv1zi2jvkV/Z6lHfEjfWmvr8TU=; b=E42LlLAu6UK/71Xv2MdcMpkk462a1/jtJ8jIPMJgSRTzxS9n92YZ9vlqSi1Lj+kbOkqvYDmB8aZm4PY56Z8JGqOXchiBH2Tcg86wUDphO3Yd6hcrfanpKdbR32iNiBQigcy6oc5ofnf54cvuA9M8Sz1INdTXoSjObnUHQnEy/AhINBOWa3xsJnfQzOBd3DFaN2FJj4S7+bGSq8C1PKti5qmY+el1Zz2ByuEkPWsTvyeYsJ/+jowHa5MOKi42e1VY78jQW8qWSVtG2ROTE1K44+W364qrhLahds7+dG4chE9UDPAxG99E+Pcu6ay3zbK0u386haF1JvmrTOZ+1hbjEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UBIeVMlSw0+fRW1Hv/tkAlkquDpn9OfPhuApQde2j22txRhAovKpABd0ynADB+1F+wYevn8DSRcf1hCP5XTk3VjMH38nBmVuFXCAFB4NCJ2nFctMqLPTqt2OxolP6XBQhrHHDkX3x82V8TxFroI7B8CjMECBr5OP4A13plJElEkgyke8PjuzfU/Ty7IIbbnIhfmlscCjTXecvuzE/W0+fr8N6GiLN2yWC8SZzusc4SOSLpNyMqwg30noSYn9ZRmCaKMDFYFbk5K5ksnHS2ef3m+5nbAizRTxWwSQuTmpuML35yHLoFmdXAnOus/6fgiXOZzr4CkmFzxbEyTFh3A87A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: nd <nd@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jiamei Xie <Jiamei.Xie@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 13 Dec 2022 10:40:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY+zrluQ6bhO04RE6Xg9on5yXu8a5ruT0AgAALEbA=
  • Thread-topic: [PATCH v9 3/6] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2022年12月13日 17:47
> To: Wei Chen <Wei.Chen@xxxxxxx>
> Cc: nd <nd@xxxxxxx>; Andrew Cooper <andrew.cooper3@xxxxxxxxxx>; George
> Dunlap <george.dunlap@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Stefano
> Stabellini <sstabellini@xxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; Jiamei Xie
> <Jiamei.Xie@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx; Roger Pau Monné
> <roger.pau@xxxxxxxxxx>
> Subject: Re: [PATCH v9 3/6] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON
> for phys_to_nid
> 
> On 18.11.2022 11:45, Wei Chen wrote:
> > VIRTUAL_BUG_ON is an empty macro used in phys_to_nid. This
> > results in two lines of error-checking code in phys_to_nid
> > that is not actually working and causing two compilation
> > errors:
> > 1. error: "MAX_NUMNODES" undeclared (first use in this function).
> >    This is because in the common header file, "MAX_NUMNODES" is
> >    defined after the common header file includes the ARCH header
> >    file, where phys_to_nid has attempted to use "MAX_NUMNODES".
> >    This error was resolved after we moved the phys_to_nid from
> >    x86 ARCH header file to common header file.
> > 2. error: wrong type argument to unary exclamation mark.
> >    This is because, the error-checking code contains !node_data[nid].
> >    But node_data is a data structure variable, it's not a pointer.
> >
> > So, in this patch, we use ASSERT instead of VIRTUAL_BUG_ON to
> > enable the two lines of error-checking code. And fix the left
> > compilation errors by replacing !node_data[nid] to
> > !node_data[nid].node_spanned_pages. Although NUMA allows one node
> > can only have CPUs but without any memory. And node with 0 bytes
> > of memory might have an entry in memnodemap[] theoretically. But
> > that doesn't mean phys_to_nid can find any valid address from a
> > node with 0 bytes memory.
> >
> > Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> > Tested-by: Jiamei Xie <jiamei.xie@xxxxxxx>
> > Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> This patch is what is causing the regression found by osstest. The
> previously silent (dead) checks no trigger when paging_init()
> encounters a hole in SRAT-described space, as is the case e.g. on
> the himrods:
> 
> (XEN) NUMA: Node 0 PXM 0 [0000000000000000, 000000007fffffff]
> (XEN) NUMA: Node 0 PXM 0 [0000000100000000, 000000087fffffff]
> (XEN) NUMA: Node 1 PXM 1 [0000000880000000, 000000107fffffff]
> (XEN) NUMA: Using 19 for the hash shift
> 
> The node ID for 0x80000000 (slot 1 of memnodemap[]) is NUMA_NO_NODE,
> which of course fails the left side of ...
> 

I am sorry, I had not triggered this in my testing machine. I'm a bit
curious, on NUMA platforms will there be memory that doesn't belong to
any node? If not, why the space of 0x80000000 will be used in paging_init?

> > @@ -69,9 +67,9 @@ extern struct node_data node_data[];
> >  static inline nodeid_t __attribute_pure__ phys_to_nid(paddr_t addr)
> >  {
> >      nodeid_t nid;
> > -    VIRTUAL_BUG_ON((paddr_to_pdx(addr) >> memnode_shift) >=
> memnodemapsize);
> > +    ASSERT((paddr_to_pdx(addr) >> memnode_shift) < memnodemapsize);
> >      nid = memnodemap[paddr_to_pdx(addr) >> memnode_shift];
> > -    VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
> > +    ASSERT(nid < MAX_NUMNODES && node_data[nid].node_spanned_pages);
> 
> ... the && here. As I don't think the use of phys_to_nid() by
> paging_init() is outright invalid, I would conclude that the
> condition needs to be relaxed to permit for NUMA_NO_NODE. Otoh it's
> possible that the function was really intended to never return
> NUMA_NO_NODE (and only ever be used on valid memory ranges), in
> which case paging_init() would need to use something else (or
> make the call conditional): According to my audit all uses except
> the two in paging_init() are on (supposedly) valid addresses only
> (commonly when already holding in hands a valid struct page_info).
> 
> Then again us having phys_to_nid() in the first place is somewhat
> bogus: No caller really starts from a physical address. It would
> be quite a bit more sensible to have page_to_nid() and mfn_to_nid(),
> the more that what phys_to_nid() does is pass the address to
> paddr_to_pdx() (undoing every caller's to-addr conversion). At which
> point the former could do strict checking (disallowing NUMA_NO_NODE
> output) while the latter could be more relaxed. I guess I'll make a
> patch along these lines.
> 

Thanks, I will review it after you sent that patch.

Cheers,
Wei Chen

> Jan

 


Rackspace

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