From: "Martin J. Bligh" <mbligh@aracnet.com>

Fix pfn_valid for architctures with discontiguous memory.  This only
changes the NUMA definition, and it leaves the NUMA-Q definition as was,
because it's faster that way, it's in hotpaths, and our memory is always
contiguous.



---

 include/asm-i386/mmzone.h |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff -puN include/asm-i386/mmzone.h~ia32-discontig-pfn_valid-fix include/asm-i386/mmzone.h
--- 25/include/asm-i386/mmzone.h~ia32-discontig-pfn_valid-fix	2004-02-09 09:34:23.000000000 -0800
+++ 25-akpm/include/asm-i386/mmzone.h	2004-02-09 09:34:23.000000000 -0800
@@ -80,14 +80,19 @@ extern struct pglist_data *node_data[];
 		+ __zone->zone_start_pfn;				\
 })
 #define pmd_page(pmd)		(pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
-/*
- * pfn_valid should be made as fast as possible, and the current definition 
- * is valid for machines that are NUMA, but still contiguous, which is what
- * is currently supported. A more generalised, but slower definition would
- * be something like this - mbligh:
- * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) ) 
- */ 
+
+#ifdef CONFIG_X86_NUMAQ            /* we have contiguous memory on NUMA-Q */
 #define pfn_valid(pfn)          ((pfn) < num_physpages)
+#else
+static inline int pfn_valid(int pfn)
+{
+	int nid = pfn_to_nid(pfn);
+
+	if (nid >= 0)
+		return (pfn < node_end_pfn(nid));
+	return 0;
+}
+#endif
 
 /*
  * generic node memory support, the following assumptions apply:

_