mmzone_32.h 3.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
/*
 * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
 *
 */

H
H. Peter Anvin 已提交
6 7
#ifndef _ASM_X86_MMZONE_32_H
#define _ASM_X86_MMZONE_32_H
L
Linus Torvalds 已提交
8 9 10

#include <asm/smp.h>

11
#ifdef CONFIG_NUMA
12 13
extern struct pglist_data *node_data[];
#define NODE_DATA(nid)	(node_data[nid])
L
Linus Torvalds 已提交
14

15 16 17
#include <asm/numaq.h>
/* summit or generic arch */
#include <asm/srat.h>
L
Linus Torvalds 已提交
18

19
extern int get_memcfg_numa_flat(void);
20 21 22 23 24 25 26
/*
 * This allows any one NUMA architecture to be compiled
 * for, and still fall back to the flat function if it
 * fails.
 */
static inline void get_memcfg_numa(void)
{
27

28 29 30 31 32 33 34
	if (get_memcfg_numaq())
		return;
	if (get_memcfg_from_srat())
		return;
	get_memcfg_numa_flat();
}

35 36
extern int early_pfn_to_nid(unsigned long pfn);

37
#else /* !CONFIG_NUMA */
38

39
#define get_memcfg_numa get_memcfg_numa_flat
40

41 42 43
#endif /* CONFIG_NUMA */

#ifdef CONFIG_DISCONTIGMEM
L
Linus Torvalds 已提交
44 45 46 47

/*
 * generic node memory support, the following assumptions apply:
 *
48
 * 1) memory comes in 64Mb contigious chunks which are either present or not
L
Linus Torvalds 已提交
49 50 51 52 53 54
 * 2) we will not have more than 64Gb in total
 *
 * for now assume that 64Gb is max amount of RAM for whole system
 *    64Gb / 4096bytes/page = 16777216 pages
 */
#define MAX_NR_PAGES 16777216
55
#define MAX_ELEMENTS 1024
L
Linus Torvalds 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)

extern s8 physnode_map[];

static inline int pfn_to_nid(unsigned long pfn)
{
#ifdef CONFIG_NUMA
	return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]);
#else
	return 0;
#endif
}

/*
 * Following are macros that each numa implmentation must define.
 */

#define node_start_pfn(nid)	(NODE_DATA(nid)->node_start_pfn)
#define node_end_pfn(nid)						\
({									\
	pg_data_t *__pgdat = NODE_DATA(nid);				\
	__pgdat->node_start_pfn + __pgdat->node_spanned_pages;		\
})

static inline int pfn_valid(int pfn)
{
	int nid = pfn_to_nid(pfn);

	if (nid >= 0)
		return (pfn < node_end_pfn(nid));
	return 0;
}
88 89 90 91

#endif /* CONFIG_DISCONTIGMEM */

#ifdef CONFIG_NEED_MULTIPLE_NODES
L
Linus Torvalds 已提交
92 93

/*
94
 * Following are macros that are specific to this numa platform.
L
Linus Torvalds 已提交
95
 */
96 97
#define reserve_bootmem(addr, size, flags) \
	reserve_bootmem_node(NODE_DATA(0), (addr), (size), (flags))
98 99
#define alloc_bootmem(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
100 101 102
#define alloc_bootmem_nopanic(x) \
	__alloc_bootmem_node_nopanic(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
				__pa(MAX_DMA_ADDRESS))
103 104 105 106
#define alloc_bootmem_low(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
#define alloc_bootmem_pages(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
107 108 109
#define alloc_bootmem_pages_nopanic(x) \
	__alloc_bootmem_node_nopanic(NODE_DATA(0), (x), PAGE_SIZE, \
				__pa(MAX_DMA_ADDRESS))
110 111
#define alloc_bootmem_low_pages(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
112 113
#define alloc_bootmem_node(pgdat, x)					\
({									\
D
David Rientjes 已提交
114
	struct pglist_data  __maybe_unused			\
115 116 117 118 119 120
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,	\
						__pa(MAX_DMA_ADDRESS));	\
})
#define alloc_bootmem_pages_node(pgdat, x)				\
({									\
D
David Rientjes 已提交
121
	struct pglist_data  __maybe_unused			\
122 123
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,		\
124
						__pa(MAX_DMA_ADDRESS));	\
125 126 127
})
#define alloc_bootmem_low_pages_node(pgdat, x)				\
({									\
D
David Rientjes 已提交
128
	struct pglist_data  __maybe_unused			\
129 130 131
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);		\
})
132
#endif /* CONFIG_NEED_MULTIPLE_NODES */
133

H
H. Peter Anvin 已提交
134
#endif /* _ASM_X86_MMZONE_32_H */