public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Paul Jackson <pj@sgi.com>
Cc: colpatch@us.ibm.com, wli@holomorphy.com, linux-kernel@vger.kernel.org
Subject: [Patch 14/23] mask v2 - [3/7] nodemask_t_i386_changes
Date: Thu, 1 Apr 2004 13:12:23 -0800	[thread overview]
Message-ID: <20040401131223.2f3da21a.pj@sgi.com> (raw)
In-Reply-To: <20040401122802.23521599.pj@sgi.com>

Patch_14_of_23 - Matthew Dobson's [PATCH]_nodemask_t_i386_changes_[3_7]
	Changes to i386 specific code.  As with most arch changes,
	it involves close-coding loops (ie: for_each_online_node(nid)
	rather than for(nid=0;nid<numnodes;nid++)) and replacing the
	use of numnodes with num_online_nodes() and node_set_online(nid).

Diffstat Patch_14_of_23:
 arch/i386/kernel/mpparse.c              |    4 ++--
 arch/i386/kernel/numaq.c                |   10 ++++------
 arch/i386/kernel/smpboot.c              |    2 +-
 arch/i386/kernel/srat.c                 |   23 +++++++++++------------
 arch/i386/mm/discontig.c                |   17 ++++++++---------
 arch/i386/mm/hugetlbpage.c              |    8 ++++----
 arch/i386/pci/numa.c                    |   11 ++++-------
 include/asm-i386/mach-numaq/mach_apic.h |   10 ++++++----
 8 files changed, 40 insertions(+), 45 deletions(-)


diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
--- a/arch/i386/kernel/mpparse.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/kernel/mpparse.c	Mon Mar 29 01:03:48 2004
@@ -287,8 +287,8 @@
 		printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n");
 	else
 		translation_table[mpc_record] = m; /* stash this for later */
-	if (m->trans_quad+1 > numnodes)
-		numnodes = m->trans_quad+1;
+	if (m->trans_quad+1 > num_online_nodes())
+		node_set_online(m->trans_quad);
 }
 
 /*
diff -Nru a/arch/i386/kernel/numaq.c b/arch/i386/kernel/numaq.c
--- a/arch/i386/kernel/numaq.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/kernel/numaq.c	Mon Mar 29 01:03:48 2004
@@ -39,8 +39,7 @@
  * Function: smp_dump_qct()
  *
  * Description: gets memory layout from the quad config table.  This
- * function also increments numnodes with the number of nodes (quads)
- * present.
+ * function also updates node_online_map with the nodes (quads) present.
  */
 static void __init smp_dump_qct(void)
 {
@@ -49,11 +48,10 @@
 	struct sys_cfg_data *scd =
 		(struct sys_cfg_data *)__va(SYS_CFG_DATA_PRIV_ADDR);
 
-	numnodes = 0;
-	for(node = 0; node < MAX_NUMNODES; node++) {
+	nodes_clear(node_online_map);
+	for_each_node(node) {
 		if(scd->quads_present31_0 & (1 << node)) {
 			node_set_online(node);
-			numnodes++;
 			eq = &scd->eq[node];
 			/* Convert to pages */
 			node_start_pfn[node] = MB_TO_PAGES(
@@ -86,7 +84,7 @@
 		(struct sys_cfg_data *)__va(SYS_CFG_DATA_PRIV_ADDR);
 
 	
-	for(nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		if(scd->quads_present31_0 & (1 << nid)) {
 			eq = &scd->eq[nid];
 			cur = eq->hi_shrd_mem_start;
diff -Nru a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
--- a/arch/i386/kernel/smpboot.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/kernel/smpboot.c	Mon Mar 29 01:03:48 2004
@@ -520,7 +520,7 @@
 	int node;
 
 	printk("Unmapping cpu %d from all nodes\n", cpu);
-	for (node = 0; node < MAX_NUMNODES; node ++)
+	for_each_node(node)
 		cpu_clear(cpu, node_2_cpu_mask[node]);
 	cpu_2_node[cpu] = -1;
 }
diff -Nru a/arch/i386/kernel/srat.c b/arch/i386/kernel/srat.c
--- a/arch/i386/kernel/srat.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/kernel/srat.c	Mon Mar 29 01:03:48 2004
@@ -248,17 +248,16 @@
 	 * a set of sequential node IDs starting at zero.  (ACPI doesn't seem
 	 * to specify the range of _PXM values.)
 	 */
-	numnodes = 0;		/* init total nodes in system */
+	nodes_clear(node_online_map);	/* init total nodes in system */
 	for (i = 0; i < MAX_PXM_DOMAINS; i++) {
 		if (BMAP_TEST(pxm_bitmap, i)) {
-			pxm_to_nid_map[i] = numnodes;
-			nid_to_pxm_map[numnodes] = i;
-			node_set_online(numnodes);
-			++numnodes;
+			pxm_to_nid_map[i] = num_online_nodes();
+			nid_to_pxm_map[num_online_nodes()] = i;
+			node_set_online(num_online_nodes());
 		}
 	}
 
-	if (numnodes == 0)
+	if (num_online_nodes() == 0)
 		BUG();
 
 	/* set cnode id in memory chunk structure */
@@ -272,7 +271,7 @@
 		printk("%02X ", pxm_bitmap[i]);
 	}
 	printk("\n");
-	printk("Number of logical nodes in system = %d\n", numnodes);
+	printk("Number of logical nodes in system = %d\n", num_online_nodes());
 	printk("Number of memory chunks in system = %d\n", num_memory_chunks);
 
 	for (j = 0; j < num_memory_chunks; j++){
@@ -283,7 +282,7 @@
 	}
  
 	/*calculate node_start_pfn/node_end_pfn arrays*/
-	for (nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		int been_here_before = 0;
 
 		for (j = 0; j < num_memory_chunks; j++){
@@ -415,7 +414,7 @@
 	int first;
 	unsigned long end = 0;
 
-	for (nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		first = 1;
 		for (c = 0; c < num_memory_chunks; c++){
 			if (node_memory_chunk[c].nid == nid) {
@@ -443,8 +442,8 @@
 		zholes_size_init++;
 		get_zholes_init();
 	}
-	if((nid >= numnodes) | (nid >= MAX_NUMNODES))
-		printk("%s: nid = %d is invalid. numnodes = %d",
-		       __FUNCTION__, nid, numnodes);
+	if (!node_online(nid))
+		printk("%s: nid = %d is invalid. num_online_nodes() = %d",
+		       __FUNCTION__, nid, num_online_nodes());
 	return &zholes_size[nid * MAX_NR_ZONES];
 }
diff -Nru a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
--- a/arch/i386/mm/discontig.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/mm/discontig.c	Mon Mar 29 01:03:48 2004
@@ -39,7 +39,7 @@
  * numa interface - we expect the numa architecture specfic code to have
  *                  populated the following initialisation.
  *
- * 1) numnodes         - the total number of nodes configured in the system
+ * 1) node_online_map  - the bitmap of nodes configured in the system
  * 2) physnode_map     - the mapping between a pfn and owning node
  * 3) node_start_pfn   - the starting page frame number for a node
  * 3) node_end_pfn     - the ending page fram number for a node
@@ -107,7 +107,6 @@
 
          /* Indicate there is one node available. */
 	node_set_online(0);
-	numnodes = 1;
 	return 1;
 }
 
@@ -189,7 +188,7 @@
 	unsigned long pfn;
 	int node;
 
-	for (node = 1; node < numnodes; ++node) {
+	for(node = 1; node < num_online_nodes(); node++) {
 		for (pfn=0; pfn < node_remap_size[node]; pfn += PTRS_PER_PTE) {
 			vaddr = node_remap_start_vaddr[node]+(pfn<<PAGE_SHIFT);
 			set_pmd_pfn((ulong) vaddr, 
@@ -204,7 +203,7 @@
 	int nid;
 	unsigned long size, reserve_pages = 0;
 
-	for (nid = 1; nid < numnodes; nid++) {
+	for(nid = 1; nid < num_online_nodes(); nid++) {
 		/* calculate the size of the mem_map needed in bytes */
 		size = (node_end_pfn[nid] - node_start_pfn[nid] + 1) 
 			* sizeof(struct page) + sizeof(pg_data_t);
@@ -256,7 +255,7 @@
 
 	printk("Low memory ends at vaddr %08lx\n",
 			(ulong) pfn_to_kaddr(max_low_pfn));
-	for (nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		node_remap_start_vaddr[nid] = pfn_to_kaddr(
 			highstart_pfn - node_remap_offset[nid]);
 		allocate_pgdat(nid);
@@ -267,7 +266,7 @@
 	}
 	printk("High memory starts at vaddr %08lx\n",
 			(ulong) pfn_to_kaddr(highstart_pfn));
-	for (nid = 0; nid < numnodes; nid++)
+	for_each_online_node(nid)
 		find_max_pfn_node(nid);
 
 	NODE_DATA(0)->bdata = &node0_bdata;
@@ -342,14 +341,14 @@
 	 * Clobber node 0's links and NULL out pgdat_list before starting.
 	 */
 	pgdat_list = NULL;
-	for (nid = numnodes - 1; nid >= 0; nid--) {       
+	for(nid = num_online_nodes() - 1; nid >= 0; nid--) {       
 		if (nid)
 			memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
 		NODE_DATA(nid)->pgdat_next = pgdat_list;
 		pgdat_list = NODE_DATA(nid);
 	}
 
-	for (nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
 		unsigned long *zholes_size;
 		unsigned int max_dma;
@@ -405,7 +404,7 @@
 #ifdef CONFIG_HIGHMEM
 	int nid;
 
-	for (nid = 0; nid < numnodes; nid++) {
+	for_each_online_node(nid) {
 		unsigned long node_pfn, node_high_size, zone_start_pfn;
 		struct page * zone_mem_map;
 		
diff -Nru a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
--- a/arch/i386/mm/hugetlbpage.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/mm/hugetlbpage.c	Mon Mar 29 01:03:48 2004
@@ -39,11 +39,11 @@
 	struct page *page = NULL;
 
 	if (list_empty(&hugepage_freelists[nid])) {
-		for (nid = 0; nid < MAX_NUMNODES; ++nid)
+		for_each_node(nid)
 			if (!list_empty(&hugepage_freelists[nid]))
 				break;
 	}
-	if (nid >= 0 && nid < MAX_NUMNODES && !list_empty(&hugepage_freelists[nid])) {
+	if (node_possible(nid) && !list_empty(&hugepage_freelists[nid])) {
 		page = list_entry(hugepage_freelists[nid].next, struct page, list);
 		list_del(&page->list);
 	}
@@ -55,7 +55,7 @@
 	static int nid = 0;
 	struct page *page;
 	page = alloc_pages_node(nid, GFP_HIGHUSER, HUGETLB_PAGE_ORDER);
-	nid = (nid + 1) % numnodes;
+	nid = (nid + 1) % num_online_nodes();
 	return page;
 }
 
@@ -494,7 +494,7 @@
 	if (!cpu_has_pse)
 		return -ENODEV;
 
-	for (i = 0; i < MAX_NUMNODES; ++i)
+	for_each_node(i)
 		INIT_LIST_HEAD(&hugepage_freelists[i]);
 
 	for (i = 0; i < htlbpage_max; ++i) {
diff -Nru a/arch/i386/pci/numa.c b/arch/i386/pci/numa.c
--- a/arch/i386/pci/numa.c	Mon Mar 29 01:03:48 2004
+++ b/arch/i386/pci/numa.c	Mon Mar 29 01:03:48 2004
@@ -115,13 +115,10 @@
 		return 0;
 
 	pci_root_bus = pcibios_scan_root(0);
-	if (numnodes > 1) {
-		for (quad = 1; quad < numnodes; ++quad) {
-			printk("Scanning PCI bus %d for quad %d\n", 
-				QUADLOCAL2BUS(quad,0), quad);
-			pci_scan_bus(QUADLOCAL2BUS(quad,0), 
-				&pci_root_ops, NULL);
-		}
+	for(quad = 1; quad < num_online_nodes(); quad++) {
+		printk("Scanning PCI bus %d for quad %d\n", 
+			QUADLOCAL2BUS(quad,0), quad);
+		pci_scan_bus(QUADLOCAL2BUS(quad,0), &pci_root_ops, NULL);
 	}
 	return 0;
 }
diff -Nru a/include/asm-i386/mach-numaq/mach_apic.h b/include/asm-i386/mach-numaq/mach_apic.h
--- a/include/asm-i386/mach-numaq/mach_apic.h	Mon Mar 29 01:03:48 2004
+++ b/include/asm-i386/mach-numaq/mach_apic.h	Mon Mar 29 01:03:48 2004
@@ -114,13 +114,15 @@
 
 static inline void setup_portio_remap(void)
 {
-	if (numnodes <= 1)
+	int num_nodes = num_online_nodes();
+
+	if (num_nodes <= 1)
        		return;
 
-	printk("Remapping cross-quad port I/O for %d quads\n", numnodes);
-	xquad_portio = ioremap (XQUAD_PORTIO_BASE, numnodes*XQUAD_PORTIO_QUAD);
+	printk("Remapping cross-quad port I/O for %d quads\n", num_nodes);
+	xquad_portio = ioremap (XQUAD_PORTIO_BASE, num_nodes*XQUAD_PORTIO_QUAD);
 	printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
-		(u_long) xquad_portio, (u_long) numnodes*XQUAD_PORTIO_QUAD);
+		(u_long) xquad_portio, (u_long) num_nodes*XQUAD_PORTIO_QUAD);
 }
 
 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)


-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj@sgi.com> 1.650.933.1373

  parent reply	other threads:[~2004-04-01 21:57 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01 20:28 [Patch 0/23] mask v2 - Second version of mask, cpumask and nodemask consolidation Paul Jackson
2004-04-01 21:10 ` [Patch 1/23] mask v2 - Document bitmap.c bit model Paul Jackson
2004-04-01 21:10 ` [Patch 2/23] mask v2 - Tighten unused bitmap bit handling Paul Jackson
2004-04-01 21:11 ` [Patch 3/23] mask v2 - New bitmap operators Paul Jackson
2004-04-01 21:11 ` [Patch 4/23] mask v2 - two missing 'const' qualifiers Paul Jackson
2004-04-01 21:11 ` [Patch 5/23] mask v2 - Add new mask.h file Paul Jackson
2004-04-02 20:26   ` Matthew Dobson
2004-04-03  5:12     ` Paul Jackson
2004-04-01 21:11 ` [Patch 6/23] mask v2 - Replace cpumask_t with one using mask Paul Jackson
2004-04-02 22:24   ` Matthew Dobson
2004-04-02 23:35     ` Paul Jackson
2004-04-03  1:09       ` Matthew Dobson
2004-04-03  6:00         ` Paul Jackson
2004-04-04  5:57           ` Paul Jackson
2004-04-03  5:23     ` Paul Jackson
2004-04-01 21:11 ` [Patch 7/23] mask v2 - Remove i386 obsolete cpumask ops Paul Jackson
2004-04-01 21:11 ` [Patch 8/23] mask v2 - Remove ppc64 " Paul Jackson
2004-04-01 21:11 ` [Patch 9/23] mask v2 - Remove x86_64 " Paul Jackson
2004-04-01 21:12 ` [Patch 10/23] mask v2 - Remove obsolete cpumask emulation Paul Jackson
2004-04-01 21:12 ` [Patch 11/23] mask v2 - Add new nodemasks.h file Paul Jackson
2004-04-01 21:12 ` [Patch 12/23] mask v2 - [1/7] mmzone.h changes for nodemask Paul Jackson
2004-04-01 21:12 ` [Patch 13/23] mask v2 - [2/7] nodemask_t core changes Paul Jackson
2004-04-01 21:12 ` Paul Jackson [this message]
2004-04-01 21:12 ` [Patch 15/23] mask v2 - [4/7] nodemask_t_pp64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 16/23] mask v2 - [5/7] nodemask_t_x86_64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 17/23] mask v2 = [6/7] nodemask_t_ia64_changes Paul Jackson
2004-04-06 11:37   ` Paul Jackson
2004-04-07  5:55     ` Denis Vlasenko
2004-04-07  6:50       ` Paul Jackson
2004-04-07  7:44         ` Paul Jackson
2004-04-07 14:13           ` Nick Piggin
2004-04-07 14:44             ` Paul Jackson
2004-04-07 15:02               ` Nick Piggin
2004-04-07 15:21                 ` Paul Jackson
2004-04-09  7:54           ` Denis Vlasenko
2004-04-09 17:53             ` Paul Jackson
2004-04-09 20:04               ` Denis Vlasenko
2004-04-10  2:54                 ` Paul Jackson
2004-04-07 11:27         ` Paul Jackson
2004-04-09 18:54           ` Paul Jackson
2004-04-01 21:12 ` [Patch 18/23] mask v2 - [7/7] nodemask_t_other_arch_changes Paul Jackson
2004-04-01 21:12 ` [Patch 19/23] mask v2 - Simplify sparc64 cpumask loop code Paul Jackson
2004-04-01 21:12 ` [Patch 20/23] mask v2 - Optimize i386 cpumask macro usage Paul Jackson
2004-04-01 21:13 ` [Patch 21/23] mask v2 - Dyadic physids_complement() Paul Jackson
2004-04-01 21:13 ` [Patch 22/23] mask v2 - Fix cpumask in asm-x86_64/topology.h Paul Jackson
2004-04-01 21:13 ` [Patch 23/23] mask v2 - Cpumask tweak in kernel/sched.c Paul Jackson
2004-04-02  8:15 ` [Patch 24/23] mask v2 - Small system optimizations Paul Jackson
2004-04-04  5:56   ` Paul Jackson
2004-04-04  6:16 ` [Patch 24a/23] mask v2 - UP fix, faster mask_of_bit, MASK_ALL* names Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040401131223.2f3da21a.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=colpatch@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox