diff mbox

[RFC,v1,17/21] ARM: NUMA: Extract memory proximity from SRAT table

Message ID 1486655834-9708-18-git-send-email-vijay.kilari@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vijay Kilari Feb. 9, 2017, 3:57 p.m. UTC
From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>

Register SRAT entry handler for type
ACPI_SRAT_TYPE_MEMORY_AFFINITY to parse SRAT table
and extract proximity for all memory mappings.

Signed-off-by: Vijaya Kumar <Vijaya.Kumar@cavium.com>
---
 xen/arch/arm/acpi_numa.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

Comments

Konrad Rzeszutek Wilk Feb. 10, 2017, 5:33 p.m. UTC | #1
On Thu, Feb 09, 2017 at 09:27:09PM +0530, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> 
> Register SRAT entry handler for type
> ACPI_SRAT_TYPE_MEMORY_AFFINITY to parse SRAT table
> and extract proximity for all memory mappings.

Why can't you use arch/x86/srat.c code? Or move parts of that code to an
common code?
Konrad Rzeszutek Wilk Feb. 10, 2017, 5:35 p.m. UTC | #2
On Fri, Feb 10, 2017 at 12:33:33PM -0500, Konrad Rzeszutek Wilk wrote:
> On Thu, Feb 09, 2017 at 09:27:09PM +0530, vijay.kilari@gmail.com wrote:
> > From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> > 
> > Register SRAT entry handler for type
> > ACPI_SRAT_TYPE_MEMORY_AFFINITY to parse SRAT table
> > and extract proximity for all memory mappings.
> 
> Why can't you use arch/x86/srat.c code? Or move parts of that code to an
> common code?

And to be clear - I meant the 'acpi_numa_memory_affinity_init' function?
Vijay Kilari March 2, 2017, 2:41 p.m. UTC | #3
On Fri, Feb 10, 2017 at 11:05 PM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Fri, Feb 10, 2017 at 12:33:33PM -0500, Konrad Rzeszutek Wilk wrote:
>> On Thu, Feb 09, 2017 at 09:27:09PM +0530, vijay.kilari@gmail.com wrote:
>> > From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>> >
>> > Register SRAT entry handler for type
>> > ACPI_SRAT_TYPE_MEMORY_AFFINITY to parse SRAT table
>> > and extract proximity for all memory mappings.
>>
>> Why can't you use arch/x86/srat.c code? Or move parts of that code to an
>> common code?
>
> And to be clear - I meant the 'acpi_numa_memory_affinity_init' function?

OK. I will check.

Thanks
Vijay
diff mbox

Patch

diff --git a/xen/arch/arm/acpi_numa.c b/xen/arch/arm/acpi_numa.c
index f659275..23cb07b 100644
--- a/xen/arch/arm/acpi_numa.c
+++ b/xen/arch/arm/acpi_numa.c
@@ -30,6 +30,9 @@ 
 #include <asm/page.h>
 #include <asm/acpi.h>
 
+extern int num_node_memblks;
+extern struct node node_memblk_range[NR_NODE_MEMBLKS];
+extern nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
 extern nodemask_t numa_nodes_parsed;
 struct uid_to_mpidr {
     u32 uid;
@@ -38,6 +41,7 @@  struct uid_to_mpidr {
 
 /* Holds mapping of CPU id to MPIDR read from MADT */
 static struct uid_to_mpidr cpu_uid_to_hwid[NR_CPUS] __read_mostly;
+static __initdata DECLARE_BITMAP(memblk_hotplug, NR_NODE_MEMBLKS);
 
 static __init void bad_srat(void)
 {
@@ -160,6 +164,82 @@  void __init acpi_numa_gicc_affinity_init(const struct acpi_srat_gicc_affinity *p
            pxm, mpidr, node);
 }
 
+/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
+void __init
+acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)
+{
+    u64 start, end;
+    unsigned pxm;
+    nodeid_t node;
+    int i;
+
+    if ( srat_disabled() )
+        return;
+
+    if ( ma->header.length != sizeof(struct acpi_srat_mem_affinity) )
+    {
+        bad_srat();
+        return;
+    }
+    if ( !(ma->flags & ACPI_SRAT_MEM_ENABLED) )
+        return;
+
+    if ( num_node_memblks >= NR_NODE_MEMBLKS )
+    {
+        printk(XENLOG_WARNING
+               "Too many numa entry, try bigger NR_NODE_MEMBLKS \n");
+        bad_srat();
+        return;
+    }
+
+    start = ma->base_address;
+    end = start + ma->length;
+    pxm = ma->proximity_domain;
+    node = setup_node(pxm);
+    if ( node == NUMA_NO_NODE )
+    {
+        bad_srat();
+        return;
+    }
+    /* It is fine to add this area to the nodes data it will be used later*/
+    i = conflicting_memblks(start, end);
+    if ( i < 0 )
+        /* everything fine */;
+    else if ( memblk_nodeid[i] == node )
+    {
+        bool_t mismatch = !(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) !=
+                           !test_bit(i, memblk_hotplug);
+
+        printk(XENLOG_WARNING
+               "%sSRAT: PXM %u (%"PRIx64"-%"PRIx64") overlaps with itself (%"PRIx64"-%"PRIx64")\n",
+               mismatch ? KERN_ERR : KERN_WARNING, pxm, start, end,
+               node_memblk_range[i].start, node_memblk_range[i].end);
+        if ( mismatch )
+        {
+            bad_srat();
+            return;
+        }
+    }
+    else
+    {
+         printk(XENLOG_WARNING
+                "SRAT: PXM %u (%"PRIx64"-%"PRIx64") overlaps with PXM %u (%"PRIx64"-%"PRIx64")\n",
+                pxm, start, end, node_to_pxm(memblk_nodeid[i]),
+                node_memblk_range[i].start, node_memblk_range[i].end);
+        bad_srat();
+        return;
+    }
+
+    printk(XENLOG_INFO "SRAT: Node %u PXM %u %"PRIx64"-%"PRIx64"%s\n",
+           node, pxm, start, end,
+           ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE ? " (hotplug)" : "");
+
+    numa_add_memblk(node, start, ma->length);
+    node_set(node, numa_nodes_parsed);
+    if (ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
+        __set_bit(num_node_memblks, memblk_hotplug);
+}
+
 void __init acpi_map_uid_to_mpidr(void)
 {
     int i;