From ca8878630bcd0467c21228f2d13f7b8a6649c612 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 4 Oct 2003 21:02:51 -0700 Subject: [PATCH] [PATCH] node enumeration fixes From: Matthew Dobson Here's a small update to the numnodes fix that went into -mm3. The biggest changes are: 1) move the actual NODES_SHIFT and MAX_NUMNODES definitions into linux/numa.h and include this in linux/mmzone.h, instead of being directly in linux/mmzone.h. This allows other files to include *just* the NUMNODES stuff w/out grabbing all of mmzone.h. 2) pull NODE_SHIFT out of linux/mm.h. This isn't used anywhere in the kernel, and it will only get confused with NODES_SHIFT. 3) Fix the IA64 patch. The original patch I had sent out hadn't been tested on IA64. It was mostly right, but there were circular dependencies. All better now, and acked by Jesse. 4) In linux/mmzone.h, insert code to define MAX_NODES_SHIFT based on the size of unsigned long. For 64-bit arches, we can have a much larger value. This allows IA64 to have 100's or 1000's of nodes. MAX_NODES_SHIFT is defined as 10 (ie: 1024 nodes) for 64-bit for now, although it could likely be much larger. For 32-bit it is 6 (ie: 64 nodes). 5) Small cleanup in include/asm-arm/memory.h. Mostly the result of the new linux/numa.h file. Much cleaner and more readable now. --- include/asm-arm/memory.h | 17 ++++++----------- include/asm-ia64/nodedata.h | 8 +++----- include/asm-ia64/numa.h | 4 ++-- include/asm-ia64/sn/pda.h | 2 +- include/linux/mm.h | 1 - include/linux/mmzone.h | 21 +++++++++++---------- include/linux/numa.h | 16 ++++++++++++++++ 7 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 include/linux/numa.h diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index c6c9fa67479a4..3d9b777a0349c 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h @@ -84,27 +84,24 @@ static inline void *phys_to_virt(unsigned long x) #define PHYS_TO_NID(addr) (0) -#else +#else /* CONFIG_DISCONTIGMEM */ + /* * This is more complex. We have a set of mem_map arrays spread * around in memory. */ -#include -#define NUM_NODES (1 << NODES_SHIFT) +#include #define page_to_pfn(page) \ (( (page) - page_zone(page)->zone_mem_map) \ + page_zone(page)->zone_start_pfn) - #define pfn_to_page(pfn) \ (PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT)) - -#define pfn_valid(pfn) (PFN_TO_NID(pfn) < NUM_NODES) +#define pfn_valid(pfn) (PFN_TO_NID(pfn) < MAX_NUMNODES) #define virt_to_page(kaddr) \ (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) - -#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < NUM_NODES) +#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < MAX_NUMNODES) /* * Common discontigmem stuff. @@ -112,9 +109,7 @@ static inline void *phys_to_virt(unsigned long x) */ #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) -#undef NUM_NODES - -#endif +#endif /* !CONFIG_DISCONTIGMEM */ /* * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die. diff --git a/include/asm-ia64/nodedata.h b/include/asm-ia64/nodedata.h index f09856b1c902e..eae5235fa8bec 100644 --- a/include/asm-ia64/nodedata.h +++ b/include/asm-ia64/nodedata.h @@ -8,13 +8,11 @@ * Copyright (c) 2002 Erich Focht * Copyright (c) 2002 Kimio Suganuma */ - - #ifndef _ASM_IA64_NODEDATA_H #define _ASM_IA64_NODEDATA_H - -#include +#include +#include /* * Node Data. One of these structures is located on each node of a NUMA system. @@ -24,7 +22,7 @@ struct pglist_data; struct ia64_node_data { short active_cpu_count; short node; - struct pglist_data *pg_data_ptrs[MAX_NUMNODES]; + struct pglist_data *pg_data_ptrs[MAX_NUMNODES]; struct page *bank_mem_map_base[NR_BANKS]; struct ia64_node_data *node_data_ptrs[MAX_NUMNODES]; short node_id_map[NR_BANKS]; diff --git a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h index ee2e483a07193..8b0d5edad7bac 100644 --- a/include/asm-ia64/numa.h +++ b/include/asm-ia64/numa.h @@ -16,9 +16,9 @@ #ifdef CONFIG_NUMA -# include - +#include #include + extern volatile char cpu_to_node_map[NR_CPUS] __cacheline_aligned; extern volatile cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned; diff --git a/include/asm-ia64/sn/pda.h b/include/asm-ia64/sn/pda.h index 426daf9b95961..7162968474c74 100644 --- a/include/asm-ia64/sn/pda.h +++ b/include/asm-ia64/sn/pda.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/linux/mm.h b/include/linux/mm.h index ca006021a13ed..f72772e17665d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -323,7 +323,6 @@ static inline void put_page(struct page *page) * The zone field is never updated after free_area_init_core() * sets it, so none of the operations on it need to be atomic. */ -#define NODE_SHIFT 4 #define ZONE_SHIFT (BITS_PER_LONG - 8) struct zone; diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fa476e70c2a9f..bea51c4f5b22f 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -10,14 +10,8 @@ #include #include #include +#include #include -#ifdef CONFIG_DISCONTIGMEM -#include -#endif -#ifndef NODES_SHIFT -#define NODES_SHIFT 0 -#endif -#define MAX_NUMNODES (1 << NODES_SHIFT) /* Free memory management - zoned buddy allocator. */ #ifndef CONFIG_FORCE_MAX_ZONEORDER @@ -313,12 +307,19 @@ extern struct pglist_data contig_page_data; #else /* CONFIG_DISCONTIGMEM */ #include + +#if BITS_PER_LONG == 32 /* - * page->zone is currently 8 bits - * there are 3 zones (2 bits) - * this leaves 8-2=6 bits for nodes + * with 32 bit flags field, page->zone is currently 8 bits. + * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. */ #define MAX_NODES_SHIFT 6 +#elif BITS_PER_LONG == 64 +/* + * with 64 bit flags field, there's plenty of room. + */ +#define MAX_NODES_SHIFT 10 +#endif #endif /* !CONFIG_DISCONTIGMEM */ diff --git a/include/linux/numa.h b/include/linux/numa.h new file mode 100644 index 0000000000000..bd0c8c4e9a95f --- /dev/null +++ b/include/linux/numa.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_NUMA_H +#define _LINUX_NUMA_H + +#include + +#ifdef CONFIG_DISCONTIGMEM +#include +#endif + +#ifndef NODES_SHIFT +#define NODES_SHIFT 0 +#endif + +#define MAX_NUMNODES (1 << NODES_SHIFT) + +#endif /* _LINUX_NUMA_H */ -- 2.53.0