1
2 #ifndef PAGE_FLAGS_LAYOUT_H
3 #define PAGE_FLAGS_LAYOUT_H
4
5 #include <linux/numa.h>
6 #include <generated/bounds.h>
7
8
9
10
11
12
13
14
15 #if MAX_NR_ZONES < 2
16 #define ZONES_SHIFT 0
17 #elif MAX_NR_ZONES <= 2
18 #define ZONES_SHIFT 1
19 #elif MAX_NR_ZONES <= 4
20 #define ZONES_SHIFT 2
21 #elif MAX_NR_ZONES <= 8
22 #define ZONES_SHIFT 3
23 #else
24 #error ZONES_SHIFT -- too many zones configured adjust calculation
25 #endif
26
27 #ifdef CONFIG_SPARSEMEM
28 #include <asm/sparsemem.h>
29
30
31 #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
32
33 #endif
34
35 #ifndef BUILD_VDSO32_64
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
52 #define SECTIONS_WIDTH SECTIONS_SHIFT
53 #else
54 #define SECTIONS_WIDTH 0
55 #endif
56
57 #define ZONES_WIDTH ZONES_SHIFT
58
59 #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
60 #define NODES_WIDTH NODES_SHIFT
61 #else
62 #ifdef CONFIG_SPARSEMEM_VMEMMAP
63 #error "Vmemmap: No space for nodes field in page flags"
64 #endif
65 #define NODES_WIDTH 0
66 #endif
67
68 #ifdef CONFIG_NUMA_BALANCING
69 #define LAST__PID_SHIFT 8
70 #define LAST__PID_MASK ((1 << LAST__PID_SHIFT)-1)
71
72 #define LAST__CPU_SHIFT NR_CPUS_BITS
73 #define LAST__CPU_MASK ((1 << LAST__CPU_SHIFT)-1)
74
75 #define LAST_CPUPID_SHIFT (LAST__PID_SHIFT+LAST__CPU_SHIFT)
76 #else
77 #define LAST_CPUPID_SHIFT 0
78 #endif
79
80 #ifdef CONFIG_KASAN_SW_TAGS
81 #define KASAN_TAG_WIDTH 8
82 #else
83 #define KASAN_TAG_WIDTH 0
84 #endif
85
86 #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT+KASAN_TAG_WIDTH \
87 <= BITS_PER_LONG - NR_PAGEFLAGS
88 #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT
89 #else
90 #define LAST_CPUPID_WIDTH 0
91 #endif
92
93 #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH+LAST_CPUPID_WIDTH+KASAN_TAG_WIDTH \
94 > BITS_PER_LONG - NR_PAGEFLAGS
95 #error "Not enough bits in page flags"
96 #endif
97
98
99
100
101
102 #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0)
103 #define NODE_NOT_IN_PAGE_FLAGS
104 #endif
105
106 #if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0
107 #define LAST_CPUPID_NOT_IN_PAGE_FLAGS
108 #endif
109
110 #endif
111 #endif