All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vijay Kilari <vijay.kilari@gmail.com>
To: Julien Grall <julien.grall@arm.com>
Cc: Tim Deegan <tim@xen.org>,
	kevin.tian@intel.com, Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Dario Faggioli <dario.faggioli@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Subject: Re: [RFC PATCH v3 15/24] ARM: NUMA: DT: Add CPU NUMA support
Date: Tue, 25 Jul 2017 12:17:08 +0530	[thread overview]
Message-ID: <CALicx6tp7zU2NSd3USgcxixBv3HYO8QqGVT+=xQhkq66AVyx7Q@mail.gmail.com> (raw)
In-Reply-To: <1b4adfe8-c66d-b701-a6ee-815fb7b38734@arm.com>

Hi Julien,

On Mon, Jul 24, 2017 at 4:54 PM, Julien Grall <julien.grall@arm.com> wrote:
> Hi Vijay,
>
>
> On 18/07/17 12:41, vijay.kilari@gmail.com wrote:
>>
>> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>>
>> For each cpu, update cpu_to_node[] with node id from
>> the numa-node-id DT property. Also, initialize cpu_to_node[]
>> with node 0.
>>
>> Add macros to access cpu_to_node[] information.
>>
>> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>> ---
>> v3: - Dropped numa_add_cpu declaration from asm-arm/numa.h
>>     - Dropped stale declarations
>>     - Call numa_add_cpu for cpu0
>> ---
>>  xen/arch/arm/numa/numa.c   | 21 +++++++++++++++++++++
>>  xen/arch/arm/setup.c       |  2 ++
>>  xen/arch/arm/smpboot.c     | 25 ++++++++++++++++++++++++-
>>  xen/include/asm-arm/numa.h |  7 +++++++
>>  xen/include/asm-x86/numa.h |  1 -
>>  xen/include/xen/numa.h     |  1 +
>>  6 files changed, 55 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/arch/arm/numa/numa.c b/xen/arch/arm/numa/numa.c
>> index c00b92c..dc80aa5 100644
>> --- a/xen/arch/arm/numa/numa.c
>> +++ b/xen/arch/arm/numa/numa.c
>> @@ -22,11 +22,31 @@
>>
>>  static uint8_t (*node_distance_fn)(nodeid_t a, nodeid_t b);
>>
>> +/*
>> + * Setup early cpu_to_node.
>> + */
>> +void __init init_cpu_to_node(void)
>> +{
>> +    int i;
>> +
>> +    for ( i = 0; i < NR_CPUS; i++ )
>> +        numa_set_node(i, 0);
>> +}
>
>
> From the comment: "Setup early cpu_to_node". However this is not how you are
> using it.

Ok. I will update the comment.

>
> But I am not sure why it is even here...
>
>> +
>>  void numa_failed(void)
>>  {
>>      numa_off = true;
>>      init_dt_numa_distance();
>>      node_distance_fn = NULL;
>> +    init_cpu_to_node();
>> +}
>> +
>> +void __init numa_set_cpu_node(int cpu, unsigned int nid)
>> +{
>> +    if ( !node_isset(nid, processor_nodes_parsed) || nid >= MAX_NUMNODES
>> )
>> +        nid = 0;
>
>
> This looks wrong to me. If the node-id is invalid, why would you blindly set
> to 0?

Generally this check will not pass. I will make this function return
error code in case
of wrong nid.

>
>
>> +
>> +    numa_set_node(cpu, nid);
>>  }
>>
>>  uint8_t __node_distance(nodeid_t a, nodeid_t b)
>> @@ -49,6 +69,7 @@ void __init numa_init(void)
>>      int ret = 0;
>>
>>      nodes_clear(processor_nodes_parsed);
>> +    init_cpu_to_node();
>>      init_dt_numa_distance();
>>
>>      if ( numa_off )
>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>> index a6d1499..b9c8b0d 100644
>> --- a/xen/arch/arm/setup.c
>> +++ b/xen/arch/arm/setup.c
>> @@ -787,6 +787,8 @@ void __init start_xen(unsigned long boot_phys_offset,
>>
>>      processor_id();
>>
>> +    numa_add_cpu(0);
>> +
>>      smp_init_cpus();
>>      cpus = smp_get_max_cpus();
>>      printk(XENLOG_INFO "SMP: Allowing %u CPUs\n", cpus);
>> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
>> index 32e8722..fcf9afc 100644
>> --- a/xen/arch/arm/smpboot.c
>> +++ b/xen/arch/arm/smpboot.c
>> @@ -29,6 +29,7 @@
>>  #include <xen/timer.h>
>>  #include <xen/irq.h>
>>  #include <xen/console.h>
>> +#include <xen/numa.h>
>
>
> Please use the alphabetical order.
>
>>  #include <asm/cpuerrata.h>
>>  #include <asm/gic.h>
>>  #include <asm/psci.h>
>> @@ -106,6 +107,7 @@ static void __init dt_smp_init_cpus(void)
>>          [0 ... NR_CPUS - 1] = MPIDR_INVALID
>>      };
>>      bool_t bootcpu_valid = 0;
>> +    nodeid_t *cpu_to_nodemap;
>>      int rc;
>>
>>      mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
>> @@ -117,11 +119,18 @@ static void __init dt_smp_init_cpus(void)
>>          return;
>>      }
>>
>> +    cpu_to_nodemap = xzalloc_array(nodeid_t, NR_CPUS);
>
>
> Why do you need to allocate cpu_to_nodemap? Would not it be easier to put it
> on the stack as we do for other variable?

This array holds nodemap indexed by cpuid once for all the cpus.
Later while setting the logical cpu id mapping, the node mapping is set
by calling numa_set_cpu_node().

>
>> +    if ( !cpu_to_nodemap )
>> +    {
>> +        printk(XENLOG_WARNING "Failed to allocate memory for
>> cpu_to_nodemap\n");
>> +        return;
>> +    }
>> +
>>      dt_for_each_child_node( cpus, cpu )
>>      {
>>          const __be32 *prop;
>>          u64 addr;
>> -        u32 reg_len;
>> +        uint32_t reg_len, nid;
>>          register_t hwid;
>>
>>          if ( !dt_device_type_is_equal(cpu, "cpu") )
>> @@ -146,6 +155,15 @@ static void __init dt_smp_init_cpus(void)
>>              continue;
>>          }
>>
>> +        if ( !dt_property_read_u32(cpu, "numa-node-id", &nid) )
>> +        {
>> +            printk(XENLOG_WARNING "cpu node `%s`: numa-node-id not
>> found\n",
>> +                   dt_node_full_name(cpu));
>
>
> numa-node-id is not mandatory. So you would print a warning on all non-NUMA
> platform. This not what we want.

ok. I will drop this warning.
>
>> +            nid = 0;
>> +        }
>> +
>> +        cpu_to_nodemap[cpuidx] = nid;
>> +
>>          addr = dt_read_number(prop, dt_n_addr_cells(cpu));
>>
>>          hwid = addr;
>> @@ -224,6 +242,7 @@ static void __init dt_smp_init_cpus(void)
>>      {
>>          printk(XENLOG_WARNING "DT missing boot CPU MPIDR[23:0]\n"
>>                 "Using only 1 CPU\n");
>> +        xfree(cpu_to_nodemap);
>>          return;
>>      }
>>
>> @@ -233,7 +252,10 @@ static void __init dt_smp_init_cpus(void)
>>              continue;
>>          cpumask_set_cpu(i, &cpu_possible_map);
>>          cpu_logical_map(i) = tmp_map[i];
>> +        numa_set_cpu_node(i, cpu_to_nodemap[i]);
>>      }
>> +
>> +    xfree(cpu_to_nodemap);
>>  }
>>
>>  void __init smp_init_cpus(void)
>> @@ -313,6 +335,7 @@ void start_secondary(unsigned long boot_phys_offset,
>>       */
>>      smp_wmb();
>>
>> +    numa_add_cpu(cpuid);
>
>
> Newline here please.
>
>
>>      /* Now report this CPU is up */
>>      cpumask_set_cpu(cpuid, &cpu_online_map);
>>
>> diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h
>> index d1dc83a..0d3146c 100644
>> --- a/xen/include/asm-arm/numa.h
>> +++ b/xen/include/asm-arm/numa.h
>> @@ -10,12 +10,19 @@ void init_dt_numa_distance(void);
>>  #ifdef CONFIG_NUMA
>>  void numa_init(void);
>>  int dt_numa_init(void);
>> +void numa_set_cpu_node(int cpu, unsigned int nid);
>> +
>>  #else
>>  static inline void numa_init(void)
>>  {
>>      return;
>>  }
>>
>> +static inline void numa_set_cpu_node(int cpu, unsigned int nid)
>> +{
>> +    return;
>> +}
>> +
>>  /* Fake one node for now. See also node_online_map. */
>>  #define cpu_to_node(cpu) 0
>>  #define node_to_cpumask(node)   (cpu_online_map)
>> diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h
>> index ca0a2a6..fc4747f 100644
>> --- a/xen/include/asm-x86/numa.h
>> +++ b/xen/include/asm-x86/numa.h
>> @@ -15,7 +15,6 @@ extern nodeid_t acpi_setup_node(unsigned int pxm);
>>  extern void srat_detect_node(int cpu);
>>
>>  extern nodeid_t apicid_to_node[];
>> -extern void init_cpu_to_node(void);
>>
>>  void srat_parse_regions(paddr_t addr);
>>  unsigned int arch_get_dma_bitsize(void);
>> diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
>> index 10ef4c4..8a306e7 100644
>> --- a/xen/include/xen/numa.h
>> +++ b/xen/include/xen/numa.h
>> @@ -30,6 +30,7 @@ extern s8 acpi_numa;
>>  void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
>>  int srat_disabled(void);
>>  int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node);
>> +void init_cpu_to_node(void);
>
>
> You never used this function in common code. So why did you move it in the
> common headers?

Same was defined for x86 as well. So I have moved to common header file.

>
>>
>>  #ifdef CONFIG_NUMA
>>  #define cpu_to_node(cpu)         (cpu_to_node[cpu])
>>
>
> Cheers,
>
> --
> Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-07-25  6:47 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 11:41 [RFC PATCH v3 00/24] ARM: Add Xen NUMA support vijay.kilari
2017-07-18 11:41 ` [RFC PATCH v3 01/24] NUMA: Make number of NUMA nodes configurable vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-18 17:52     ` Julien Grall
2017-07-19  8:17       ` Wei Liu
2017-07-19 15:48         ` Julien Grall
2017-07-28 10:11     ` Jan Beulich
2017-07-18 17:55   ` Julien Grall
2017-07-19  7:00     ` Vijay Kilari
2017-07-19 15:55       ` Julien Grall
2017-07-20  7:30         ` Vijay Kilari
2017-07-20 10:57           ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 02/24] x86: NUMA: Clean up: Fix coding styles and drop unused code vijay.kilari
2017-07-19 16:23   ` Julien Grall
2017-07-19 16:27     ` Wei Liu
2017-07-19 16:34       ` Julien Grall
2017-07-20  7:00     ` Vijay Kilari
2017-07-20 11:00       ` Julien Grall
2017-07-20 12:05         ` Vijay Kilari
2017-07-20 12:09           ` Julien Grall
2017-07-20 12:29             ` Vijay Kilari
2017-07-20 12:33               ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 03/24] x86: NUMA: Fix datatypes and attributes vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-18 11:41 ` [RFC PATCH v3 04/24] x86: NUMA: Rename and sanitize memnode shift code vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-19 17:12   ` Julien Grall
2017-07-20  6:56     ` Vijay Kilari
2017-07-18 11:41 ` [RFC PATCH v3 05/24] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-19  6:40     ` Vijay Kilari
2017-07-19 17:18       ` Julien Grall
2017-07-20  7:41         ` Vijay Kilari
2017-07-20 11:03           ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 06/24] x86: NUMA: Rename some generic functions vijay.kilari
2017-07-19 17:23   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 07/24] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA vijay.kilari
2017-07-18 18:06   ` Julien Grall
2017-07-20  9:31     ` Vijay Kilari
2017-07-20 11:10       ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 08/24] NUMA: x86: Move numa code and make it generic vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-18 18:16     ` Julien Grall
2017-07-19  6:47       ` Vijay Kilari
2017-07-19 17:41   ` Julien Grall
2017-07-20  8:55     ` Vijay Kilari
2017-07-20 11:14       ` Julien Grall
2017-07-24 20:28     ` Stefano Stabellini
2017-07-18 11:41 ` [RFC PATCH v3 09/24] NUMA: x86: Move common code from srat.c vijay.kilari
2017-07-20 11:17   ` Julien Grall
2017-07-20 11:43     ` Vijay Kilari
2017-07-24 20:35     ` Stefano Stabellini
2017-07-18 11:41 ` [RFC PATCH v3 10/24] NUMA: Allow numa initialization with DT vijay.kilari
2017-07-19 17:58   ` Julien Grall
2017-07-20 10:28     ` Vijay Kilari
2017-07-20 11:20       ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 11/24] ARM: fdt: Export and introduce new fdt functions vijay.kilari
2017-07-18 15:29   ` Wei Liu
2017-07-18 16:29     ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 12/24] ARM: NUMA: DT: Parse CPU NUMA information vijay.kilari
2017-07-19 18:26   ` Julien Grall
2017-07-20  9:20     ` Vijay Kilari
2017-07-18 11:41 ` [RFC PATCH v3 13/24] ARM: NUMA: DT: Parse memory " vijay.kilari
2017-07-19 18:39   ` Julien Grall
2017-07-20 10:37     ` Vijay Kilari
2017-07-20 11:24       ` Julien Grall
2017-07-20 11:26     ` Julien Grall
2017-07-21 11:10       ` Vijay Kilari
2017-07-21 12:35         ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 14/24] ARM: NUMA: DT: Parse NUMA distance information vijay.kilari
2017-07-20 13:02   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 15/24] ARM: NUMA: DT: Add CPU NUMA support vijay.kilari
2017-07-24 11:24   ` Julien Grall
2017-07-25  6:47     ` Vijay Kilari [this message]
2017-07-25 18:38       ` Julien Grall
2017-07-25 18:48         ` Stefano Stabellini
2017-07-25 18:51           ` Julien Grall
2017-07-25 19:06             ` Stefano Stabellini
2017-07-26 17:18               ` Julien Grall
2017-07-26 17:21                 ` Stefano Stabellini
2017-07-18 11:41 ` [RFC PATCH v3 16/24] ARM: NUMA: Add memory " vijay.kilari
2017-07-24 12:43   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 17/24] ARM: NUMA: DT: Do not expose numa info to DOM0 vijay.kilari
2017-07-24 20:48   ` Stefano Stabellini
2017-07-26 17:22   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 18/24] ACPI: Refactor acpi SRAT and SLIT table handling code vijay.kilari
2017-07-18 15:36   ` Wei Liu
2017-07-19  6:33     ` Vijay Kilari
2017-07-18 11:41 ` [RFC PATCH v3 19/24] ARM: NUMA: Extract MPIDR from MADT table vijay.kilari
2017-07-24 22:17   ` Stefano Stabellini
2017-07-26 18:12   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 20/24] ACPI: Move arch specific SRAT parsing vijay.kilari
2017-07-24 21:15   ` Stefano Stabellini
2017-07-18 11:41 ` [RFC PATCH v3 21/24] ARM: NUMA: ACPI: Extract proximity from SRAT table vijay.kilari
2017-07-24 22:17   ` Stefano Stabellini
2017-07-26 18:18   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 22/24] ARM: NUMA: Initialize ACPI NUMA vijay.kilari
2017-07-24 22:11   ` Stefano Stabellini
2017-07-26 18:23   ` Julien Grall
2017-07-18 11:41 ` [RFC PATCH v3 23/24] NUMA: Move CONFIG_NUMA to common Kconfig vijay.kilari
2017-07-18 16:25   ` Julien Grall
2017-07-18 18:00     ` Julien Grall
2017-07-28 10:08     ` Jan Beulich
2017-07-18 11:41 ` [RFC PATCH v3 24/24] NUMA: Enable ACPI_NUMA config vijay.kilari
2017-07-18 16:18 ` [RFC PATCH v3 00/24] ARM: Add Xen NUMA support Julien Grall
2017-07-19  6:31   ` Vijay Kilari
2017-07-19  7:18     ` Julien Grall
     [not found]       ` <CALicx6svuo3JXik=8bYuciFzWDu6qmwVi1VXdBgjLp_f_YUhqQ@mail.gmail.com>
2017-10-06 17:09         ` vkilari
2017-10-06 17:30           ` Julien Grall

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='CALicx6tp7zU2NSd3USgcxixBv3HYO8QqGVT+=xQhkq66AVyx7Q@mail.gmail.com' \
    --to=vijay.kilari@gmail.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Vijaya.Kumar@cavium.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=kevin.tian@intel.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 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.