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

[PATCH v2 05/10] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid


  • To: <--to=xen-devel@xxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Mon, 18 Apr 2022 17:07:30 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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=29LYeiieE23CD0WLwJtnSYLtGaVHDf97F/bctCj7n5U=; b=S4h+BmdlbhNyndFyKuzmOqXQy0lpZfIeg32RbMPgmEw0tFi2SUtPoXZPYGVTN3Epdo8bPmPivcnCqOt+bQ8Hlislto3Gv8bcLfwZkXDqf1uNzgf4/b40Z7UxwnMq+qxRYBa6Z5HvAYPe1Hcqg+dzyD9u/k6/7PA56QheQKktQ3Zgu2qCkA+tjzrAHj76KQIkxg19pxym4K+hVOEfoQi+u4vIu4QW17eVZzI7UQ+mj+fi+A2k5AfEJTEzGBlXcnfXwLRjVwa68WQCMzD5aoNjCYs0d6UzglBd7IyxzPqbX2sXt34jPtZefsdBPBIXqhk6P9iAyySppwIm/i5UIIoaMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TnUbvlFfTLseXlX229YjrFVy49gUlyHRQ1XUjIDI9eRkFv+e+zXzij53P2QPvak147CUgrm9WsNr+WXuiQ0WPEBhTlwens/olTlZK5PO9VEybSeB/3c/CbyOZPFAXP4sMXRZnfctfkzT9tiEcDaQGtJa2S9LXAQuP9MaEsFjuol5faaqfXyNP74L24ImUs6nQUuVEglPvajP02cj1NpRf4LkCmA01dTiQl5Am0QDcs3aeuyq8CgO+1b6NiyacD2mLx1Sg9Fk1UmStsiK3stvgl2FzDqSCwM49pKlXJOrlytx/zX+hXvmCtXCr38szNcBY51miXEJyQ1t2N+pk4ujvw==
  • Cc: <nd@xxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, 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>
  • Delivery-date: Mon, 18 Apr 2022 09:11:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

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.
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?".

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v1 -> v2:
1. Use ASSERT to replace VIRTUAL_BUG_ON in phys_to_nid.
2. Adjust the conditional express for ASSERT.
3. Move MAX_NUMNODES from xen/numa.h to asm/numa.h for x86.
4. Use conditional macro to gate MAX_NUMNODES for other architectures.
---
 xen/arch/x86/include/asm/numa.h | 6 +++---
 xen/include/xen/numa.h          | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/numa.h
index bada2c0bb9..1f268ce77d 100644
--- a/xen/arch/x86/include/asm/numa.h
+++ b/xen/arch/x86/include/asm/numa.h
@@ -4,6 +4,7 @@
 #include <xen/cpumask.h>
 
 #define NODES_SHIFT 6
+#define MAX_NUMNODES    (1 << NODES_SHIFT)
 
 typedef u8 nodeid_t;
 
@@ -26,7 +27,6 @@ extern int compute_hash_shift(struct node *nodes, int 
numnodes,
 extern nodeid_t pxm_to_node(unsigned int pxm);
 
 #define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
-#define VIRTUAL_BUG_ON(x) 
 
 extern void numa_add_cpu(int cpu);
 extern void numa_init_array(void);
@@ -62,9 +62,9 @@ extern struct node_data node_data[];
 static inline __attribute__((pure)) nodeid_t 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);
        return nid; 
 } 
 
diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index 7aef1a88dc..91b25c5617 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -10,7 +10,9 @@
 #define NUMA_NO_NODE     0xFF
 #define NUMA_NO_DISTANCE 0xFF
 
+#ifndef MAX_NUMNODES
 #define MAX_NUMNODES    (1 << NODES_SHIFT)
+#endif
 
 #define vcpu_to_node(v) (cpu_to_node((v)->processor))
 
-- 
2.25.1




 


Rackspace

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