* [PATCH v3 0/3] Updates to pxm2node mapping and nodeID sizing
@ 2015-02-25 23:41 Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-02-25 23:41 UTC (permalink / raw)
To: keir, jbeulich, yang.z.zhang, kevin.tian, ian.campbell,
stefano.stabellini, tim
Cc: Andrew.Cooper3, dario.faggioli, boris.ostrovsky, xen-devel
A set of patches for better px2<->node mapping and consistent use of
nodeID datatype.
Boris Ostrovsky (3):
x86/numa: Allow arbitrary value of PXM in PXM<->node mapping
x86/numa: Adjust datatypes for node and pxm
mm: MEMF_node should handle changes in nodeid_t size
xen/arch/x86/irq.c | 4 +-
xen/arch/x86/numa.c | 15 ++--
xen/arch/x86/setup.c | 2 +-
xen/arch/x86/smpboot.c | 6 +-
xen/arch/x86/srat.c | 121 ++++++++++++++++++++++++-----------
xen/arch/x86/x86_64/mm.c | 5 +-
xen/common/page_alloc.c | 8 ++-
xen/drivers/passthrough/vtd/iommu.c | 5 +-
xen/include/asm-arm/numa.h | 4 +-
xen/include/asm-x86/irq.h | 3 +-
xen/include/asm-x86/numa.h | 24 ++++---
xen/include/xen/mm.h | 5 +-
12 files changed, 133 insertions(+), 69 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping
2015-02-25 23:41 [PATCH v3 0/3] Updates to pxm2node mapping and nodeID sizing Boris Ostrovsky
@ 2015-02-25 23:41 ` Boris Ostrovsky
2015-02-26 8:38 ` Jan Beulich
2015-02-26 9:06 ` Dario Faggioli
2015-02-25 23:41 ` [PATCH v3 2/3] x86/numa: Adjust datatypes for node and pxm Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 3/3] mm: MEMF_node should handle changes in nodeid_t size Boris Ostrovsky
2 siblings, 2 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-02-25 23:41 UTC (permalink / raw)
To: keir, jbeulich, yang.z.zhang, kevin.tian, ian.campbell,
stefano.stabellini, tim
Cc: Andrew.Cooper3, dario.faggioli, boris.ostrovsky, xen-devel
ACPI defines proximity domain identifier as a 32-bit integer. While
in most cases the values will be zero-based this is not guaranteed,
making current pxm2node[256] mapping structure not appropriate.
We will instead use MAX_NUMNODES-sized array of struct pxm2node to
store PXM-to-node mapping. To accommodate common case of zero-based
and contiguios PXMs we will, whenever possible, try to use PXM as
index into this array array for fast lookups.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Renamed p2n to pxm2node (and struct pxm2node to struct pxm_to_node)
* Changed node type in pxm_to_node to u8
* pxm_to_node(), setup_node() and node_to_pxm()) use unsigned as node
argument
* Reinitialized pxm2node in abd_srat();
* Added BUILD_BUG_ON(MAX_NUMNODES >= NUMA_NO_NODE);
* Made changes to K&R style (which is what this file uses)
xen/arch/x86/srat.c | 96 ++++++++++++++++++++++++++++++++------------
xen/include/asm-x86/numa.h | 4 +-
2 files changed, 72 insertions(+), 28 deletions(-)
diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 29fc724..1664393 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -27,35 +27,78 @@ static nodemask_t memory_nodes_parsed __initdata;
static nodemask_t processor_nodes_parsed __initdata;
static nodemask_t nodes_found __initdata;
static struct node nodes[MAX_NUMNODES] __initdata;
-static u8 __read_mostly pxm2node[256] = { [0 ... 255] = NUMA_NO_NODE };
+struct pxm_to_node {
+ unsigned pxm;
+ u8 node;
+};
+static struct pxm_to_node __read_mostly pxm2node[MAX_NUMNODES] =
+ { [0 ... MAX_NUMNODES - 1] = {.node = NUMA_NO_NODE} };
+
+static int node_to_pxm(unsigned n);
static int num_node_memblks;
static struct node node_memblk_range[NR_NODE_MEMBLKS];
static int memblk_nodeid[NR_NODE_MEMBLKS];
+static inline bool_t node_found(unsigned idx, unsigned pxm)
+{
+ return ((pxm2node[idx].pxm == pxm) &&
+ (pxm2node[idx].node != NUMA_NO_NODE));
+}
-static int node_to_pxm(int n);
-
-int pxm_to_node(int pxm)
+int pxm_to_node(unsigned pxm)
{
- if ((unsigned)pxm >= 256)
- return -1;
+ unsigned i;
+
+ if ((pxm < MAX_NUMNODES) && node_found(pxm, pxm))
+ return pxm2node[pxm].node;
+
+ for (i = 0; i < MAX_NUMNODES; i++)
+ if (node_found(i, pxm))
+ return pxm2node[i].node;
+
/* Extend 0xff to (int)-1 */
- return (signed char)pxm2node[pxm];
+ return (signed char)NUMA_NO_NODE;
}
-__devinit int setup_node(int pxm)
+__devinit int setup_node(unsigned pxm)
{
- unsigned node = pxm2node[pxm];
- if (node == 0xff) {
- if (nodes_weight(nodes_found) >= MAX_NUMNODES)
- return -1;
- node = first_unset_node(nodes_found);
- node_set(node, nodes_found);
- pxm2node[pxm] = node;
+ int node;
+ unsigned idx;
+ static bool_t warned;
+
+ BUILD_BUG_ON(MAX_NUMNODES >= NUMA_NO_NODE);
+
+ if (pxm < MAX_NUMNODES) {
+ if (node_found(pxm, pxm))
+ return pxm2node[pxm].node;
+
+ /* Try to maintain indexing of pxm2node by pxm */
+ if (pxm2node[pxm].node == NUMA_NO_NODE) {
+ idx = pxm;
+ goto finish;
+ }
+ }
+
+ for (idx = 0; idx < MAX_NUMNODES; idx++)
+ if (pxm2node[idx].node == NUMA_NO_NODE)
+ goto finish;
+
+ if (!warned) {
+ printk(XENLOG_WARNING "More PXMs than available nodes\n");
+ warned = 1;
}
- return pxm2node[pxm];
+
+ return (signed char)NUMA_NO_NODE;
+
+ finish:
+ node = first_unset_node(nodes_found);
+ node_set(node, nodes_found);
+ pxm2node[idx].pxm = pxm;
+ pxm2node[idx].node = node;
+
+ return node;
}
int valid_numa_range(u64 start, u64 end, int node)
@@ -111,8 +154,8 @@ static __init void bad_srat(void)
acpi_numa = -1;
for (i = 0; i < MAX_LOCAL_APIC; i++)
apicid_to_node[i] = NUMA_NO_NODE;
- for (i = 0; i < ARRAY_SIZE(pxm2node); i++)
- pxm2node[i] = NUMA_NO_NODE;
+ for (i = 0; i < MAX_NUMNODES; i++)
+ pxm2node[i].node = NUMA_NO_NODE;
mem_hotplug = 0;
}
@@ -438,15 +481,16 @@ int __init acpi_scan_nodes(u64 start, u64 end)
return 0;
}
-static int node_to_pxm(int n)
+static int node_to_pxm(unsigned n)
{
- int i;
- if (pxm2node[n] == n)
- return n;
- for (i = 0; i < 256; i++)
- if (pxm2node[i] == n)
- return i;
- return 0;
+ unsigned i;
+
+ if ((n < MAX_NUMNODES) && (pxm2node[n].node == n))
+ return pxm2node[n].pxm;
+ for (i = 0; i < MAX_NUMNODES; i++)
+ if (pxm2node[i].node == n)
+ return pxm2node[i].pxm;
+ return 0;
}
int __node_distance(int a, int b)
diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h
index 5959860..e491a9e 100644
--- a/xen/include/asm-x86/numa.h
+++ b/xen/include/asm-x86/numa.h
@@ -21,7 +21,7 @@ struct node {
extern int compute_hash_shift(struct node *nodes, int numnodes,
int *nodeids);
-extern int pxm_to_node(int nid);
+extern int pxm_to_node(unsigned pxm);
#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
#define VIRTUAL_BUG_ON(x)
@@ -33,7 +33,7 @@ extern int numa_off;
extern int srat_disabled(void);
extern void numa_set_node(int cpu, int node);
-extern int setup_node(int pxm);
+extern int setup_node(unsigned pxm);
extern void srat_detect_node(int cpu);
extern void setup_node_bootmem(int nodeid, u64 start, u64 end);
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] x86/numa: Adjust datatypes for node and pxm
2015-02-25 23:41 [PATCH v3 0/3] Updates to pxm2node mapping and nodeID sizing Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
@ 2015-02-25 23:41 ` Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 3/3] mm: MEMF_node should handle changes in nodeid_t size Boris Ostrovsky
2 siblings, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-02-25 23:41 UTC (permalink / raw)
To: keir, jbeulich, yang.z.zhang, kevin.tian, ian.campbell,
stefano.stabellini, tim
Cc: Andrew.Cooper3, dario.faggioli, boris.ostrovsky, xen-devel
Use u8-sized node IDs and unsigned PXMs consistently throughout
code (and introduce nodeid_t type).
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes n v3:
* Moved node declaration in cpu_add() into its scope.
xen/arch/x86/irq.c | 4 +-
xen/arch/x86/numa.c | 15 ++++++------
xen/arch/x86/setup.c | 2 +-
xen/arch/x86/smpboot.c | 6 +++-
xen/arch/x86/srat.c | 41 ++++++++++++++++++----------------
xen/arch/x86/x86_64/mm.c | 5 ++-
xen/common/page_alloc.c | 5 ++-
xen/drivers/passthrough/vtd/iommu.c | 5 ++-
xen/include/asm-arm/numa.h | 4 ++-
xen/include/asm-x86/irq.h | 3 +-
xen/include/asm-x86/numa.h | 24 +++++++++++---------
11 files changed, 64 insertions(+), 50 deletions(-)
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index f214072..9be8840 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -153,7 +153,7 @@ int __init bind_irq_vector(int irq, int vector, const cpumask_t *cpu_mask)
/*
* Dynamic irq allocate and deallocation for MSI
*/
-int create_irq(int node)
+int create_irq(nodeid_t node)
{
int irq, ret;
struct irq_desc *desc;
@@ -173,7 +173,7 @@ int create_irq(int node)
{
cpumask_t *mask = NULL;
- if (node != NUMA_NO_NODE && node >= 0)
+ if ( node != NUMA_NO_NODE )
{
mask = &node_to_cpumask(node);
if (cpumask_empty(mask))
diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 628a40a..7a01923 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -35,13 +35,13 @@ static typeof(*memnodemap) _memnodemap[64];
unsigned long memnodemapsize;
u8 *memnodemap;
-unsigned char cpu_to_node[NR_CPUS] __read_mostly = {
+nodeid_t cpu_to_node[NR_CPUS] __read_mostly = {
[0 ... NR_CPUS-1] = NUMA_NO_NODE
};
/*
* Keep BIOS's CPU2node information, should not be used for memory allocaion
*/
-unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
+nodeid_t apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
[0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
};
cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly;
@@ -65,7 +65,7 @@ int srat_disabled(void)
* -1 if node overlap or lost ram (shift too big)
*/
static int __init populate_memnodemap(const struct node *nodes,
- int numnodes, int shift, int *nodeids)
+ int numnodes, int shift, nodeid_t *nodeids)
{
unsigned long spdx, epdx;
int i, res = -1;
@@ -150,7 +150,7 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,
}
int __init compute_hash_shift(struct node *nodes, int numnodes,
- int *nodeids)
+ nodeid_t *nodeids)
{
int shift;
@@ -172,7 +172,7 @@ int __init compute_hash_shift(struct node *nodes, int numnodes,
return shift;
}
/* initialize NODE_DATA given nodeid and start/end */
-void __init setup_node_bootmem(int nodeid, u64 start, u64 end)
+void __init setup_node_bootmem(nodeid_t nodeid, u64 start, u64 end)
{
unsigned long start_pfn, end_pfn;
@@ -294,7 +294,7 @@ __cpuinit void numa_add_cpu(int cpu)
cpumask_set_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
}
-void __cpuinit numa_set_node(int cpu, int node)
+void __cpuinit numa_set_node(int cpu, nodeid_t node)
{
cpu_to_node[cpu] = node;
}
@@ -340,7 +340,8 @@ static __init int numa_setup(char *opt)
*/
void __init init_cpu_to_node(void)
{
- int i, node;
+ unsigned i;
+ nodeid_t node;
for ( i = 0; i < nr_cpu_ids; i++ )
{
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c27c49c..84da722 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -188,7 +188,7 @@ static void __init init_idle_domain(void)
void __devinit srat_detect_node(int cpu)
{
- unsigned node;
+ nodeid_t node;
u32 apicid = x86_cpu_to_apicid[cpu];
node = apicid_to_node[apicid];
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index c54be7e..ea84fe0 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -843,7 +843,7 @@ void __cpu_die(unsigned int cpu)
int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm)
{
- int node, cpu = -1;
+ int cpu = -1;
dprintk(XENLOG_DEBUG, "cpu_add apic_id %x acpi_id %x pxm %x\n",
apic_id, acpi_id, pxm);
@@ -877,7 +877,9 @@ int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm)
if ( !srat_disabled() )
{
- if ( (node = setup_node(pxm)) < 0 )
+ nodeid_t node = setup_node(pxm);
+
+ if ( node == NUMA_NO_NODE )
{
dprintk(XENLOG_WARNING,
"Setup node failed for pxm %x\n", pxm);
diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 1664393..5a237a3 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -30,16 +30,16 @@ static struct node nodes[MAX_NUMNODES] __initdata;
struct pxm_to_node {
unsigned pxm;
- u8 node;
+ nodeid_t node;
};
static struct pxm_to_node __read_mostly pxm2node[MAX_NUMNODES] =
{ [0 ... MAX_NUMNODES - 1] = {.node = NUMA_NO_NODE} };
-static int node_to_pxm(unsigned n);
+static unsigned node_to_pxm(nodeid_t n);
static int num_node_memblks;
static struct node node_memblk_range[NR_NODE_MEMBLKS];
-static int memblk_nodeid[NR_NODE_MEMBLKS];
+static nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
static inline bool_t node_found(unsigned idx, unsigned pxm)
{
@@ -47,7 +47,7 @@ static inline bool_t node_found(unsigned idx, unsigned pxm)
(pxm2node[idx].node != NUMA_NO_NODE));
}
-int pxm_to_node(unsigned pxm)
+nodeid_t pxm_to_node(unsigned pxm)
{
unsigned i;
@@ -58,13 +58,12 @@ int pxm_to_node(unsigned pxm)
if (node_found(i, pxm))
return pxm2node[i].node;
- /* Extend 0xff to (int)-1 */
- return (signed char)NUMA_NO_NODE;
+ return NUMA_NO_NODE;
}
-__devinit int setup_node(unsigned pxm)
+__devinit nodeid_t setup_node(unsigned pxm)
{
- int node;
+ nodeid_t node;
unsigned idx;
static bool_t warned;
@@ -90,7 +89,7 @@ __devinit int setup_node(unsigned pxm)
warned = 1;
}
- return (signed char)NUMA_NO_NODE;
+ return NUMA_NO_NODE;
finish:
node = first_unset_node(nodes_found);
@@ -101,7 +100,7 @@ __devinit int setup_node(unsigned pxm)
return node;
}
-int valid_numa_range(u64 start, u64 end, int node)
+int valid_numa_range(u64 start, u64 end, nodeid_t node)
{
int i;
@@ -205,8 +204,9 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
void __init
acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
{
- int pxm, node;
- int apic_id;
+ unsigned pxm;
+ nodeid_t node;
+ u32 apic_id;
if (srat_disabled())
return;
@@ -218,7 +218,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
return;
pxm = pa->proximity_domain;
node = setup_node(pxm);
- if (node < 0) {
+ if (node == NUMA_NO_NODE) {
printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
bad_srat();
return;
@@ -235,7 +235,9 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
void __init
acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
{
- int pxm, node;
+ unsigned pxm;
+ nodeid_t node;
+
if (srat_disabled())
return;
if (pa->header.length != sizeof(struct acpi_srat_cpu_affinity)) {
@@ -251,7 +253,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
pxm |= pa->proximity_domain_hi[2] << 24;
}
node = setup_node(pxm);
- if (node < 0) {
+ if (node == NUMA_NO_NODE) {
printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
bad_srat();
return;
@@ -269,7 +271,8 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
{
struct node *nd;
u64 start, end;
- int node, pxm;
+ unsigned pxm;
+ nodeid_t node;
int i;
if (srat_disabled())
@@ -295,7 +298,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
if (srat_rev < 2)
pxm &= 0xff;
node = setup_node(pxm);
- if (node < 0) {
+ if (node == NUMA_NO_NODE) {
printk(KERN_ERR "SRAT: Too many proximity domains.\n");
bad_srat();
return;
@@ -481,7 +484,7 @@ int __init acpi_scan_nodes(u64 start, u64 end)
return 0;
}
-static int node_to_pxm(unsigned n)
+static unsigned node_to_pxm(nodeid_t n)
{
unsigned i;
@@ -493,7 +496,7 @@ static int node_to_pxm(unsigned n)
return 0;
}
-int __node_distance(int a, int b)
+int __node_distance(nodeid_t a, nodeid_t b)
{
int index;
diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index d631aee..6875c92 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -1343,7 +1343,8 @@ int mem_hotadd_check(unsigned long spfn, unsigned long epfn)
int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
{
struct mem_hotadd_info info;
- int ret, node;
+ int ret;
+ nodeid_t node;
unsigned long old_max = max_page, old_total = total_pages;
unsigned long old_node_start, old_node_span, orig_online;
unsigned long i;
@@ -1353,7 +1354,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
if ( !mem_hotadd_check(spfn, epfn) )
return -EINVAL;
- if ( (node = setup_node(pxm)) == -1 )
+ if ( (node = setup_node(pxm)) == NUMA_NO_NODE )
return -EINVAL;
if ( !valid_numa_range(spfn << PAGE_SHIFT, epfn << PAGE_SHIFT, node) )
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 7b4092d..124fa88 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -581,7 +581,7 @@ static struct page_info *alloc_heap_pages(
struct domain *d)
{
unsigned int first_node, i, j, zone = 0, nodemask_retry = 0;
- unsigned int node = (uint8_t)((memflags >> _MEMF_node) - 1);
+ nodeid_t node = (nodeid_t)((memflags >> _MEMF_node) - 1);
unsigned long request = 1UL << order;
struct page_info *pg;
nodemask_t nodemask = (d != NULL ) ? d->node_affinity : node_online_map;
@@ -1278,7 +1278,8 @@ static void __init smp_scrub_heap_pages(void *data)
unsigned long mfn, start, end;
struct page_info *pg;
struct scrub_region *r;
- unsigned int temp_cpu, node, cpu_idx = 0;
+ unsigned int temp_cpu, cpu_idx = 0;
+ nodeid_t node;
unsigned int cpu = smp_processor_id();
if ( data )
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 19d8165..2e0af6f 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -190,14 +190,15 @@ u64 alloc_pgtable_maddr(struct acpi_drhd_unit *drhd, unsigned long npages)
struct acpi_rhsa_unit *rhsa;
struct page_info *pg, *cur_pg;
u64 *vaddr;
- int node = -1, i;
+ nodeid_t node = NUMA_NO_NODE;
+ unsigned i;
rhsa = drhd_to_rhsa(drhd);
if ( rhsa )
node = pxm_to_node(rhsa->proximity_domain);
pg = alloc_domheap_pages(NULL, get_order_from_pages(npages),
- (node == -1 ) ? 0 : MEMF_node(node));
+ (node == NUMA_NO_NODE) ? 0 : MEMF_node(node));
if ( !pg )
return 0;
diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h
index 06a9d5a..a00cb7c 100644
--- a/xen/include/asm-arm/numa.h
+++ b/xen/include/asm-arm/numa.h
@@ -1,11 +1,13 @@
#ifndef __ARCH_ARM_NUMA_H
#define __ARCH_ARM_NUMA_H
+typedef u8 nodeid_t;
+
/* Fake one node for now. See also node_online_map. */
#define cpu_to_node(cpu) 0
#define node_to_cpumask(node) (cpu_online_map)
-static inline __attribute__((pure)) int phys_to_nid(paddr_t addr)
+static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)
{
return 0;
}
diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h
index d3c55f3..a44305e 100644
--- a/xen/include/asm-x86/irq.h
+++ b/xen/include/asm-x86/irq.h
@@ -5,6 +5,7 @@
#include <xen/config.h>
#include <asm/atomic.h>
+#include <asm/numa.h>
#include <xen/cpumask.h>
#include <xen/smp.h>
#include <xen/hvm/irq.h>
@@ -155,7 +156,7 @@ int init_irq_data(void);
void clear_irq_vector(int irq);
int irq_to_vector(int irq);
-int create_irq(int node);
+int create_irq(nodeid_t node);
void destroy_irq(unsigned int irq);
int assign_irq_vector(int irq, const cpumask_t *);
diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h
index e491a9e..419f770 100644
--- a/xen/include/asm-x86/numa.h
+++ b/xen/include/asm-x86/numa.h
@@ -5,6 +5,8 @@
#define NODES_SHIFT 6
+typedef u8 nodeid_t;
+
extern int srat_rev;
extern unsigned char cpu_to_node[];
@@ -20,8 +22,8 @@ struct node {
};
extern int compute_hash_shift(struct node *nodes, int numnodes,
- int *nodeids);
-extern int pxm_to_node(unsigned pxm);
+ nodeid_t *nodeids);
+extern nodeid_t pxm_to_node(unsigned pxm);
#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
#define VIRTUAL_BUG_ON(x)
@@ -32,12 +34,12 @@ extern int numa_off;
extern int srat_disabled(void);
-extern void numa_set_node(int cpu, int node);
-extern int setup_node(unsigned pxm);
+extern void numa_set_node(int cpu, nodeid_t node);
+extern nodeid_t setup_node(unsigned pxm);
extern void srat_detect_node(int cpu);
-extern void setup_node_bootmem(int nodeid, u64 start, u64 end);
-extern unsigned char apicid_to_node[];
+extern void setup_node_bootmem(nodeid_t nodeid, u64 start, u64 end);
+extern nodeid_t apicid_to_node[];
#ifdef CONFIG_NUMA
extern void init_cpu_to_node(void);
@@ -54,14 +56,14 @@ extern u8 *memnodemap;
struct node_data {
unsigned long node_start_pfn;
unsigned long node_spanned_pages;
- unsigned int node_id;
+ nodeid_t node_id;
};
extern struct node_data node_data[];
-static inline __attribute__((pure)) int phys_to_nid(paddr_t addr)
+static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)
{
- unsigned nid;
+ nodeid_t nid;
VIRTUAL_BUG_ON((paddr_to_pdx(addr) >> memnode_shift) >= memnodemapsize);
nid = memnodemap[paddr_to_pdx(addr) >> memnode_shift];
VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
@@ -75,7 +77,7 @@ static inline __attribute__((pure)) int phys_to_nid(paddr_t addr)
#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
NODE_DATA(nid)->node_spanned_pages)
-extern int valid_numa_range(u64 start, u64 end, int node);
+extern int valid_numa_range(u64 start, u64 end, nodeid_t node);
#else
#define init_cpu_to_node() do {} while (0)
#define clear_node_cpumask(cpu) do {} while (0)
@@ -83,6 +85,6 @@ extern int valid_numa_range(u64 start, u64 end, int node);
#endif
void srat_parse_regions(u64 addr);
-extern int __node_distance(int a, int b);
+extern int __node_distance(nodeid_t a, nodeid_t b);
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] mm: MEMF_node should handle changes in nodeid_t size
2015-02-25 23:41 [PATCH v3 0/3] Updates to pxm2node mapping and nodeID sizing Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 2/3] x86/numa: Adjust datatypes for node and pxm Boris Ostrovsky
@ 2015-02-25 23:41 ` Boris Ostrovsky
2 siblings, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-02-25 23:41 UTC (permalink / raw)
To: keir, jbeulich, yang.z.zhang, kevin.tian, ian.campbell,
stefano.stabellini, tim
Cc: Andrew.Cooper3, dario.faggioli, boris.ostrovsky, xen-devel
Instead of using a hardcoded constant to extract nodeID from
memflags use a macro whose value is based on nodeid_t size.
Also provide a macro for extracting nodeID from memflags so that
users don't need to remember to decrement the value.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Fixed shift for MEMF_node_mask and moved it a few lines down
* Added BUILD_BUG_ON((_MEMF_bits - _MEMF_node) >= (8 * sizeof(nodeid_t))) to
alloc_heap_pages() (Not sure it's the best place).
xen/common/page_alloc.c | 5 ++++-
xen/include/xen/mm.h | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 124fa88..08d8ed6 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -581,13 +581,16 @@ static struct page_info *alloc_heap_pages(
struct domain *d)
{
unsigned int first_node, i, j, zone = 0, nodemask_retry = 0;
- nodeid_t node = (nodeid_t)((memflags >> _MEMF_node) - 1);
+ nodeid_t node = MEMF2NODE(memflags);
unsigned long request = 1UL << order;
struct page_info *pg;
nodemask_t nodemask = (d != NULL ) ? d->node_affinity : node_online_map;
bool_t need_tlbflush = 0;
uint32_t tlbflush_timestamp = 0;
+ /* Make sure there are enough bits in memflags for nodeID */
+ BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t)));
+
if ( node == NUMA_NO_NODE )
{
memflags &= ~MEMF_exact_node;
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 74a65a6..788fbdd 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -121,10 +121,13 @@ struct npfec {
#define _MEMF_exact_node 4
#define MEMF_exact_node (1U<<_MEMF_exact_node)
#define _MEMF_node 8
-#define MEMF_node(n) ((((n)+1)&0xff)<<_MEMF_node)
+#define MEMF_node_mask ((1U<<(8*sizeof(nodeid_t)))-1)
+#define MEMF_node(n) ((((n)+1)&MEMF_node_mask)<<_MEMF_node)
#define _MEMF_bits 24
#define MEMF_bits(n) ((n)<<_MEMF_bits)
+#define MEMF2NODE(memflags) (MASK_EXTR(memflags,MEMF_node_mask)-1)
+
#ifdef CONFIG_PAGEALLOC_MAX_ORDER
#define MAX_ORDER CONFIG_PAGEALLOC_MAX_ORDER
#else
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
@ 2015-02-26 8:38 ` Jan Beulich
2015-02-26 9:06 ` Dario Faggioli
1 sibling, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2015-02-26 8:38 UTC (permalink / raw)
To: Boris Ostrovsky
Cc: kevin.tian, keir, ian.campbell, Andrew.Cooper3, dario.faggioli,
tim, xen-devel, stefano.stabellini, yang.z.zhang
>>> On 26.02.15 at 00:41, <boris.ostrovsky@oracle.com> wrote:
> * Made changes to K&R style (which is what this file uses)
I don't find anything K&R style here, and I think the compiler would
have prevented you from doing any such (by way for issuing
warnings and us using -Werror). I'm sure you mean Linux instead.
> @@ -111,8 +154,8 @@ static __init void bad_srat(void)
> acpi_numa = -1;
> for (i = 0; i < MAX_LOCAL_APIC; i++)
> apicid_to_node[i] = NUMA_NO_NODE;
> - for (i = 0; i < ARRAY_SIZE(pxm2node); i++)
> - pxm2node[i] = NUMA_NO_NODE;
> + for (i = 0; i < MAX_NUMNODES; i++)
> + pxm2node[i].node = NUMA_NO_NODE;
It escapes me why the ARRAY_SIZE() use needed replacing. I'm
going to undo that before committing, and in fact will adjust other
similar bounds checks to use it too.
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
2015-02-26 8:38 ` Jan Beulich
@ 2015-02-26 9:06 ` Dario Faggioli
1 sibling, 0 replies; 6+ messages in thread
From: Dario Faggioli @ 2015-02-26 9:06 UTC (permalink / raw)
To: boris.ostrovsky@oracle.com
Cc: Kevin Tian, Keir (Xen.org), Ian Campbell, Andrew Cooper,
Tim (Xen.org), xen-devel@lists.xen.org, Stefano Stabellini,
jbeulich@suse.com, yang.z.zhang@intel.com
[-- Attachment #1.1: Type: text/plain, Size: 586 bytes --]
On Wed, 2015-02-25 at 18:41 -0500, Boris Ostrovsky wrote:
> ACPI defines proximity domain identifier as a 32-bit integer. While
> in most cases the values will be zero-based this is not guaranteed,
> making current pxm2node[256] mapping structure not appropriate.
>
> We will instead use MAX_NUMNODES-sized array of struct pxm2node to
> store PXM-to-node mapping. To accommodate common case of zero-based
> and contiguios PXMs we will, whenever possible, try to use PXM as
> index into this array array for fast lookups.
>
^array for fast lookups.
Dario
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-26 9:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 23:41 [PATCH v3 0/3] Updates to pxm2node mapping and nodeID sizing Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 1/3] x86/numa: Allow arbitrary value of PXM in PXM<->node mapping Boris Ostrovsky
2015-02-26 8:38 ` Jan Beulich
2015-02-26 9:06 ` Dario Faggioli
2015-02-25 23:41 ` [PATCH v3 2/3] x86/numa: Adjust datatypes for node and pxm Boris Ostrovsky
2015-02-25 23:41 ` [PATCH v3 3/3] mm: MEMF_node should handle changes in nodeid_t size Boris Ostrovsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.