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

RE: [PATCH v2 05/10] 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: Wed, 27 Apr 2022 03:52:28 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • 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=2; 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=pceHUH/SelruKIeUg8IoL4G9TiVeeobEpOyMvTiaeKI=; b=D+l26pi0o8P6EjJ0FzSCuIxXUHkoAqSV4H7VwKlIEpshfZRYoRoUxHfK0nX/pxwLc9ryNSJgx66XKTCqRct2NktIq7eAA32Ps948rXRaaBk7jh1b+m9bwsVE7ocE/b+89QZY/ApOjULXUfA7rjft+22EKyri9pVeV4/pFgC4lZpWw4A4Z8wURzSL9/OLeEe/Riyy7HDwq5unTcMaC8GGw2FjppnX906DAGS66Oh8p7vZdOOys4k/5AwtbdrAfz6G4S9ClF7Mu27aoAK6gnddh1EeXYAIbDe6JhqFxPTb2O4fcHRT9twAZw/zSMwPnWSFzb35Ov5eFF3UMNDxasXH/A==
  • 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=pceHUH/SelruKIeUg8IoL4G9TiVeeobEpOyMvTiaeKI=; b=LdlFuJTC0NgrkCO30UJG3okc/OtU8jb59tlkaAeIIROI0EAJtmjc7lwuMaRZHFn4TK4NmNIIn5aBIK7iwzJ5QCkLeHj6GYvwTukNIz1Dn9l2YbJLRpq7Xy4eg0CKWiGKFbaVPQ8Pq9DM4S9Zre7xsmE4v85iLOyNDEzZchWOYGIDT1yEXyUxTq+2L+X1m5s/TH3hA95vZzB6imse3lKQU2pEaxacohU/VKC41+i1geseO07H9QicNIAkyuXSZTthwfxmLJMePsk63WDkP+fbBe77lzpzRdmvgY60wrRaEi1lCPiNTnaGmQZ52Mp0NWyqvEAic5xJWXegjmgepdMmsw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=l3+dSZTCEJMFXhRnWKoWaU5jqCF7ovPFpWfhQB5ByorNTVUVSUl9XWhaJct48mOQpLfidI+rdfRzFDf8ZEwCQ55F0XQq8frgnwnwrz4Y8hVcfJSYmHpioPukiZkUU/qIO54OQeFruvZicQIhJye1XzAi7lR+RMNfmzDWd5vAxjHEdkOGb02keELB6D7uu/r3XJxo/vbQ78TNpglVxURyRs1sGb3zsmVPIwPA4I5WMBswsuLXnDCoiCvVcv39fCXiYi++f9JhYenp20kRnh+oV57eKxNB1D1IVPoZ/hSVr38lxQb61JUT7sTL3vGe3irnP5eZ9ajq1gwyUD9pOdSglA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C9G2ozMMY/qOJN4nR/0x5iqUx5SZCLbRgXHJdyC9S+alojjw29XaSjyIlmi5pufKxTaRImVuH9MF6j2eFOZxwFscdO20cXSB22+Kq9TlzRxcXmTvciSerdXcNVBNL3p4CpFsmF8b2Gp/XJBGcmrGb7Q8AskZnI0UrlOUcQWXvIZDB1g3UDg31/ssL1seG0luuIG1drfKTZ00uQij5NGGt1g/e2KMFL+NKFAM2FvWNfms5o84vP0XiB13IQO3fPN9l8m9Gzbb/rydbZ4mDkfyN9KIXpXaw69PrhXqadXGO/HT9jfKjvsJ7INNa/BDptTfmjjny0ytrgrrzRjYdfBD/w==
  • 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>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 27 Apr 2022 03:53:01 +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: AQHYUwP8rcNxDcW2QEyqIlyEGMAP4q0B8r0AgAAgsICAAD42gIAAz9Gg
  • Thread-topic: [PATCH v2 05/10] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2022年4月26日 22:42
> To: Wei Chen <Wei.Chen@xxxxxxx>
> Cc: nd <nd@xxxxxxx>; Andrew Cooper <andrew.cooper3@xxxxxxxxxx>; Roger Pau
> Monné <roger.pau@xxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; George Dunlap
> <george.dunlap@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Stefano
> Stabellini <sstabellini@xxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 05/10] xen/x86: Use ASSERT instead of
> VIRTUAL_BUG_ON for phys_to_nid
> 
> On 26.04.2022 12:59, Wei Chen wrote:
> > On 2022/4/26 17:02, Jan Beulich wrote:
> >> On 18.04.2022 11:07, 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 when we moved the definition of
> >>>     "MAX_NUMNODES" to x86 ARCH header file. And we reserve the
> >>>     "MAX_NUMNODES" definition in common header file through a
> >>>     conditional compilation for some architectures that don't
> >>>     need to define "MAX_NUMNODES" in their ARCH header files.
> >>
> >> No, that's setting up a trap for someone else to fall into, especially
> >> with the #ifdef around the original definition. Afaict all you need to
> >> do is to move that #define ahead of the #include in xen/numa.h. Unlike
> >> functions, #define-s can reference not-yet-defined identifiers.
> >>
> >
> > I had tried it before. MAX_NUMNODES depends on NODE_SHIFT. But
> > NODE_SHIFT depends on the definition status in asm/numa.h. If I move
> > MAX_NUMNODES to before asm/numa.h, then I have to move NODES_SHIFT as
> > well. But this will break the original design. NODES_SHIFT in xen/numa.h
> > will always be defined before asm/numa.h. This will be a duplicated
> > definition error.
> 
> I'm afraid I don't follow. MAX_NUMNODES depends on NODES_SHIFT only as
> soon as some code actually uses MAX_NUMNODES. It does not require
> NODES_SHIFT to be defined up front. Of course with the current layout
> (phys_to_nid() living in an inline function in asm/numa.h) things won't
> build. But wasn't the plan to move phys_to_nid() to xen/numa.h as well?
>

Yes, I will drop this patch from part#1, and move it to part#2. This
patch will follow when we move phys_to_nid() to xen/numa.h.

Thanks,
Wei Chen

> Otherwise I'd recommend to introduce a new header, say numa-defs.h,
> holding (for now) just NODES_SHIFT. Then you'd include asm/numa-defs.h
> first and asm/numa.h only after having defined MAX_NUMNODES. But
> splitting the header should only be a last resort if things can't be
> made work another way.
> 
> > How about I move MAX_NUMNODES to arm and x86 asm/numa.h in this patch
> > at the same time? Because in one of following patches, MAX_NUMNODES and
> > phys_to_nid will be moved to xen/numa.h at the same time?
> >
> >>> 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.
> >>>
> >>> Because when node_spanned_pages is 0, this node has no memory,
> >>> numa_scan_node will print warning message for such kind of nodes:
> >>> "Firmware Bug or mis-configured hardware?".
> >>
> >> This warning is bogus - nodes can have only processors. Therefore I'd
> >> like to ask that you don't use it for justification. And indeed you
> >
> > Yes, you're right, node can only has CPUs! I will remove it.
> >
> >> don't need to: phys_to_nid() is about translating an address. The
> >> input address can't be valid if it maps to a node with no memory.
> >>
> >
> > Can I understand your comment:
> > Any input address is invalid, when node_spanned_pages is zero, because
> > this node has no memory?
> 
> It's getting close, but it's not exactly equivalent I think. A node
> with 0 bytes of memory might (at least in theory) have an entry in
> memnodemap[]. But finding a node ID for that address would still

I have done a quick check in populate_memnodemap:
74          spdx = paddr_to_pdx(nodes[i].start);
75          epdx = paddr_to_pdx(nodes[i].end - 1) + 1;
76          if ( spdx >= epdx )
77              continue;

It seems that if node has no memory, start == end, then this function
will not populate memnodemap entry for this node.

> not mean that at least one byte of memory at that address is present
> on the given node, because the node covers 0 bytes.
> 

And back to this patch, can I just drop the unnecessary justification
from the commit message?

And for the bogus warning message, can I update it to an INFO level
message in part#2 series, and just keep:
printk(KERN_INFO "SRAT: Node %u has no memory!\n", i);
but remove "BIOS Bug or mis-configured hardware?\n", i); ?

Thanks,
Wei Chen

> Jan


 


Rackspace

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