Skip to contentSkip to conversation

Create nodemask_t

PATCH New Matthew Dobson 1 participant 1 message Jul 16, 2004

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Create nodemask_t

Late, but not forgotten, here's the somewhat anticipated nodemask_t patch.

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.

With that, I would like to submit the following patch for discussion, and eventually, inclusion.

Thanks!

-Matt

arch/i386/kernel/numaq.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/i386/kernel/numaq.c linux-2.6.7-mm7+nodemask_t/arch/i386/kernel/numaq.c
@@ -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 */
arch/i386/kernel/srat.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/i386/kernel/srat.c linux-2.6.7-mm7+nodemask_t/arch/i386/kernel/srat.c
@@ -28,6 +28,7 @@
 #include <linux/bootmem.h>
 #include <linux/mmzone.h>
 #include <linux/acpi.h>
+#include <linux/nodemask.h>
 #include <asm/srat.h>
 
 /*
arch/i386/mach-default/topology.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/i386/mach-default/topology.c linux-2.6.7-mm7+nodemask_t/arch/i386/mach-default/topology.c
@@ -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];
arch/i386/mm/discontig.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/i386/mm/discontig.c linux-2.6.7-mm7+nodemask_t/arch/i386/mm/discontig.c
@@ -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>
arch/ia64/kernel/acpi.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/ia64/kernel/acpi.c linux-2.6.7-mm7+nodemask_t/arch/ia64/kernel/acpi.c
@@ -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>
arch/ia64/mm/discontig.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/ia64/mm/discontig.c linux-2.6.7-mm7+nodemask_t/arch/ia64/mm/discontig.c
@@ -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>
arch/ppc64/kernel/sysfs.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/ppc64/kernel/sysfs.c linux-2.6.7-mm7+nodemask_t/arch/ppc64/kernel/sysfs.c
@@ -5,6 +5,7 @@
 #include <linux/percpu.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/nodemask.h>
 #include <asm/current.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
arch/ppc64/mm/numa.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/ppc64/mm/numa.c linux-2.6.7-mm7+nodemask_t/arch/ppc64/mm/numa.c
@@ -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>
arch/x86_64/mm/k8topology.c +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/x86_64/mm/k8topology.c linux-2.6.7-mm7+nodemask_t/arch/x86_64/mm/k8topology.c
@@ -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>
arch/x86_64/mm/numa.c +3 -2
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/arch/x86_64/mm/numa.c linux-2.6.7-mm7+nodemask_t/arch/x86_64/mm/numa.c
@@ -10,6 +10,7 @@
 #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 +152,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++; 
include/asm-i386/cpu.h +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/include/asm-i386/cpu.h linux-2.6.7-mm7+nodemask_t/include/asm-i386/cpu.h
@@ -4,6 +4,7 @@
 #include <linux/device.h>
 #include <linux/cpu.h>
 #include <linux/topology.h>
+#include <linux/nodemask.h>
 
 #include <asm/node.h>
 
include/asm-i386/node.h +1 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/include/asm-i386/node.h linux-2.6.7-mm7+nodemask_t/include/asm-i386/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;
include/asm-x86_64/numa.h +2 -0
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/include/asm-x86_64/numa.h linux-2.6.7-mm7+nodemask_t/include/asm-x86_64/numa.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_X8664_NUMA_H 
 #define _ASM_X8664_NUMA_H 1
 
+#include <linux/nodemask.h>
+
 #define MAXNODE 8 
 #define NODEMASK 0xff
 
include/linux/mmzone.h +0 -29
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/include/linux/mmzone.h linux-2.6.7-mm7+nodemask_t/include/linux/mmzone.h
@@ -411,35 +411,6 @@ extern struct pglist_data contig_page_da
 #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 */
include/linux/nodemask.h +328 -0

328 lines not on this page · raw message

mm/mempolicy.c +6 -4
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/mm/mempolicy.c linux-2.6.7-mm7+nodemask_t/mm/mempolicy.c
@@ -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 *n
 {
 	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))
@@ -422,7 +423,7 @@ static void get_zonemask(struct mempolic
 	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;
@@ -628,7 +629,7 @@ static struct page *alloc_page_interleav
 	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]) {
@@ -1017,7 +1018,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");
 }
 
mm/page_alloc.c +3 -1
diff -Nurp --exclude-from=/home/mcd/.dontdiff linux-2.6.7-mm7/mm/page_alloc.c linux-2.6.7-mm7+nodemask_t/mm/page_alloc.c
@@ -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;