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. */ |
| 4 | #ifndef _ASM_X86_64_MMZONE_H |
| 5 | #define _ASM_X86_64_MMZONE_H 1 |
| 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 | |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 10 | #define VIRTUAL_BUG_ON(x) |
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 | 076422d2 | 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 | 076422d2 | 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 | 076422d2 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 31 | VIRTUAL_BUG_ON(!memnodemap); |
| 32 | VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize); |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 33 | nid = memnodemap[addr >> memnode_shift]; |
| 34 | VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]); |
| 35 | return nid; |
| 36 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define NODE_DATA(nid) (node_data[nid]) |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 41 | #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | NODE_DATA(nid)->node_spanned_pages) |
| 43 | |
Thomas Gleixner | 8a423ff | 2008-01-30 13:30:37 +0100 | [diff] [blame] | 44 | extern int early_pfn_to_nid(unsigned long pfn); |
| 45 | |
Rohit Seth | 53fee04 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 46 | #ifdef CONFIG_NUMA_EMU |
Joe Perches | 60e9bfd | 2008-03-23 01:02:47 -0700 | [diff] [blame] | 47 | #define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024) |
| 48 | #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) |
Rohit Seth | 53fee04 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 49 | #endif |
| 50 | |
Matt Tolentino | 2b97690 | 2005-06-23 00:08:06 -0700 | [diff] [blame] | 51 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #endif |