Commit 59356466 authored by Matthew Dobson's avatar Matthew Dobson Committed by Linus Torvalds

[PATCH] Create nodemask_t

The idea behind this patch is to create a nodemask_t as a node analog of
cpumask_t.  As NUMA machines become more common, the need for a standard,
cross-platform bitmap of both online & possible nodes becomes more
apparent.  We believe we've worked out most of the kinks of the variable
length bitmap types with the recent cpumask_t patches.  Nodemasks are also
currently far less widespread than cpumasks.  Further, inclusion at this
point in the kernel would mean consistency in node handling between 2.6 and
2.7.

Future goals would be to get rid of the 'numnodes' variable used to count
the number of online nodes, and replace with node_online_map.  This would
allow arbitrary node numbering and facilitate node hotplugging.

(Nothing actually uses this yet, but several projects need it, and it does
model a well-defined physical grouping).
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 66d5cab9
......@@ -28,6 +28,7 @@
#include <linux/bootmem.h>
#include <linux/mmzone.h>
#include <linux/module.h>
#include <linux/nodemask.h>
#include <asm/numaq.h>
/* These are needed before the pgdat's are created */
......
......@@ -28,6 +28,7 @@
#include <linux/bootmem.h>
#include <linux/mmzone.h>
#include <linux/acpi.h>
#include <linux/nodemask.h>
#include <asm/srat.h>
/*
......
......@@ -27,6 +27,7 @@
*/
#include <linux/init.h>
#include <linux/smp.h>
#include <linux/nodemask.h>
#include <asm/cpu.h>
struct i386_cpu cpu_devices[NR_CPUS];
......
......@@ -28,6 +28,7 @@
#include <linux/mmzone.h>
#include <linux/highmem.h>
#include <linux/initrd.h>
#include <linux/nodemask.h>
#include <asm/e820.h>
#include <asm/setup.h>
#include <asm/mmzone.h>
......
......@@ -43,6 +43,7 @@
#include <linux/acpi.h>
#include <linux/efi.h>
#include <linux/mmzone.h>
#include <linux/nodemask.h>
#include <asm/io.h>
#include <asm/iosapic.h>
#include <asm/machvec.h>
......
......@@ -16,6 +16,7 @@
#include <linux/bootmem.h>
#include <linux/acpi.h>
#include <linux/efi.h>
#include <linux/nodemask.h>
#include <asm/pgalloc.h>
#include <asm/tlb.h>
#include <asm/meminit.h>
......
......@@ -6,6 +6,8 @@
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/nodemask.h>
#include <asm/current.h>
#include <asm/processor.h>
#include <asm/cputable.h>
......
......@@ -14,6 +14,7 @@
#include <linux/mm.h>
#include <linux/mmzone.h>
#include <linux/module.h>
#include <linux/nodemask.h>
#include <asm/lmb.h>
#include <asm/machdep.h>
#include <asm/abs_addr.h>
......
......@@ -12,6 +12,7 @@
#include <linux/init.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/nodemask.h>
#include <asm/io.h>
#include <linux/pci_ids.h>
#include <asm/types.h>
......
......@@ -10,6 +10,8 @@
#include <linux/mmzone.h>
#include <linux/ctype.h>
#include <linux/module.h>
#include <linux/nodemask.h>
#include <asm/e820.h>
#include <asm/proto.h>
#include <asm/dma.h>
......@@ -151,9 +153,9 @@ void __init numa_init_array(void)
for (i = 0; i < MAXNODE; i++) {
if (node_online(i))
continue;
rr = find_next_bit(node_online_map, MAX_NUMNODES, rr);
rr = next_node(rr, node_online_map);
if (rr == MAX_NUMNODES)
rr = find_first_bit(node_online_map, MAX_NUMNODES);
rr = first_node(node_online_map);
node_data[i] = node_data[rr];
cpu_to_node[i] = rr;
rr++;
......
......@@ -4,6 +4,7 @@
#include <linux/device.h>
#include <linux/cpu.h>
#include <linux/topology.h>
#include <linux/nodemask.h>
#include <asm/node.h>
......
......@@ -5,6 +5,7 @@
#include <linux/mmzone.h>
#include <linux/node.h>
#include <linux/topology.h>
#include <linux/nodemask.h>
struct i386_node {
struct node node;
......
#ifndef _ASM_X8664_NUMA_H
#define _ASM_X8664_NUMA_H 1
#include <linux/nodemask.h>
#define MAXNODE 8
#define NODEMASK 0xff
......
......@@ -410,35 +410,6 @@ extern struct pglist_data contig_page_data;
#error ZONES_SHIFT > MAX_ZONES_SHIFT
#endif
extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
#if defined(CONFIG_DISCONTIGMEM) || defined(CONFIG_NUMA)
#define node_online(node) test_bit(node, node_online_map)
#define node_set_online(node) set_bit(node, node_online_map)
#define node_set_offline(node) clear_bit(node, node_online_map)
static inline unsigned int num_online_nodes(void)
{
int i, num = 0;
for(i = 0; i < MAX_NUMNODES; i++){
if (node_online(i))
num++;
}
return num;
}
#else /* !CONFIG_DISCONTIGMEM && !CONFIG_NUMA */
#define node_online(node) \
({ BUG_ON((node) != 0); test_bit(node, node_online_map); })
#define node_set_online(node) \
({ BUG_ON((node) != 0); set_bit(node, node_online_map); })
#define node_set_offline(node) \
({ BUG_ON((node) != 0); clear_bit(node, node_online_map); })
#define num_online_nodes() 1
#endif /* CONFIG_DISCONTIGMEM || CONFIG_NUMA */
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _LINUX_MMZONE_H */
This diff is collapsed.
......@@ -66,6 +66,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/nodemask.h>
#include <linux/gfp.h>
#include <linux/slab.h>
#include <linux/string.h>
......@@ -95,7 +96,7 @@ static int nodes_online(unsigned long *nodes)
{
DECLARE_BITMAP(online2, MAX_NUMNODES);
bitmap_copy(online2, node_online_map, MAX_NUMNODES);
bitmap_copy(online2, nodes_addr(node_online_map), MAX_NUMNODES);
if (bitmap_empty(online2, MAX_NUMNODES))
set_bit(0, online2);
if (!bitmap_subset(nodes, online2, MAX_NUMNODES))
......@@ -424,7 +425,7 @@ static void get_zonemask(struct mempolicy *p, unsigned long *nodes)
case MPOL_PREFERRED:
/* or use current node instead of online map? */
if (p->v.preferred_node < 0)
bitmap_copy(nodes, node_online_map, MAX_NUMNODES);
bitmap_copy(nodes, nodes_addr(node_online_map), MAX_NUMNODES);
else
__set_bit(p->v.preferred_node, nodes);
break;
......@@ -692,7 +693,7 @@ static struct page *alloc_page_interleave(unsigned gfp, unsigned order, unsigned
struct zonelist *zl;
struct page *page;
BUG_ON(!test_bit(nid, node_online_map));
BUG_ON(!node_online(nid));
zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK);
page = __alloc_pages(gfp, order, zl);
if (page && page_zone(page) == zl->zones[0]) {
......@@ -1081,7 +1082,8 @@ void __init numa_policy_init(void)
/* Set interleaving policy for system init. This way not all
the data structures allocated at system boot end up in node zero. */
if (sys_set_mempolicy(MPOL_INTERLEAVE, node_online_map, MAX_NUMNODES) < 0)
if (sys_set_mempolicy(MPOL_INTERLEAVE, nodes_addr(node_online_map),
MAX_NUMNODES) < 0)
printk("numa_policy_init: interleaving failed\n");
}
......
......@@ -31,10 +31,12 @@
#include <linux/topology.h>
#include <linux/sysctl.h>
#include <linux/cpu.h>
#include <linux/nodemask.h>
#include <asm/tlbflush.h>
DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
nodemask_t node_online_map = NODE_MASK_NONE;
nodemask_t node_possible_map = NODE_MASK_ALL;
struct pglist_data *pgdat_list;
unsigned long totalram_pages;
unsigned long totalhigh_pages;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment