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

[PATCH v2 4/9] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Fri, 8 Jul 2022 22:54:19 +0800
  • 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] dmarc=[1,1,header.from=arm.com])
  • 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=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=6hrldKnD93EUpTTS3t0Fp32LcqOWPG36yIxeFRBs9ew=; b=U1D0CzkuG/bS9NDAKPHyY3uDiuz20Eavvyfo8M0Ld/kL7u7MUffbRK8hcSFXUuo0WbEOo2dXfFm/EFEmvmzaBiUAbDrAEiPRzs4XNeU6plEDi+X8CErEZhJ8qZM1Uk0fzqfm/MIgzf8F2AvvrUbNPx4IKi1mH3DM+qbGoqI3CylWi3zKgEG+fbsnr2s/cPEvXNZIxs2+Uy7Tg5OKRNgSQh6OTQCj65Ol9iWW47/PJ5ROu72qxHqnxvlcUkxuoZry63dzcIzclpmpUOFA6q8JXxiUmXdILcEwTSYzfcw+e70juzaLOHKUSWY18c4DNXx2f82eNAaWe7416LrslsJ7Ng==
  • 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=6hrldKnD93EUpTTS3t0Fp32LcqOWPG36yIxeFRBs9ew=; b=Ij8niYl0dRhV3OChGMOKPu08IIiWnM66A9e7957ZEBaQk3RDITL87wehcfZmj/kN7X5Xu8nTQIwD2m7wqDjTkGx4uwDXw9ifacl8rC4tO+Vrp3sXpK8Bo4AUneYGix4Q88TLb/M1Pk6MrgrZIP8f5gKWjhuvpcmhu1us6rwtAD/OgfdeG+Z85tnIzkrnb+x6S+frN5FeocAc5kZg5InTK9enykOekU0msmh08G1MvOc5wAvQYeYib1u3asu4UuV8MdkgAXNSrzB5gTj8Vg07WMkKG/quuc3/HK5J/7x3YHOBERoT3Q6uiZyNafa0gRgUS/xcMX5C5Cvf5PtzdwoIKg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Wmw9uhcQvlqoQfsqQKnCb6GYRbv0nfzcevcMi9oDjhtet8V49Jka6Cn7iN71MV7YJs4OmYjZcTRvKhk6AvO6do8jtTUHb2XG2009Ml0rwsDSXVpEkE7qEzB60+tb4cGmEtKKoG3n41GRLMJiaME6pIwFtbvkplNSaTU2lcMopYt7yJEqRBK5hD+LOtBUB3OltG85t2pwWQ5HH4ZOrHv0It7yhM2ozas+/IJBNjlNNRrqTwvKHr8YLatgFN1BRgEQPSg2OmP9zO0AlYoIbAmdgODvYkXO3vEKo/LUIsjoNMuJ685k89nBUYPf5vCWgYkMa3HIKuoOAMxCETG7J7BROA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIHrdJvFu0vMjmIyUBGHBwFFYq4cd+uNR0WGKg+FeGnM3E1Ro3ofkprkX0OGeJCnj11SucXA2RXUGHbQS7Xvk06DCyrWY22zLbeHKarJbcs8SRmNNz1XoiU6r7Nt1b7cACMAL0tspsqeIoH6A8t3bJFHoe9VX/kLnZirAv58TnLudgcm67+qVNNW4q/yqytHesY7vFBjUuYeqrZE8cLqhGIlojz2/QN3JBKvlwnRkxkOV+FVtgZim491wgG+N0AYI1lMi+qOkhfBOL6nX5WqYRmlz4LixSfFitigKpLaRYJ2SExb15uwJcaldq8Fc/2j2J4VrKvv5jLjfA180po3Sw==
  • Cc: <nd@xxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jiamei Xie <jiamei.xie@xxxxxxx>
  • Delivery-date: Fri, 08 Jul 2022 14:55:28 +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 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>
---
v1 -> v2:
1. Move from part#1 to part#2. (Comment from NUMA part1 series)
2. Refine the justification of using
   !node_data[nid].node_spanned_pages. (From NUMA part1 series)
3. Use ASSERT to replace VIRTUAL_BUG_ON in phys_to_nid.
4. Adjust the conditional express for ASSERT.
5. Move MAX_NUMNODES from xen/numa.h to asm/numa.h for x86.
6. Use conditional macro to gate MAX_NUMNODES for other architectures.
---
 xen/include/xen/numa.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index db0e524a0e..695ad51df0 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -36,8 +36,6 @@ struct node {
 extern int compute_hash_shift(struct node *nodes, int numnodes,
                               nodeid_t *nodeids);
 
-#define VIRTUAL_BUG_ON(x)
-
 /* Enumerations for NUMA status. */
 enum numa_mode {
     numa_on = 0,
@@ -77,9 +75,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;
 }
 
-- 
2.25.1




 


Rackspace

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