ia64/xen-unstable

changeset 11998:3db344ea8070

[XEN] Clean up NUMA stuff and disable by default ('numa=on' enables it).
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Oct 25 15:17:40 2006 +0100 (2006-10-25)
parents 6788aedb820c
children 21905d2497d6
files xen/arch/x86/numa.c xen/arch/x86/setup.c xen/arch/x86/smpboot.c xen/arch/x86/srat.c xen/common/page_alloc.c xen/include/asm-x86/acpi.h xen/include/asm-x86/numa.h xen/include/asm-x86/numnodes.h xen/include/asm-x86/topology.h xen/include/xen/nodemask.h xen/include/xen/numa.h xen/include/xen/topology.h
line diff
     1.1 --- a/xen/arch/x86/numa.c	Wed Oct 25 15:01:51 2006 +0100
     1.2 +++ b/xen/arch/x86/numa.c	Wed Oct 25 15:17:40 2006 +0100
     1.3 @@ -12,9 +12,11 @@
     1.4  #include <xen/numa.h>
     1.5  #include <xen/keyhandler.h>
     1.6  #include <xen/time.h>
     1.7 +#include <xen/smp.h>
     1.8 +#include <asm/acpi.h>
     1.9  
    1.10 -#include <asm/numa.h>
    1.11 -#include <asm/acpi.h>
    1.12 +static int numa_setup(char *s);
    1.13 +custom_param("numa", numa_setup);
    1.14  
    1.15  #ifndef Dprintk
    1.16  #define Dprintk(x...)
    1.17 @@ -28,7 +30,7 @@ struct node_data node_data[MAX_NUMNODES]
    1.18  int memnode_shift;
    1.19  u8  memnodemap[NODEMAPSIZE];
    1.20  
    1.21 -unsigned int cpu_to_node[NR_CPUS] __read_mostly = {
    1.22 +unsigned char cpu_to_node[NR_CPUS] __read_mostly = {
    1.23  	[0 ... NR_CPUS-1] = NUMA_NO_NODE
    1.24  };
    1.25  unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
    1.26 @@ -38,7 +40,8 @@ cpumask_t node_to_cpumask[MAX_NUMNODES] 
    1.27  
    1.28  nodemask_t node_online_map = { { [0] = 1UL } };
    1.29  
    1.30 -int numa_off __initdata;
    1.31 +/* Default NUMA to off for now. acpi=on required to enable it. */
    1.32 +int numa_off __initdata = 1;
    1.33  
    1.34  int acpi_numa __initdata;
    1.35  
    1.36 @@ -70,7 +73,7 @@ populate_memnodemap(const struct node *n
    1.37  			if (memnodemap[addr >> shift] != 0xff)
    1.38  				return -1;
    1.39  			memnodemap[addr >> shift] = i;
    1.40 -                       addr += (1UL << shift);
    1.41 +			addr += (1UL << shift);
    1.42  		} while (addr < end);
    1.43  		res = 1;
    1.44  	} 
    1.45 @@ -133,8 +136,7 @@ void __init numa_init_array(void)
    1.46  }
    1.47  
    1.48  #ifdef CONFIG_NUMA_EMU
    1.49 -/* default to faking a single node as fallback for non-NUMA hardware */
    1.50 -int numa_fake __initdata = 1;
    1.51 +static int numa_fake __initdata = 0;
    1.52  
    1.53  /* Numa emulation */
    1.54  static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
    1.55 @@ -160,9 +162,9 @@ static int numa_emulation(unsigned long 
    1.56   			sz = (end_pfn<<PAGE_SHIFT) - nodes[i].start;
    1.57   		nodes[i].end = nodes[i].start + sz;
    1.58   		printk(KERN_INFO "Faking node %d at %"PRIx64"-%"PRIx64" (%"PRIu64"MB)\n",
    1.59 - 		       i,
    1.60 - 		       nodes[i].start, nodes[i].end,
    1.61 - 		       (nodes[i].end - nodes[i].start) >> 20);
    1.62 +		       i,
    1.63 +		       nodes[i].start, nodes[i].end,
    1.64 +		       (nodes[i].end - nodes[i].start) >> 20);
    1.65  		node_set_online(i);
    1.66   	}
    1.67   	memnode_shift = compute_hash_shift(nodes, numa_fake);
    1.68 @@ -182,16 +184,15 @@ void __init numa_initmem_init(unsigned l
    1.69  { 
    1.70  	int i;
    1.71  
    1.72 +#ifdef CONFIG_NUMA_EMU
    1.73 +	if (numa_fake && !numa_emulation(start_pfn, end_pfn))
    1.74 +		return;
    1.75 +#endif
    1.76 +
    1.77  #ifdef CONFIG_ACPI_NUMA
    1.78  	if (!numa_off && !acpi_scan_nodes(start_pfn << PAGE_SHIFT,
    1.79  					  end_pfn << PAGE_SHIFT))
    1.80 - 		return;
    1.81 -#endif
    1.82 -
    1.83 -#ifdef CONFIG_NUMA_EMU
    1.84 -   /* fake a numa node for non-numa hardware */
    1.85 -	if (numa_fake && !numa_emulation(start_pfn, end_pfn))
    1.86 - 		return;
    1.87 +		return;
    1.88  #endif
    1.89  
    1.90  	printk(KERN_INFO "%s\n",
    1.91 @@ -200,7 +201,7 @@ void __init numa_initmem_init(unsigned l
    1.92  	printk(KERN_INFO "Faking a node at %016lx-%016lx\n", 
    1.93  	       start_pfn << PAGE_SHIFT,
    1.94  	       end_pfn << PAGE_SHIFT); 
    1.95 -		/* setup dummy node covering all memory */ 
    1.96 +	/* setup dummy node covering all memory */ 
    1.97  	memnode_shift = 63; 
    1.98  	memnodemap[0] = 0;
    1.99  	nodes_clear(node_online_map);
   1.100 @@ -222,20 +223,25 @@ void __cpuinit numa_set_node(int cpu, in
   1.101  }
   1.102  
   1.103  /* [numa=off] */
   1.104 -__init int numa_setup(char *opt) 
   1.105 +static __init int numa_setup(char *opt) 
   1.106  { 
   1.107  	if (!strncmp(opt,"off",3))
   1.108  		numa_off = 1;
   1.109 +	if (!strncmp(opt,"on",2))
   1.110 +		numa_off = 0;
   1.111  #ifdef CONFIG_NUMA_EMU
   1.112  	if(!strncmp(opt, "fake=", 5)) {
   1.113 +		numa_off = 0;
   1.114  		numa_fake = simple_strtoul(opt+5,NULL,0); ;
   1.115  		if (numa_fake >= MAX_NUMNODES)
   1.116  			numa_fake = MAX_NUMNODES;
   1.117  	}
   1.118  #endif
   1.119  #ifdef CONFIG_ACPI_NUMA
   1.120 - 	if (!strncmp(opt,"noacpi",6))
   1.121 - 		acpi_numa = -1;
   1.122 +	if (!strncmp(opt,"noacpi",6)) {
   1.123 +		numa_off = 0;
   1.124 +		acpi_numa = -1;
   1.125 +	}
   1.126  #endif
   1.127  	return 1;
   1.128  } 
     2.1 --- a/xen/arch/x86/setup.c	Wed Oct 25 15:01:51 2006 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Wed Oct 25 15:17:40 2006 +0100
     2.3 @@ -26,7 +26,6 @@
     2.4  #include <asm/desc.h>
     2.5  #include <asm/shadow.h>
     2.6  #include <asm/e820.h>
     2.7 -#include <asm/numa.h>
     2.8  #include <acm/acm_hooks.h>
     2.9  
    2.10  extern void dmi_scan_machine(void);
    2.11 @@ -63,9 +62,6 @@ boolean_param("watchdog", opt_watchdog);
    2.12  static void parse_acpi_param(char *s);
    2.13  custom_param("acpi", parse_acpi_param);
    2.14  
    2.15 -extern int numa_setup(char *s);
    2.16 -custom_param("numa", numa_setup);
    2.17 -
    2.18  /* **** Linux config option: propagated to domain0. */
    2.19  /* acpi_skip_timer_override: Skip IRQ0 overrides. */
    2.20  extern int acpi_skip_timer_override;
    2.21 @@ -265,16 +261,16 @@ static void __init init_idle_domain(void
    2.22  
    2.23  static void srat_detect_node(int cpu)
    2.24  {
    2.25 -   unsigned node;
    2.26 -   u8 apicid = x86_cpu_to_apicid[cpu];
    2.27 +    unsigned node;
    2.28 +    u8 apicid = x86_cpu_to_apicid[cpu];
    2.29  
    2.30 -   node = apicid_to_node[apicid];
    2.31 -   if (node == NUMA_NO_NODE)
    2.32 -      node = 0;
    2.33 -   numa_set_node(cpu, node);
    2.34 +    node = apicid_to_node[apicid];
    2.35 +    if ( node == NUMA_NO_NODE )
    2.36 +        node = 0;
    2.37 +    numa_set_node(cpu, node);
    2.38  
    2.39 -   if (acpi_numa > 0)
    2.40 -      printk(KERN_INFO "CPU %d APIC %d -> Node %d\n", cpu, apicid, node);
    2.41 +    if ( acpi_numa > 0 )
    2.42 +        printk(KERN_INFO "CPU %d APIC %d -> Node %d\n", cpu, apicid, node);
    2.43  }
    2.44  
    2.45  void __init __start_xen(multiboot_info_t *mbi)
    2.46 @@ -617,9 +613,9 @@ void __init __start_xen(multiboot_info_t
    2.47          if ( !cpu_online(i) )
    2.48              __cpu_up(i);
    2.49  
    2.50 -		/* setup cpu_to_node[] */
    2.51 +        /* Set up cpu_to_node[]. */
    2.52          srat_detect_node(i);
    2.53 -		/* setup node_to_cpumask based on cpu_to_node[] */
    2.54 +        /* Set up node_to_cpumask based on cpu_to_node[]. */
    2.55          numa_add_cpu(i);        
    2.56      }
    2.57  
     3.1 --- a/xen/arch/x86/smpboot.c	Wed Oct 25 15:01:51 2006 +0100
     3.2 +++ b/xen/arch/x86/smpboot.c	Wed Oct 25 15:17:40 2006 +0100
     3.3 @@ -44,7 +44,6 @@
     3.4  #include <xen/softirq.h>
     3.5  #include <xen/serial.h>
     3.6  #include <xen/numa.h>
     3.7 -#include <asm/numa.h>
     3.8  #include <asm/current.h>
     3.9  #include <asm/mc146818rtc.h>
    3.10  #include <asm/desc.h>
     4.1 --- a/xen/arch/x86/srat.c	Wed Oct 25 15:01:51 2006 +0100
     4.2 +++ b/xen/arch/x86/srat.c	Wed Oct 25 15:17:40 2006 +0100
     4.3 @@ -11,22 +11,12 @@
     4.4   * Adapted for Xen: Ryan Harper <ryanh@us.ibm.com>
     4.5   */
     4.6  
     4.7 -#if 0
     4.8 -#include <linux/kernel.h>
     4.9 -#include <linux/module.h>
    4.10 -#include <asm/proto.h>
    4.11 -#include <xen/bitmap.h>
    4.12 -#include <xen/numa.h>
    4.13 -#include <xen/topology.h>
    4.14 -#include <asm/e820.h>
    4.15 -#endif
    4.16  #include <xen/init.h>
    4.17  #include <xen/mm.h>
    4.18  #include <xen/inttypes.h>
    4.19  #include <xen/nodemask.h>
    4.20  #include <xen/acpi.h>
    4.21 -
    4.22 -#include <asm/numa.h>
    4.23 +#include <xen/numa.h>
    4.24  #include <asm/page.h>
    4.25  
    4.26  static struct acpi_table_slit *acpi_slit;
     5.1 --- a/xen/common/page_alloc.c	Wed Oct 25 15:01:51 2006 +0100
     5.2 +++ b/xen/common/page_alloc.c	Wed Oct 25 15:17:40 2006 +0100
     5.3 @@ -34,9 +34,9 @@
     5.4  #include <xen/domain_page.h>
     5.5  #include <xen/keyhandler.h>
     5.6  #include <xen/perfc.h>
     5.7 +#include <xen/numa.h>
     5.8 +#include <xen/nodemask.h>
     5.9  #include <asm/page.h>
    5.10 -#include <asm/numa.h>
    5.11 -#include <asm/topology.h>
    5.12  
    5.13  /*
    5.14   * Comma-separated list of hexadecimal page numbers containing bad bytes.
    5.15 @@ -702,10 +702,8 @@ inline struct page_info *alloc_domheap_p
    5.16      struct domain *d, unsigned int order, unsigned int flags)
    5.17  {
    5.18      return __alloc_domheap_pages(d, smp_processor_id(), order, flags);
    5.19 -
    5.20  }
    5.21  
    5.22 -
    5.23  void free_domheap_pages(struct page_info *pg, unsigned int order)
    5.24  {
    5.25      int            i, drop_dom_ref;
     6.1 --- a/xen/include/asm-x86/acpi.h	Wed Oct 25 15:01:51 2006 +0100
     6.2 +++ b/xen/include/asm-x86/acpi.h	Wed Oct 25 15:17:40 2006 +0100
     6.3 @@ -159,6 +159,7 @@ static inline void acpi_noirq_set(void) 
     6.4  static inline int acpi_irq_balance_set(char *str) { return 0; }
     6.5  extern int acpi_scan_nodes(u64 start, u64 end);
     6.6  extern int acpi_numa;
     6.7 +#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
     6.8  
     6.9  #ifdef CONFIG_ACPI_SLEEP
    6.10  
     7.1 --- a/xen/include/asm-x86/numa.h	Wed Oct 25 15:01:51 2006 +0100
     7.2 +++ b/xen/include/asm-x86/numa.h	Wed Oct 25 15:17:40 2006 +0100
     7.3 @@ -1,10 +1,17 @@
     7.4  #ifndef _ASM_X8664_NUMA_H 
     7.5  #define _ASM_X8664_NUMA_H 1
     7.6  
     7.7 -#include <xen/nodemask.h>
     7.8 -#include <xen/topology.h>
     7.9 -#include <asm/numnodes.h>
    7.10 -#include <asm/smp.h>
    7.11 +#include <xen/cpumask.h>
    7.12 +
    7.13 +#define NODES_SHIFT 6
    7.14 +
    7.15 +extern unsigned char cpu_to_node[];
    7.16 +extern cpumask_t     node_to_cpumask[];
    7.17 +
    7.18 +#define cpu_to_node(cpu)		(cpu_to_node[cpu])
    7.19 +#define parent_node(node)		(node)
    7.20 +#define node_to_first_cpu(node)  (__ffs(node_to_cpumask[node]))
    7.21 +#define node_to_cpumask(node)    (node_to_cpumask[node])
    7.22  
    7.23  struct node { 
    7.24  	u64 start,end; 
    7.25 @@ -37,6 +44,12 @@ static inline void clear_node_cpumask(in
    7.26  extern int memnode_shift; 
    7.27  extern u8  memnodemap[NODEMAPSIZE]; 
    7.28  
    7.29 +struct node_data {
    7.30 +    unsigned long node_start_pfn;
    7.31 +    unsigned long node_spanned_pages;
    7.32 +    unsigned int  node_id;
    7.33 +};
    7.34 +
    7.35  extern struct node_data node_data[];
    7.36  
    7.37  static inline __attribute__((pure)) int phys_to_nid(unsigned long addr) 
     8.1 --- a/xen/include/asm-x86/numnodes.h	Wed Oct 25 15:01:51 2006 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,26 +0,0 @@
     8.4 -#ifndef _ASM_MAX_NUMNODES_H
     8.5 -#define _ASM_MAX_NUMNODES_H
     8.6 -
     8.7 -#include <xen/config.h>
     8.8 -
     8.9 -#if defined(__i386__)
    8.10 -#ifdef CONFIG_X86_NUMAQ
    8.11 -
    8.12 -/* Max 16 Nodes */
    8.13 -#define NODES_SHIFT	4
    8.14 -
    8.15 -#elif defined(CONFIG_ACPI_SRAT)
    8.16 -
    8.17 -/* Max 8 Nodes */
    8.18 -#define NODES_SHIFT	3
    8.19 -
    8.20 -#endif /* CONFIG_X86_NUMAQ */
    8.21 -
    8.22 -
    8.23 -#endif /* __i386__ */
    8.24 -
    8.25 -#if defined(CONFIG_NUMA) && defined(__x86_64__)
    8.26 -#define NODES_SHIFT  6
    8.27 -#endif /* __x86_64__ */
    8.28 -
    8.29 -#endif /* _ASM_MAX_NUMNODES_H */
     9.1 --- a/xen/include/asm-x86/topology.h	Wed Oct 25 15:01:51 2006 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,40 +0,0 @@
     9.4 -/*
     9.5 - * Copyright (C) 2006, IBM Corp.
     9.6 - *
     9.7 - * All rights reserved.          
     9.8 - *
     9.9 - * This program is free software; you can redistribute it and/or modify
    9.10 - * it under the terms of the GNU General Public License as published by
    9.11 - * the Free Software Foundation; either version 2 of the License, or
    9.12 - * (at your option) any later version.
    9.13 - *
    9.14 - * This program is distributed in the hope that it will be useful, but
    9.15 - * WITHOUT ANY WARRANTY; without even the implied warranty of
    9.16 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
    9.17 - * NON INFRINGEMENT.  See the GNU General Public License for more
    9.18 - * details.
    9.19 - *
    9.20 - * You should have received a copy of the GNU General Public License
    9.21 - * along with this program; if not, write to the Free Software
    9.22 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    9.23 - *
    9.24 - * Ryan Harper <ryanh@us.ibm.com>
    9.25 - */
    9.26 -
    9.27 -#ifndef _ASM_X86_TOPOLOGY_H
    9.28 -#define _ASM_X86_TOPOLOGY_H
    9.29 -
    9.30 -#include <xen/config.h>
    9.31 -#include <xen/bitops.h>
    9.32 -
    9.33 -extern cpumask_t cpu_online_map;
    9.34 -
    9.35 -extern unsigned int cpu_to_node[];
    9.36 -extern cpumask_t     node_to_cpumask[];
    9.37 -
    9.38 -#define cpu_to_node(cpu)		(cpu_to_node[cpu])
    9.39 -#define parent_node(node)		(node)
    9.40 -#define node_to_first_cpu(node)  (__ffs(node_to_cpumask[node]))
    9.41 -#define node_to_cpumask(node)    (node_to_cpumask[node])
    9.42 -
    9.43 -#endif  /* _ASM_X86_TOPOLOGY_H */
    10.1 --- a/xen/include/xen/nodemask.h	Wed Oct 25 15:01:51 2006 +0100
    10.2 +++ b/xen/include/xen/nodemask.h	Wed Oct 25 15:17:40 2006 +0100
    10.3 @@ -72,10 +72,6 @@
    10.4   *    way we do the other calls.
    10.5   */
    10.6  
    10.7 -#if 0
    10.8 -#include <linux/threads.h>
    10.9 -#include <asm/bug.h>
   10.10 -#endif
   10.11  #include <xen/kernel.h>
   10.12  #include <xen/bitmap.h>
   10.13  #include <xen/numa.h>
    11.1 --- a/xen/include/xen/numa.h	Wed Oct 25 15:01:51 2006 +0100
    11.2 +++ b/xen/include/xen/numa.h	Wed Oct 25 15:17:40 2006 +0100
    11.3 @@ -2,34 +2,12 @@
    11.4  #define _XEN_NUMA_H
    11.5  
    11.6  #include <xen/config.h>
    11.7 -
    11.8 -#ifdef CONFIG_DISCONTIGMEM
    11.9 -#include <asm/numnodes.h>
   11.10 -#endif
   11.11 +#include <asm/numa.h>
   11.12  
   11.13  #ifndef NODES_SHIFT
   11.14  #define NODES_SHIFT     0
   11.15  #endif
   11.16  
   11.17  #define MAX_NUMNODES    (1 << NODES_SHIFT)
   11.18 -#define NUMA_NO_NODE    0xff
   11.19 -
   11.20 -#define MAX_PXM_DOMAINS    256   /* 1 byte and no promises about values */
   11.21 -#define PXM_BITMAP_LEN (MAX_PXM_DOMAINS / 8)
   11.22 -#define MAX_CHUNKS_PER_NODE   4
   11.23 -#define MAXCHUNKS    (MAX_CHUNKS_PER_NODE * MAX_NUMNODES)
   11.24 -
   11.25 -/* needed for drivers/acpi/numa.c */
   11.26 -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
   11.27 -
   11.28 -extern unsigned int cpu_to_node[];
   11.29 -#include <xen/cpumask.h>
   11.30 -extern cpumask_t node_to_cpumask[];
   11.31 -
   11.32 -typedef struct node_data {
   11.33 -    unsigned long node_start_pfn;
   11.34 -    unsigned long node_spanned_pages;
   11.35 -    unsigned int  node_id;
   11.36 -} node_data_t;
   11.37  
   11.38  #endif /* _XEN_NUMA_H */
    12.1 --- a/xen/include/xen/topology.h	Wed Oct 25 15:01:51 2006 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,27 +0,0 @@
    12.4 -/*
    12.5 - * Copyright (C) 2006, IBM Corp.
    12.6 - *
    12.7 - * All rights reserved.          
    12.8 - *
    12.9 - * This program is free software; you can redistribute it and/or modify
   12.10 - * it under the terms of the GNU General Public License as published by
   12.11 - * the Free Software Foundation; either version 2 of the License, or
   12.12 - * (at your option) any later version.
   12.13 - *
   12.14 - * This program is distributed in the hope that it will be useful, but
   12.15 - * WITHOUT ANY WARRANTY; without even the implied warranty of
   12.16 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
   12.17 - * NON INFRINGEMENT.  See the GNU General Public License for more
   12.18 - * details.
   12.19 - *
   12.20 - * You should have received a copy of the GNU General Public License
   12.21 - * along with this program; if not, write to the Free Software
   12.22 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   12.23 - *
   12.24 - */
   12.25 -#ifndef _XEN_TOPOLOGY_H
   12.26 -#define _XEN_TOPOLOGY_H
   12.27 -
   12.28 -#include <asm/topology.h>
   12.29 -
   12.30 -#endif /* _XEN_TOPOLOGY_H */