From: vijay.kilari@gmail.com
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com,
jbeulich@suse.com, Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Subject: [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions
Date: Tue, 28 Mar 2017 21:23:11 +0530 [thread overview]
Message-ID: <1490716413-19796-4-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1490716413-19796-1-git-send-email-vijay.kilari@gmail.com>
From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Following changes are made
- Rename compute_hash_shift to compute_memnode_shift
and return error values instead of shift.
- Changes prototypes of populate_memnodemap()
and extract_lsb_from_nodes()
Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
xen/arch/x86/numa.c | 47 +++++++++++++++++++++++-----------------------
xen/arch/x86/srat.c | 7 +++----
xen/include/asm-x86/numa.h | 4 ++--
3 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 8ed31cb..964fc5a 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -53,15 +53,15 @@ int srat_disabled(void)
/*
* Given a shift value, try to populate memnodemap[]
* Returns :
- * 1 if OK
- * 0 if memnodmap[] too small (of shift too small)
- * -1 if node overlap or lost ram (shift too big)
+ * 0 if OK
+ * -EINVAL if memnodmap[] too small (of shift too small)
+ * OR if node overlap or lost ram (shift too big)
*/
-static int __init populate_memnodemap(const struct node *nodes,
- int numnodes, int shift, nodeid_t *nodeids)
+static int __init populate_memnodemap(const struct node *nodes, int numnodes,
+ unsigned int shift, nodeid_t *nodeids)
{
unsigned long spdx, epdx;
- int i, res = -1;
+ int i, res = -EINVAL;
memset(memnodemap, NUMA_NO_NODE, memnodemapsize * sizeof(*memnodemap));
for ( i = 0; i < numnodes; i++ )
@@ -74,7 +74,7 @@ static int __init populate_memnodemap(const struct node *nodes,
return 0;
do {
if ( memnodemap[spdx >> shift] != NUMA_NO_NODE )
- return -1;
+ return -EINVAL;
if ( !nodeids )
memnodemap[spdx >> shift] = i;
@@ -83,7 +83,7 @@ static int __init populate_memnodemap(const struct node *nodes,
spdx += (1UL << shift);
} while ( spdx < epdx );
- res = 1;
+ res = 0;
}
return res;
@@ -99,7 +99,7 @@ static int __init allocate_cachealigned_memnodemap(void)
printk(KERN_ERR
"NUMA: Unable to allocate Memory to Node hash map\n");
memnodemapsize = 0;
- return -1;
+ return -ENOMEM;
}
memnodemap = mfn_to_virt(mfn);
@@ -116,10 +116,10 @@ static int __init allocate_cachealigned_memnodemap(void)
* The LSB of all start and end addresses in the node map is the value of the
* maximum possible shift.
*/
-static int __init extract_lsb_from_nodes(const struct node *nodes,
- int numnodes)
+static unsigned int __init extract_lsb_from_nodes(const struct node *nodes,
+ int numnodes)
{
- int i, nodes_used = 0;
+ unsigned int i, nodes_used = 0;
unsigned long spdx, epdx;
unsigned long bitfield = 0, memtop = 0;
@@ -143,27 +143,27 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,
return i;
}
-int __init compute_hash_shift(struct node *nodes, int numnodes,
- nodeid_t *nodeids)
+int __init compute_memnode_shift(struct node *nodes, int numnodes,
+ nodeid_t *nodeids, unsigned int *shift)
{
- int shift;
+ *shift = extract_lsb_from_nodes(nodes, numnodes);
- shift = extract_lsb_from_nodes(nodes, numnodes);
if ( memnodemapsize <= ARRAY_SIZE(_memnodemap) )
memnodemap = _memnodemap;
else if ( allocate_cachealigned_memnodemap() )
- return -1;
- printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n", shift);
+ return -ENOMEM;
+
+ printk(KERN_DEBUG "NUMA: Using %u for the hash shift.\n", *shift);
- if ( populate_memnodemap(nodes, numnodes, shift, nodeids) != 1 )
+ if ( populate_memnodemap(nodes, numnodes, *shift, nodeids) )
{
printk(KERN_INFO "Your memory is not aligned you need to "
"rebuild your hypervisor with a bigger NODEMAPSIZE "
- "shift=%d\n", shift);
- return -1;
+ "shift=%u\n", *shift);
+ return -EINVAL;
}
- return shift;
+ return 0;
}
/* initialize NODE_DATA given nodeid and start/end */
void __init setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end)
@@ -235,8 +235,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn)
(nodes[i].end - nodes[i].start) >> 20);
node_set_online(i);
}
- memnode_shift = compute_hash_shift(nodes, numa_fake, NULL);
- if ( memnode_shift < 0 )
+ if ( compute_memnode_shift(nodes, numa_fake, NULL, &memnode_shift) )
{
memnode_shift = 0;
printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\n");
diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 800a7c3..2d0c047 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -470,10 +470,9 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)
return -1;
}
- memnode_shift = compute_hash_shift(node_memblk_range, num_node_memblks,
- memblk_nodeid);
-
- if (memnode_shift < 0) {
+ if (compute_memnode_shift(node_memblk_range, num_node_memblks,
+ memblk_nodeid, &memnode_shift)) {
+ memnode_shift = 0;
printk(KERN_ERR
"SRAT: No NUMA node hash function found. Contact maintainer\n");
bad_srat();
diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h
index 748cdfd..bb22bff 100644
--- a/xen/include/asm-x86/numa.h
+++ b/xen/include/asm-x86/numa.h
@@ -22,8 +22,8 @@ struct node {
paddr_t end;
};
-extern int compute_hash_shift(struct node *nodes, int numnodes,
- nodeid_t *nodeids);
+extern int compute_memnode_shift(struct node *nodes, int numnodes,
+ nodeid_t *nodeids, unsigned int *shift);
extern nodeid_t pxm_to_node(unsigned int pxm);
#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-28 15:53 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 15:53 [RFC PATCH v2 00/25] ARM: Add Xen NUMA support vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 01/25] x86: NUMA: Clean up: Drop trailing spaces vijay.kilari
2017-03-28 16:44 ` Wei Liu
2017-05-31 10:20 ` Jan Beulich
2017-05-31 10:21 ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 02/25] x86: NUMA: Fix datatypes and attributes vijay.kilari
2017-03-28 16:44 ` Wei Liu
2017-05-31 10:35 ` Jan Beulich
2017-03-28 15:53 ` vijay.kilari [this message]
2017-06-30 14:05 ` [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions Jan Beulich
2017-07-11 10:16 ` Vijay Kilari
2017-03-28 15:53 ` [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables vijay.kilari
2017-04-20 15:59 ` Julien Grall
2017-04-25 6:54 ` Vijay Kilari
2017-04-25 12:04 ` Julien Grall
2017-04-25 12:20 ` Vijay Kilari
2017-04-25 12:28 ` Julien Grall
2017-04-25 14:54 ` Vijay Kilari
2017-04-25 15:14 ` Julien Grall
2017-04-25 15:43 ` Jan Beulich
2017-05-02 9:47 ` Vijay Kilari
2017-05-02 9:54 ` Jan Beulich
2017-05-08 17:38 ` Julien Grall
2017-06-30 14:07 ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 05/25] x86: NUMA: Move generic dummy_numa_init to separate function vijay.kilari
2017-04-20 16:12 ` Julien Grall
2017-04-25 6:59 ` Vijay Kilari
2017-06-30 14:08 ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 06/25] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs vijay.kilari
2017-05-08 14:39 ` Julien Grall
2017-05-09 7:02 ` Vijay Kilari
2017-05-09 8:13 ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 07/25] x86: NUMA: Rename some generic functions vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 08/25] x86: NUMA: Sanitize node distance vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 09/25] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA vijay.kilari
2017-05-08 15:58 ` Julien Grall
2017-05-09 7:14 ` Vijay Kilari
2017-05-09 8:21 ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic vijay.kilari
2017-05-08 16:41 ` Julien Grall
2017-05-09 7:36 ` Vijay Kilari
2017-05-09 8:23 ` Julien Grall
2017-05-08 16:51 ` Julien Grall
2017-05-09 7:39 ` Vijay Kilari
2017-05-09 8:26 ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 11/25] x86: NUMA: Move common code from srat.c vijay.kilari
2017-05-08 17:06 ` Julien Grall
2017-05-10 9:00 ` Vijay Kilari
2017-03-28 15:53 ` [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information vijay.kilari
2017-05-08 17:31 ` Julien Grall
2017-05-10 5:24 ` Vijay Kilari
2017-05-10 8:52 ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 13/25] ARM: NUMA: Parse memory " vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 14/25] ARM: NUMA: Parse NUMA distance information vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 15/25] ARM: NUMA: Add CPU NUMA support vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 16/25] ARM: NUMA: Add memory " vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 17/25] ARM: NUMA: Add fallback on NUMA failure vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 18/25] ARM: NUMA: Do not expose numa info to DOM0 vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 19/25] ACPI: Refactor acpi SRAT and SLIT table handling code vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 20/25] ARM: NUMA: Extract MPIDR from MADT table vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 21/25] ACPI: Move arch specific SRAT parsing vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 22/25] ARM: NUMA: Extract proximity from SRAT table vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 23/25] ARM: NUMA: Initialize ACPI NUMA vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig vijay.kilari
2017-05-31 10:04 ` Jan Beulich
2017-05-31 10:18 ` Julien Grall
2017-05-31 10:37 ` Jan Beulich
2017-06-15 7:52 ` Vijay Kilari
2017-06-15 9:00 ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 25/25] NUMA: Enable ACPI_NUMA config vijay.kilari
2017-05-31 10:05 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490716413-19796-4-git-send-email-vijay.kilari@gmail.com \
--to=vijay.kilari@gmail.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Vijaya.Kumar@cavium.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).