]>
Commit | Line | Data |
---|---|---|
bbeae5b0 PZ |
1 | #ifndef PAGE_FLAGS_LAYOUT_H |
2 | #define PAGE_FLAGS_LAYOUT_H | |
3 | ||
4 | #include <linux/numa.h> | |
5 | #include <generated/bounds.h> | |
6 | ||
7 | /* | |
8 | * When a memory allocation must conform to specific limitations (such | |
9 | * as being suitable for DMA) the caller will pass in hints to the | |
10 | * allocator in the gfp_mask, in the zone modifier bits. These bits | |
11 | * are used to select a priority ordered list of memory zones which | |
12 | * match the requested limits. See gfp_zone() in include/linux/gfp.h | |
13 | */ | |
14 | #if MAX_NR_ZONES < 2 | |
15 | #define ZONES_SHIFT 0 | |
16 | #elif MAX_NR_ZONES <= 2 | |
17 | #define ZONES_SHIFT 1 | |
18 | #elif MAX_NR_ZONES <= 4 | |
19 | #define ZONES_SHIFT 2 | |
20 | #else | |
21 | #error ZONES_SHIFT -- too many zones configured adjust calculation | |
22 | #endif | |
23 | ||
24 | #ifdef CONFIG_SPARSEMEM | |
25 | #include <asm/sparsemem.h> | |
26 | ||
27 | /* SECTION_SHIFT #bits space required to store a section # */ | |
28 | #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS) | |
29 | ||
30 | #endif /* CONFIG_SPARSEMEM */ | |
31 | ||
32 | /* | |
33 | * page->flags layout: | |
34 | * | |
35 | * There are three possibilities for how page->flags get | |
36 | * laid out. The first is for the normal case, without | |
37 | * sparsemem. The second is for sparsemem when there is | |
38 | * plenty of space for node and section. The last is when | |
39 | * we have run out of space and have to fall back to an | |
40 | * alternate (slower) way of determining the node. | |
41 | * | |
42 | * No sparsemem or sparsemem vmemmap: | NODE | ZONE | ... | FLAGS | | |
43 | * classic sparse with space for node:| SECTION | NODE | ZONE | ... | FLAGS | | |
44 | * classic sparse no space for node: | SECTION | ZONE | ... | FLAGS | | |
45 | */ | |
46 | #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) | |
47 | #define SECTIONS_WIDTH SECTIONS_SHIFT | |
48 | #else | |
49 | #define SECTIONS_WIDTH 0 | |
50 | #endif | |
51 | ||
52 | #define ZONES_WIDTH ZONES_SHIFT | |
53 | ||
54 | #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS | |
55 | #define NODES_WIDTH NODES_SHIFT | |
56 | #else | |
57 | #ifdef CONFIG_SPARSEMEM_VMEMMAP | |
58 | #error "Vmemmap: No space for nodes field in page flags" | |
59 | #endif | |
60 | #define NODES_WIDTH 0 | |
61 | #endif | |
62 | ||
63 | /* | |
64 | * We are going to use the flags for the page to node mapping if its in | |
65 | * there. This includes the case where there is no node, so it is implicit. | |
66 | */ | |
67 | #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0) | |
68 | #define NODE_NOT_IN_PAGE_FLAGS | |
69 | #endif | |
70 | ||
71 | #endif /* _LINUX_PAGE_FLAGS_LAYOUT */ |