
From: "Andi Kleen" <ak@suse.de>

Add a real pfn_valid

This adds a real pfn_valid.  Needed together with the SRAT patch which can
generated memmap less holes for mmio.  In general it will help to handle
memory holes better.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/include/asm-x86_64/mmzone.h |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff -puN include/asm-x86_64/mmzone.h~x86_64-add-a-real-pfn_valid include/asm-x86_64/mmzone.h
--- 25/include/asm-x86_64/mmzone.h~x86_64-add-a-real-pfn_valid	2004-11-28 01:54:22.861121688 -0800
+++ 25-akpm/include/asm-x86_64/mmzone.h	2004-11-28 01:54:22.865121080 -0800
@@ -57,9 +57,8 @@ static inline __attribute__((pure)) int 
 #define page_to_pfn(page) \
 	(long)(((page) - page_zone(page)->zone_mem_map) + page_zone(page)->zone_start_pfn)
 
-/* AK: !DISCONTIGMEM just forces it to 1. Can't we too? */
-#define pfn_valid(pfn)          ((pfn) < num_physpages)
-
-
+#define pfn_valid(pfn) ((pfn) >= num_physpages ? 0 : \
+			({ u8 nid__ = pfn_to_nid(pfn); \
+			   nid__ != 0xff && (pfn) >= node_start_pfn(nid__) && (pfn) <= node_end_pfn(nid__); }))
 #endif
 #endif
_
