[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 3/6] 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, 2 Sep 2022 11:31:18 +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=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=Nm8RkcidI6bOg5wy+UIdGvM5kyKStFNXPFVZBjYb4NJlmyVvEmN00YOIiKmxTmEwvPquJDsF8nIv+4iCqUbDFNuESNQivCQHt4H+oiOAsPBG1RJQe4QASIJ7Xviaew1LSXb2U5gsdk0oPa1jmMKmQzFyPFSXw2YfcPk5x4qBZSgdVXPMalkEz9DrhAsWCK/JIS0rbYwSE4mn9hrIq0jVph5+nr+0YaCvwqGgrSHi3hHzChNqqrHEYsiWoffqUwiee5Q3XN+3jRRQwj92wcQgblb1z3pk5hXvbj4vVUvEM0bUmYxXwXVsBm3SYvU/jHYBeELVYZwfOMA1oI1nTF2kVw==
- 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=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=J86Tu2GnjgXH2HWIQj5B6Bq4D8n5hwFxYayq6DdqxeyHAyYijn3o4BqSkNEOriaPmiUu6+0G1HlcGRNR4cGvm0/+Y/8VQ5x/FHdsBa041vXaNju86DmzbmDU/oDRZKQNReQ092JLZYJJ+S6iZnzTfMPk01Bf6ak7evfezpJ3VWeggo6rmInNmVxu2470SDE+oZqNVgCgl2y7WZ6sqLODavC6guUxrosWXLn8QM9BNbXc+8n7+a8Rz9AXPWHomExEajq/W/zzWLGlJc+/olrh24sn2zJeV6V5b6Zj/RPtkJtYWwSPhwF0Jhw+3QlhvICdtdJhXj6HdlUv5G/U/ZpS2A==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ShlnwG+b8zbpZNncZipqcLCfRgqI5XneJ5iEtA5TLwtZhXMMyJipbAPaMZy10JG+JKyFywBqq66cx1/rrHw0GhP5MJQ+1Q3R6AF0Fl3Yto/GtCMeiNrhT4mtCz/+z3r2Y9UR2N4JUsOzYLIjtUh3fgtNMxKTIAG0bL06bu+RX0RD0oMDiIHuuUU7q339YJ4g9aFfDEGGdJ79TLWYa1CK2ryIRzsmYC8vU4peq337XGBAKovOXIT64ErR4qRQRaVRuz5JrLgZWAoByxueOHhArL74Y1DbTAnf4qyzg8EYpKSkthvz6e/UVOvtJxMhNUPqOQgWevU4VgcVKwm7jcl3Tw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJEylBXXaGPmRlgU+fDnPbI5sGLGlqiY66gCfMAbxQxtZa/E/0pgpqm0vnOuT5G+JYnZeYDcREvrYB2wvIdEftbaUuZMbv3DcCilVqPQEqALS1bQXxHGqjnPj/XdWtEgLc9FamDEzj4bjdDuPyDQRv9AJ1Mpqvsh/uxEejkPqCp441I3Q0+9+PIAbpSwf/YGV7lkSnwlQRNYaIrnvXJMVsVC/cGJRBh8THeghEUcQqBNFYB0TCozlnK121XlXXisJiNkQb5MQcnAYxHDyOSXjW9uzXMzIyIeKodCfOD0tJK/VCsWLJdo7rAtMI3n7Of4aAqzzzgp7pOdfaZjW77+xg==
- 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, 02 Sep 2022 03:32:05 +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>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3 -> v4:
no change.
v2 -> v3:
1. Remove unnecessary change items in history.
2. Add Acked-by.
v1 -> v2:
1. Use ASSERT to replace VIRTUAL_BUG_ON in phys_to_nid.
2. Adjust the conditional express for ASSERT.
3. Refine the justification of using !node_data[nid].node_spanned_pages.
---
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 baef4cd553..af0abfc8cf 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -36,8 +36,6 @@ struct node {
extern int compute_hash_shift(const struct node *nodes,
nodeid_t numnodes, nodeid_t *nodeids);
-#define VIRTUAL_BUG_ON(x)
-
extern bool numa_off;
extern void numa_add_cpu(unsigned int cpu);
@@ -70,9 +68,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);
return nid;
}
--
2.25.1
|