CONFIG_NUMA and DISCONTIG inconsistencies

Joel Schopp jschopp at austin.ibm.com
Tue Mar 22 04:58:18 EST 2005


A wise man once told me to send 1 patch per email.  It is good to see he 
ignores his own advice sometimes :)

> First of all, what are the machines that require
>         
>         CONFIG_DISCONTIGMEM=y
>         # CONFIG_NUMA is not set
> 
> That appears to be the ppc64 defconfig, and it doesn't make a lot of
> sense to me.  First of all, why do you need DISCONTIG without NUMA?
> Should that even be allowed?

Seems silly to me too.  Somebody want to set Dave and me straight?

First patch:
DEBUG_NUMA seems to clutter things up without adding any value.  This 
patch actually removes all of it despite being so small.  Paul or Anton, 
could you apply and forward on to -mm?
Acked-by: Joel Schopp <jschopp at austin.ibm.com>

> ---
> 
>  memhotplug-dave/arch/ppc64/mm/numa.c         |    6 ------
>  memhotplug-dave/include/asm-ppc64/mmzone.h   |   17 +----------------
>  memhotplug-dave/include/asm-ppc64/topology.h |   10 +---------
>  3 files changed, 2 insertions(+), 31 deletions(-)
> 
> diff -puN include/asm-ppc64/mmzone.h~ppc64-remove-numa-debug include/asm-ppc64/mmzone.h
> --- memhotplug/include/asm-ppc64/mmzone.h~ppc64-remove-numa-debug	2005-03-21 07:33:36.000000000 -0800
> +++ memhotplug-dave/include/asm-ppc64/mmzone.h	2005-03-21 07:34:12.000000000 -0800
> @@ -27,24 +27,9 @@ extern int nr_cpus_in_node[];
>  #define MEMORY_INCREMENT_SHIFT 24
>  #define MEMORY_INCREMENT (1UL << MEMORY_INCREMENT_SHIFT)
>  
> -/* NUMA debugging, will not work on a DLPAR machine */
> -#undef DEBUG_NUMA
> -
>  static inline int pa_to_nid(unsigned long pa)
>  {
> -	int nid;
> -
> -	nid = numa_memory_lookup_table[pa >> MEMORY_INCREMENT_SHIFT];
> -
> -#ifdef DEBUG_NUMA
> -	/* the physical address passed in is not in the map for the system */
> -	if (nid == -1) {
> -		printk("bad address: %lx\n", pa);
> -		BUG();
> -	}
> -#endif
> -
> -	return nid;
> +	return numa_memory_lookup_table[pa >> MEMORY_INCREMENT_SHIFT];
>  }
>  
>  #define pfn_to_nid(pfn)		pa_to_nid((pfn) << PAGE_SHIFT)
> diff -puN include/linux/mmzone.h~ppc64-remove-numa-debug include/linux/mmzone.h
> diff -puN include/asm-ppc64/page.h~ppc64-remove-numa-debug include/asm-ppc64/page.h
> diff -puN include/linux/mm.h~ppc64-remove-numa-debug include/linux/mm.h
> diff -puN arch/ppc64/mm/numa.c~ppc64-remove-numa-debug arch/ppc64/mm/numa.c
> --- memhotplug/arch/ppc64/mm/numa.c~ppc64-remove-numa-debug	2005-03-21 07:33:36.000000000 -0800
> +++ memhotplug-dave/arch/ppc64/mm/numa.c	2005-03-21 07:34:42.000000000 -0800
> @@ -26,12 +26,6 @@ static int numa_enabled = 1;
>  static int numa_debug;
>  #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
>  
> -#ifdef DEBUG_NUMA
> -#define ARRAY_INITIALISER -1
> -#else
> -#define ARRAY_INITIALISER 0
> -#endif
> -
>  int numa_cpu_lookup_table[NR_CPUS] = { [ 0 ... (NR_CPUS - 1)] =
>  	ARRAY_INITIALISER};
>  char *numa_memory_lookup_table;
> diff -puN include/asm-ppc64/topology.h~ppc64-remove-numa-debug include/asm-ppc64/topology.h
> --- memhotplug/include/asm-ppc64/topology.h~ppc64-remove-numa-debug	2005-03-21 07:35:03.000000000 -0800
> +++ memhotplug-dave/include/asm-ppc64/topology.h	2005-03-21 07:35:16.000000000 -0800
> @@ -8,15 +8,7 @@
>  
>  static inline int cpu_to_node(int cpu)
>  {
> -	int node;
> -
> -	node = numa_cpu_lookup_table[cpu];
> -
> -#ifdef DEBUG_NUMA
> -	BUG_ON(node == -1);
> -#endif
> -
> -	return node;
> +	return numa_cpu_lookup_table[cpu];
>  }
>  
>  #define parent_node(node)	(node)
> _
> 
> 
> ------------------------------------------------------------------------
> 

The second patch isn't quite ready for primetime yet.  I'll fix it and 
repost today.

> 
> 
> ---
> 
>  arch/ppc64/mm/numa.c                       |    0 
>  memhotplug-dave/include/asm-ppc64/mmzone.h |   38 ++++++-----------------------
>  memhotplug-dave/include/linux/mm.h         |    2 -
>  3 files changed, 10 insertions(+), 30 deletions(-)
> 
> diff -puN include/asm-ppc64/mmzone.h~B-sparse-171-discontig-alone include/asm-ppc64/mmzone.h
> --- memhotplug/include/asm-ppc64/mmzone.h~B-sparse-171-discontig-alone	2005-03-21 07:36:49.000000000 -0800
> +++ memhotplug-dave/include/asm-ppc64/mmzone.h	2005-03-21 07:44:36.000000000 -0800
> @@ -10,14 +10,8 @@
>  #include <linux/config.h>
>  #include <asm/smp.h>
>  
> -#ifdef CONFIG_DISCONTIGMEM
> -
> +#ifdef CONFIG_NUMA
>  extern struct pglist_data *node_data[];
> -
> -/*
> - * Following are specific to this numa platform.
> - */
> -
>  extern int numa_cpu_lookup_table[];
>  extern char *numa_memory_lookup_table;
>  extern cpumask_t numa_cpumask_lookup_table[];
> @@ -31,32 +25,21 @@ static inline int pa_to_nid(unsigned lon
>  {
>  	return numa_memory_lookup_table[pa >> MEMORY_INCREMENT_SHIFT];
>  }
> -
> -#define pfn_to_nid(pfn)		pa_to_nid((pfn) << PAGE_SHIFT)
> -
> -/*
> - * Return a pointer to the node data for node n.
> - */
>  #define NODE_DATA(nid)		(node_data[nid])
> -
>  #define node_localnr(pfn, nid)	((pfn) - NODE_DATA(nid)->node_start_pfn)
> -
> -/*
> - * Following are macros that each numa implmentation must define.
> - */
> -
> -/*
> - * Given a kernel address, find the home node of the underlying memory.
> - */
>  #define kvaddr_to_nid(kaddr)	pa_to_nid(__pa(kaddr))
> +#define pfn_to_nid(pfn)		pa_to_nid((pfn) << PAGE_SHIFT)
> +#endif /* CONFIG_NUMA */
> +
> +#define local_mapnr(kvaddr) \
> +	( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr))
> +#define node_localnr(pfn, nid)	((pfn) - NODE_DATA(nid)->node_start_pfn)

If NUMA is turned on node_localnr() gets defined twice.

>  
>  #define node_mem_map(nid)	(NODE_DATA(nid)->node_mem_map)
>  #define node_start_pfn(nid)	(NODE_DATA(nid)->node_start_pfn)
>  #define node_end_pfn(nid)	(NODE_DATA(nid)->node_end_pfn)
>  
> -#define local_mapnr(kvaddr) \
> -	( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) 
> -
> +#ifdef CONFIG_DISCONTIGMEM
>  /* Written this way to avoid evaluating arguments twice */
>  #define discontigmem_pfn_to_page(pfn) \
>  ({ \
> @@ -64,16 +47,13 @@ static inline int pa_to_nid(unsigned lon
>  	(node_mem_map(pfn_to_nid(__tmp)) + \
>  	 node_localnr(__tmp, pfn_to_nid(__tmp))); \
>  })
> -
>  #define discontigmem_page_to_pfn(p) \
>  ({ \
>  	struct page *__tmp = p; \
>  	(((__tmp) - page_zone(__tmp)->zone_mem_map) + \
>  	 page_zone(__tmp)->zone_start_pfn); \
>  })
> -
> -/* XXX fix for discontiguous physical memory */
>  #define discontigmem_pfn_valid(pfn)		((pfn) < num_physpages)
> -
>  #endif /* CONFIG_DISCONTIGMEM */
> +
>  #endif /* _ASM_MMZONE_H_ */
> diff -puN include/linux/mmzone.h~B-sparse-171-discontig-alone include/linux/mmzone.h
> diff -puN include/asm-ppc64/page.h~B-sparse-171-discontig-alone include/asm-ppc64/page.h
> diff -puN include/linux/mm.h~B-sparse-171-discontig-alone include/linux/mm.h
> --- memhotplug/include/linux/mm.h~B-sparse-171-discontig-alone	2005-03-21 07:36:49.000000000 -0800
> +++ memhotplug-dave/include/linux/mm.h	2005-03-21 07:36:49.000000000 -0800
> @@ -462,7 +462,7 @@ static inline void set_page_links(struct
>  	set_page_node(page, node);
>  }
>  
> -#ifndef CONFIG_DISCONTIGMEM
> +#ifdef CONFIG_FLATMEM

This needs to be pulled out separate since it depends on a as yet 
unposted patch.






More information about the Linuxppc64-dev mailing list