All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: vijay.kilari@gmail.com, 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, jbeulich@suse.com,
	Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Subject: Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Date: Thu, 20 Apr 2017 16:59:48 +0100	[thread overview]
Message-ID: <d8839ead-31e6-dd20-70d5-0386fc8fa228@arm.com> (raw)
In-Reply-To: <1490716413-19796-5-git-send-email-vijay.kilari@gmail.com>

Hi Vijay,

On 28/03/17 16:53, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>
> Add accessor functions for acpi_numa and numa_off static
> variables. Init value of acpi_numa is set 1 instead of 0.

Please explain why you change the acpi_numa value from 0 to 1.

Also, I am not sure to understand the benefits of those helpers. Why do 
you need them? Why not using the global variable directly, this will 
avoid to call a function just for returning a value...

> Also return value of srat_disabled is changed to bool.
>
> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> ---
>  xen/arch/x86/numa.c        | 43 +++++++++++++++++++++++++++++++------------
>  xen/arch/x86/setup.c       |  2 +-
>  xen/arch/x86/srat.c        | 12 ++++++------
>  xen/include/asm-x86/acpi.h |  1 -
>  xen/include/asm-x86/numa.h |  5 +----
>  xen/include/xen/numa.h     |  3 +++
>  6 files changed, 42 insertions(+), 24 deletions(-)
>
> diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
> index 964fc5a..6b794a7 100644
> --- a/xen/arch/x86/numa.c
> +++ b/xen/arch/x86/numa.c
> @@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];
>
>  nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
>
> -bool numa_off = 0;
> -s8 acpi_numa = 0;
> +static bool numa_off = 0;
> +static bool acpi_numa = 1;

Please don't mix 0/1 and bool. Instead use false/true.

>
> -int srat_disabled(void)
> +bool is_numa_off(void)
>  {
> -    return numa_off || acpi_numa < 0;
> +    return numa_off;
> +}
> +
> +bool get_acpi_numa(void)
> +{
> +    return acpi_numa;
> +}
> +
> +void set_acpi_numa(bool_t val)
> +{
> +    acpi_numa = val;
> +}
> +
> +bool srat_disabled(void)
> +{
> +    return numa_off || acpi_numa == 0;
>  }
>
>  /*
> @@ -202,13 +217,17 @@ void __init numa_init_array(void)
>
>  #ifdef CONFIG_NUMA_EMU
>  static int __initdata numa_fake = 0;
> +static int get_numa_fake(void)
> +{
> +    return numa_fake;
> +}
>
>  /* Numa emulation */
>  static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn)
>  {
>      int i;
>      struct node nodes[MAX_NUMNODES];
> -    uint64_t sz = ((end_pfn - start_pfn) << PAGE_SHIFT) / numa_fake;
> +    uint64_t sz = ((end_pfn - start_pfn) << PAGE_SHIFT) / get_numa_fake();
>
>      /* Kludge needed for the hash function */
>      if ( hweight64(sz) > 1 )
> @@ -223,10 +242,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn)
>      }
>
>      memset(&nodes,0,sizeof(nodes));
> -    for ( i = 0; i < numa_fake; i++ )
> +    for ( i = 0; i < get_numa_fake(); i++ )
>      {
>          nodes[i].start = (start_pfn << PAGE_SHIFT) + i * sz;
> -        if ( i == numa_fake - 1 )
> +        if ( i == get_numa_fake() - 1 )
>              sz = (end_pfn << PAGE_SHIFT) - nodes[i].start;
>          nodes[i].end = nodes[i].start + sz;
>          printk(KERN_INFO
> @@ -235,7 +254,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);
>      }
> -    if ( compute_memnode_shift(nodes, numa_fake, NULL, &memnode_shift) )
> +    if ( compute_memnode_shift(nodes, get_numa_fake(), NULL, &memnode_shift) )
>      {
>          memnode_shift = 0;
>          printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\n");
> @@ -254,18 +273,18 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
>      int i;
>
>  #ifdef CONFIG_NUMA_EMU
> -    if ( numa_fake && !numa_emulation(start_pfn, end_pfn) )
> +    if ( get_numa_fake() && !numa_emulation(start_pfn, end_pfn) )
>          return;
>  #endif
>
>  #ifdef CONFIG_ACPI_NUMA
> -    if ( !numa_off && !acpi_scan_nodes((uint64_t)start_pfn << PAGE_SHIFT,
> +    if ( !is_numa_off() && !acpi_scan_nodes((uint64_t)start_pfn << PAGE_SHIFT,
>           (uint64_t)end_pfn << PAGE_SHIFT) )
>          return;
>  #endif
>
>      printk(KERN_INFO "%s\n",
> -           numa_off ? "NUMA turned off" : "No NUMA configuration found");
> +           is_numa_off() ? "NUMA turned off" : "No NUMA configuration found");
>
>      printk(KERN_INFO "Faking a node at %016"PRIx64"-%016"PRIx64"\n",
>             (uint64_t)start_pfn << PAGE_SHIFT,
> @@ -312,7 +331,7 @@ static int __init numa_setup(char *opt)
>      if ( !strncmp(opt,"noacpi",6) )
>      {
>          numa_off = 0;
> -        acpi_numa = -1;
> +        acpi_numa = 0;
>      }
>  #endif
>
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 1cd290e..4410e53 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -241,7 +241,7 @@ void srat_detect_node(int cpu)
>      node_set_online(node);
>      numa_set_node(cpu, node);
>
> -    if ( opt_cpu_info && acpi_numa > 0 )
> +    if ( opt_cpu_info && get_acpi_numa() )
>          printk("CPU %d APIC %d -> Node %d\n", cpu, apicid, node);
>  }
>
> diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
> index 2d0c047..ccacbcd 100644
> --- a/xen/arch/x86/srat.c
> +++ b/xen/arch/x86/srat.c
> @@ -153,7 +153,7 @@ static void __init bad_srat(void)
>  {
>  	int i;
>  	printk(KERN_ERR "SRAT: SRAT not used.\n");
> -	acpi_numa = -1;
> +	set_acpi_numa(0);
>  	for (i = 0; i < MAX_LOCAL_APIC; i++)
>  		apicid_to_node[i] = NUMA_NO_NODE;
>  	for (i = 0; i < ARRAY_SIZE(pxm2node); i++)
> @@ -232,7 +232,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *pa)
>
>  	apicid_to_node[pa->apic_id] = node;
>  	node_set(node, processor_nodes_parsed);
> -	acpi_numa = 1;
> +	set_acpi_numa(1);
>  	printk(KERN_INFO "SRAT: PXM %u -> APIC %08x -> Node %u\n",
>  	       pxm, pa->apic_id, node);
>  }
> @@ -265,7 +265,7 @@ acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa)
>  	}
>  	apicid_to_node[pa->apic_id] = node;
>  	node_set(node, processor_nodes_parsed);
> -	acpi_numa = 1;
> +	set_acpi_numa(1);
>  	printk(KERN_INFO "SRAT: PXM %u -> APIC %02x -> Node %u\n",
>  	       pxm, pa->apic_id, node);
>  }
> @@ -418,7 +418,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header,
>  	    (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE))
>  		return 0;
>
> -	if (numa_off)
> +	if (is_numa_off())
>  		printk(KERN_INFO "SRAT: %013"PRIx64"-%013"PRIx64"\n",
>  		       ma->base_address, ma->base_address + ma->length - 1);
>
> @@ -433,7 +433,7 @@ void __init srat_parse_regions(uint64_t addr)
>  	uint64_t mask;
>  	unsigned int i;
>
> -	if (acpi_disabled || acpi_numa < 0 ||
> +	if (acpi_disabled || (get_acpi_numa() == 0) ||
>  	    acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat))
>  		return;
>
> @@ -462,7 +462,7 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)
>  	for (i = 0; i < MAX_NUMNODES; i++)
>  		cutoff_node(i, start, end);
>
> -	if (acpi_numa <= 0)
> +	if (get_acpi_numa() == 0)
>  		return -1;
>
>  	if (!nodes_cover_memory()) {
> diff --git a/xen/include/asm-x86/acpi.h b/xen/include/asm-x86/acpi.h
> index a766688..9298d42 100644
> --- a/xen/include/asm-x86/acpi.h
> +++ b/xen/include/asm-x86/acpi.h
> @@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);
>
>  #define ARCH_HAS_POWER_INIT	1
>
> -extern s8 acpi_numa;
>  extern int acpi_scan_nodes(u64 start, u64 end);
>  #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
>
> diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h
> index bb22bff..ae5768b 100644
> --- a/xen/include/asm-x86/numa.h
> +++ b/xen/include/asm-x86/numa.h
> @@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);
>
>  extern void numa_add_cpu(int cpu);
>  extern void numa_init_array(void);
> -extern bool_t numa_off;
> -
> -
> -extern int srat_disabled(void);
> +extern bool srat_disabled(void);
>  extern void numa_set_node(int cpu, nodeid_t node);
>  extern nodeid_t setup_node(unsigned int pxm);
>  extern void srat_detect_node(int cpu);
> diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
> index 7aef1a8..7f6d090 100644
> --- a/xen/include/xen/numa.h
> +++ b/xen/include/xen/numa.h
> @@ -18,4 +18,7 @@
>    (((d)->vcpu != NULL && (d)->vcpu[0] != NULL) \
>     ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE)
>
> +bool is_numa_off(void);
> +bool get_acpi_numa(void);
> +void set_acpi_numa(bool val);

I am not sure to understand why you add those helpers directly here in 
xen/numa.h. IHMO, This should belong to the moving code patches.

>  #endif /* _XEN_NUMA_H */
>

-- 
Julien Grall

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

  reply	other threads:[~2017-04-20 15:59 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 ` [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions vijay.kilari
2017-06-30 14:05   ` 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 [this message]
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=d8839ead-31e6-dd20-70d5-0386fc8fa228@arm.com \
    --to=julien.grall@arm.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=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=vijay.kilari@gmail.com \
    --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.