blob: a5b3817d4b9e621e2615ddd16435b83011206548 [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. */
H. Peter Anvin1965aae2008-10-22 22:26:29 -07004#ifndef _ASM_X86_MMZONE_64_H
5#define _ASM_X86_MMZONE_64_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
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
Jiri Slaby59ea7462008-06-12 13:56:40 +020010#include <linux/mmdebug.h>
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 Shah076422d2007-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 Shah076422d2007-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 Shah076422d2007-02-13 13:26:19 +010031 VIRTUAL_BUG_ON(!memnodemap);
Joe Perches60e9bfd2008-03-23 01:02:47 -070032 nid = memnodemap[addr >> memnode_shift];
33 VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
34 return nid;
35}
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define NODE_DATA(nid) (node_data[nid])
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
Joe Perches60e9bfd2008-03-23 01:02:47 -070040#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 NODE_DATA(nid)->node_spanned_pages)
42
Thomas Gleixner8a423ff2008-01-30 13:30:37 +010043extern int early_pfn_to_nid(unsigned long pfn);
44
Rohit Seth53fee042007-02-13 13:26:22 +010045#ifdef CONFIG_NUMA_EMU
Joe Perches60e9bfd2008-03-23 01:02:47 -070046#define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024)
47#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
Rohit Seth53fee042007-02-13 13:26:22 +010048#endif
49
Matt Tolentino2b976902005-06-23 00:08:06 -070050#endif
H. Peter Anvin1965aae2008-10-22 22:26:29 -070051#endif /* _ASM_X86_MMZONE_64_H */