Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* K8 NUMA support */ |
| 2 | /* Copyright 2002,2003 by Andi Kleen, SuSE Labs */ |
| 3 | /* 2.5 Version loosely based on the NUMAQ Code by Pat Gaughen. */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 4 | #ifndef _ASM_X86_MMZONE_64_H |
| 5 | #define _ASM_X86_MMZONE_64_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Matt Tolentino | 2b97690 | 2005-06-23 00:08:06 -0700 | [diff] [blame] | 8 | #ifdef CONFIG_NUMA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Jiri Slaby | 59ea746 | 2008-06-12 13:56:40 +0200 | [diff] [blame] | 10 | #include <linux/mmdebug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| 12 | #include <asm/smp.h> |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* Simple perfect hash to map physical addresses to node numbers */ |
Eric Dumazet | dcf36bf | 2006-03-25 16:31:46 +0100 | [diff] [blame] | 15 | struct memnode { |
| 16 | int shift; |
Amul Shah | 076422d | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 17 | unsigned int mapsize; |
travis@sgi.com | 4323838 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 18 | s16 *map; |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 19 | s16 embedded_map[64 - 8]; |
travis@sgi.com | 4323838 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 20 | } ____cacheline_aligned; /* total size = 128 bytes */ |
Eric Dumazet | dcf36bf | 2006-03-25 16:31:46 +0100 | [diff] [blame] | 21 | extern struct memnode memnode; |
| 22 | #define memnode_shift memnode.shift |
| 23 | #define memnodemap memnode.map |
Amul Shah | 076422d | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 24 | #define memnodemapsize memnode.mapsize |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | extern struct pglist_data *node_data[]; |
| 27 | |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 28 | static inline __attribute__((pure)) int phys_to_nid(unsigned long addr) |
| 29 | { |
| 30 | unsigned nid; |
Amul Shah | 076422d | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 31 | VIRTUAL_BUG_ON(!memnodemap); |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 32 | nid = memnodemap[addr >> memnode_shift]; |
| 33 | VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]); |
| 34 | return nid; |
| 35 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define NODE_DATA(nid) (node_data[nid]) |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 40 | #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | NODE_DATA(nid)->node_spanned_pages) |
| 42 | |
Rohit Seth | 53fee04 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 43 | #ifdef CONFIG_NUMA_EMU |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 44 | #define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024) |
| 45 | #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) |
Rohit Seth | 53fee04 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 46 | #endif |
| 47 | |
Matt Tolentino | 2b97690 | 2005-06-23 00:08:06 -0700 | [diff] [blame] | 48 | #endif |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 49 | #endif /* _ASM_X86_MMZONE_64_H */ |