blob: 594bd0dc1d081db7865f80e5a33c4c8ab4f7a718 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 Torvalds1da177e2005-04-16 15:20:36 -07007
Matt Tolentino2b976902005-06-23 00:08:06 -07008#ifdef CONFIG_NUMA
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Joe Perches60e9bfd2008-03-23 01:02:47 -070010#define VIRTUAL_BUG_ON(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12#include <asm/smp.h>
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014/* Simple perfect hash to map physical addresses to node numbers */
Eric Dumazetdcf36bf2006-03-25 16:31:46 +010015struct memnode {
16 int shift;
Amul Shah076422d22007-02-13 13:26:19 +010017 unsigned int mapsize;
travis@sgi.com43238382008-01-30 13:33:25 +010018 s16 *map;
Joe Perches60e9bfd2008-03-23 01:02:47 -070019 s16 embedded_map[64 - 8];
travis@sgi.com43238382008-01-30 13:33:25 +010020} ____cacheline_aligned; /* total size = 128 bytes */
Eric Dumazetdcf36bf2006-03-25 16:31:46 +010021extern struct memnode memnode;
22#define memnode_shift memnode.shift
23#define memnodemap memnode.map
Amul Shah076422d22007-02-13 13:26:19 +010024#define memnodemapsize memnode.mapsize
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26extern struct pglist_data *node_data[];
27
Joe Perches60e9bfd2008-03-23 01:02:47 -070028static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
29{
30 unsigned nid;
Amul Shah076422d22007-02-13 13:26:19 +010031 VIRTUAL_BUG_ON(!memnodemap);
32 VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize);
Joe Perches60e9bfd2008-03-23 01:02:47 -070033 nid = memnodemap[addr >> memnode_shift];
34 VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
35 return nid;
36}
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define NODE_DATA(nid) (node_data[nid])
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
Joe Perches60e9bfd2008-03-23 01:02:47 -070041#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 NODE_DATA(nid)->node_spanned_pages)
43
Thomas Gleixner8a423ff2008-01-30 13:30:37 +010044extern int early_pfn_to_nid(unsigned long pfn);
45
Rohit Seth53fee042007-02-13 13:26:22 +010046#ifdef CONFIG_NUMA_EMU
Joe Perches60e9bfd2008-03-23 01:02:47 -070047#define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024)
48#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
Rohit Seth53fee042007-02-13 13:26:22 +010049#endif
50
Matt Tolentino2b976902005-06-23 00:08:06 -070051#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif