diff mbox

[RFC,v1,18/21] ARM: NUMA: update node_distance with ACPI support

Message ID 1486655834-9708-19-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>

Update node_distance() function to handle
ACPI SLIT table information.

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

Comments

Julien Grall March 2, 2017, 5:24 p.m. UTC | #1
Hello Vijay,

On 09/02/17 15:57, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>
> Update node_distance() function to handle
> ACPI SLIT table information.
>
> Signed-off-by: Vijaya Kumar <Vijaya.Kumar@cavium.com>
> ---
>  xen/arch/arm/numa.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
> index 5c49347..50c3dea 100644
> --- a/xen/arch/arm/numa.c
> +++ b/xen/arch/arm/numa.c
> @@ -23,6 +23,7 @@
>  #include <xen/acpi.h>
>  #include <asm/mm.h>
>  #include <xen/numa.h>
> +#include <xen/srat.h>
>  #include <asm/acpi.h>
>  #include <xen/errno.h>
>  #include <xen/cpumask.h>
> @@ -35,6 +36,7 @@ extern struct node nodes[MAX_NUMNODES] __initdata;
>  extern int num_node_memblks;
>  extern struct node node_memblk_range[NR_NODE_MEMBLKS];
>  extern nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
> +extern struct acpi_table_slit *__read_mostly acpi_slit;
>
>  void __init numa_set_cpu_node(int cpu, unsigned long hwid)
>  {
> @@ -50,9 +52,24 @@ void __init numa_set_cpu_node(int cpu, unsigned long hwid)
>
>  u8 __node_distance(nodeid_t a, nodeid_t b)
>  {
> -    if ( !node_distance )
> +    unsigned index;
> +    u8 slit_val;
> +
> +    if ( !node_distance && !acpi_slit )
>          return a == b ? 10 : 20;
>
> +    if ( acpi_slit )
> +    {
> +        index = acpi_slit->locality_count * node_to_pxm(a);
> +        slit_val = acpi_slit->entry[index + node_to_pxm(b)];
> +
> +        /* ACPI defines 0xff as an unreachable node and 0-9 are undefined */
> +        if ( (slit_val == 0xff) || (slit_val <= 9) )
> +            return NUMA_NO_DISTANCE;
> +        else
> +            return slit_val;
> +    }
> +

arm/numa.c is the generic code and should not contain any ACPI specific 
code.

But as I said, the way to get the distance on ACPI is the same on x86 
and ARM.

So I would introduce __node_distance callback that will be setup at 
boot-time to either point to the ACPI version or DT version.

Regards,
Vijay Kilari March 3, 2017, 12:43 p.m. UTC | #2
On Thu, Mar 2, 2017 at 10:54 PM, Julien Grall <julien.grall@arm.com> wrote:
> Hello Vijay,
>
>
> On 09/02/17 15:57, vijay.kilari@gmail.com wrote:
>>
>> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>>
>> Update node_distance() function to handle
>> ACPI SLIT table information.
>>
>> Signed-off-by: Vijaya Kumar <Vijaya.Kumar@cavium.com>
>> ---
>>  xen/arch/arm/numa.c | 20 +++++++++++++++++++-
>>  1 file changed, 19 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
>> index 5c49347..50c3dea 100644
>> --- a/xen/arch/arm/numa.c
>> +++ b/xen/arch/arm/numa.c
>> @@ -23,6 +23,7 @@
>>  #include <xen/acpi.h>
>>  #include <asm/mm.h>
>>  #include <xen/numa.h>
>> +#include <xen/srat.h>
>>  #include <asm/acpi.h>
>>  #include <xen/errno.h>
>>  #include <xen/cpumask.h>
>> @@ -35,6 +36,7 @@ extern struct node nodes[MAX_NUMNODES] __initdata;
>>  extern int num_node_memblks;
>>  extern struct node node_memblk_range[NR_NODE_MEMBLKS];
>>  extern nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
>> +extern struct acpi_table_slit *__read_mostly acpi_slit;
>>
>>  void __init numa_set_cpu_node(int cpu, unsigned long hwid)
>>  {
>> @@ -50,9 +52,24 @@ void __init numa_set_cpu_node(int cpu, unsigned long
>> hwid)
>>
>>  u8 __node_distance(nodeid_t a, nodeid_t b)
>>  {
>> -    if ( !node_distance )
>> +    unsigned index;
>> +    u8 slit_val;
>> +
>> +    if ( !node_distance && !acpi_slit )
>>          return a == b ? 10 : 20;
>>
>> +    if ( acpi_slit )
>> +    {
>> +        index = acpi_slit->locality_count * node_to_pxm(a);
>> +        slit_val = acpi_slit->entry[index + node_to_pxm(b)];
>> +
>> +        /* ACPI defines 0xff as an unreachable node and 0-9 are undefined
>> */
>> +        if ( (slit_val == 0xff) || (slit_val <= 9) )
>> +            return NUMA_NO_DISTANCE;
>> +        else
>> +            return slit_val;
>> +    }
>> +
>
>
> arm/numa.c is the generic code and should not contain any ACPI specific
> code.
Agreed.
>
> But as I said, the way to get the distance on ACPI is the same on x86 and
> ARM.
>
> So I would introduce __node_distance callback that will be setup at
> boot-time to either point to the ACPI version or DT version.

Instead of callback, Just call acpi's node_distance function if acpi is enabled
or else dt based.
Julien Grall March 3, 2017, 1:46 p.m. UTC | #3
Hello Vijay,

On 03/03/17 12:43, Vijay Kilari wrote:
> On Thu, Mar 2, 2017 at 10:54 PM, Julien Grall <julien.grall@arm.com> wrote:
>> Hello Vijay,
>>
>>
>> On 09/02/17 15:57, vijay.kilari@gmail.com wrote:
>>>
>>> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>>>
>>> Update node_distance() function to handle
>>> ACPI SLIT table information.
>>>
>>> Signed-off-by: Vijaya Kumar <Vijaya.Kumar@cavium.com>
>>> ---
>>>  xen/arch/arm/numa.c | 20 +++++++++++++++++++-
>>>  1 file changed, 19 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
>>> index 5c49347..50c3dea 100644
>>> --- a/xen/arch/arm/numa.c
>>> +++ b/xen/arch/arm/numa.c
>>> @@ -23,6 +23,7 @@
>>>  #include <xen/acpi.h>
>>>  #include <asm/mm.h>
>>>  #include <xen/numa.h>
>>> +#include <xen/srat.h>
>>>  #include <asm/acpi.h>
>>>  #include <xen/errno.h>
>>>  #include <xen/cpumask.h>
>>> @@ -35,6 +36,7 @@ extern struct node nodes[MAX_NUMNODES] __initdata;
>>>  extern int num_node_memblks;
>>>  extern struct node node_memblk_range[NR_NODE_MEMBLKS];
>>>  extern nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
>>> +extern struct acpi_table_slit *__read_mostly acpi_slit;
>>>
>>>  void __init numa_set_cpu_node(int cpu, unsigned long hwid)
>>>  {
>>> @@ -50,9 +52,24 @@ void __init numa_set_cpu_node(int cpu, unsigned long
>>> hwid)
>>>
>>>  u8 __node_distance(nodeid_t a, nodeid_t b)
>>>  {
>>> -    if ( !node_distance )
>>> +    unsigned index;
>>> +    u8 slit_val;
>>> +
>>> +    if ( !node_distance && !acpi_slit )
>>>          return a == b ? 10 : 20;
>>>
>>> +    if ( acpi_slit )
>>> +    {
>>> +        index = acpi_slit->locality_count * node_to_pxm(a);
>>> +        slit_val = acpi_slit->entry[index + node_to_pxm(b)];
>>> +
>>> +        /* ACPI defines 0xff as an unreachable node and 0-9 are undefined
>>> */
>>> +        if ( (slit_val == 0xff) || (slit_val <= 9) )
>>> +            return NUMA_NO_DISTANCE;
>>> +        else
>>> +            return slit_val;
>>> +    }
>>> +
>>
>>
>> arm/numa.c is the generic code and should not contain any ACPI specific
>> code.
> Agreed.
>>
>> But as I said, the way to get the distance on ACPI is the same on x86 and
>> ARM.
>>
>> So I would introduce __node_distance callback that will be setup at
>> boot-time to either point to the ACPI version or DT version.
>
> Instead of callback, Just call acpi's node_distance function if acpi is enabled
> or else dt based.

Why? I don't see any reason to want checking whether acpi is enabled 
everytime __node_distance is called. The value will never change at runtime.

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
index 5c49347..50c3dea 100644
--- a/xen/arch/arm/numa.c
+++ b/xen/arch/arm/numa.c
@@ -23,6 +23,7 @@ 
 #include <xen/acpi.h>
 #include <asm/mm.h>
 #include <xen/numa.h>
+#include <xen/srat.h>
 #include <asm/acpi.h>
 #include <xen/errno.h>
 #include <xen/cpumask.h>
@@ -35,6 +36,7 @@  extern struct node nodes[MAX_NUMNODES] __initdata;
 extern int num_node_memblks;
 extern struct node node_memblk_range[NR_NODE_MEMBLKS];
 extern nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
+extern struct acpi_table_slit *__read_mostly acpi_slit;
 
 void __init numa_set_cpu_node(int cpu, unsigned long hwid)
 {
@@ -50,9 +52,24 @@  void __init numa_set_cpu_node(int cpu, unsigned long hwid)
 
 u8 __node_distance(nodeid_t a, nodeid_t b)
 {
-    if ( !node_distance )
+    unsigned index;
+    u8 slit_val;
+
+    if ( !node_distance && !acpi_slit )
         return a == b ? 10 : 20;
 
+    if ( acpi_slit )
+    {
+        index = acpi_slit->locality_count * node_to_pxm(a);
+        slit_val = acpi_slit->entry[index + node_to_pxm(b)];
+
+        /* ACPI defines 0xff as an unreachable node and 0-9 are undefined */
+        if ( (slit_val == 0xff) || (slit_val <= 9) )
+            return NUMA_NO_DISTANCE;
+        else
+            return slit_val;
+    }
+
     return _node_distance[a * MAX_NUMNODES + b];
 }
 
@@ -140,6 +157,7 @@  static void __init numa_dummy_init(unsigned long start_pfn,
     nodes_clear(node_online_map);
     node_set_online(0);
 
+    acpi_slit = NULL;
     for ( i = 0; i < NR_CPUS; i++ )
         numa_set_node(i, 0);