diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2013-02-22 19:34:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:17 -0500 |
commit | bbeae5b05ef6e40bf54db05ceb8635824153b9e2 (patch) | |
tree | 293d8b4e4bfc06367908df1915460905a5f8408b | |
parent | 3c0ff4689630b280704666833e9539d84cddc373 (diff) |
mm: move page flags layout to separate header
This is a preparation patch for moving page->_last_nid into page->flags
that moves page flag layout information to a separate header. This
patch is necessary because otherwise there would be a circular
dependency between mm_types.h and mm.h.
Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Simon Jeons <simon.jeons@gmail.com>
Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mm.h | 40 | ||||
-rw-r--r-- | include/linux/mm_types.h | 1 | ||||
-rw-r--r-- | include/linux/mmzone.h | 22 | ||||
-rw-r--r-- | include/linux/page-flags-layout.h | 71 |
4 files changed, 73 insertions, 61 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index a114b8eb7676..c2d7d5993b14 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -581,52 +581,12 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) | |||
581 | * sets it, so none of the operations on it need to be atomic. | 581 | * sets it, so none of the operations on it need to be atomic. |
582 | */ | 582 | */ |
583 | 583 | ||
584 | |||
585 | /* | ||
586 | * page->flags layout: | ||
587 | * | ||
588 | * There are three possibilities for how page->flags get | ||
589 | * laid out. The first is for the normal case, without | ||
590 | * sparsemem. The second is for sparsemem when there is | ||
591 | * plenty of space for node and section. The last is when | ||
592 | * we have run out of space and have to fall back to an | ||
593 | * alternate (slower) way of determining the node. | ||
594 | * | ||
595 | * No sparsemem or sparsemem vmemmap: | NODE | ZONE | ... | FLAGS | | ||
596 | * classic sparse with space for node:| SECTION | NODE | ZONE | ... | FLAGS | | ||
597 | * classic sparse no space for node: | SECTION | ZONE | ... | FLAGS | | ||
598 | */ | ||
599 | #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) | ||
600 | #define SECTIONS_WIDTH SECTIONS_SHIFT | ||
601 | #else | ||
602 | #define SECTIONS_WIDTH 0 | ||
603 | #endif | ||
604 | |||
605 | #define ZONES_WIDTH ZONES_SHIFT | ||
606 | |||
607 | #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS | ||
608 | #define NODES_WIDTH NODES_SHIFT | ||
609 | #else | ||
610 | #ifdef CONFIG_SPARSEMEM_VMEMMAP | ||
611 | #error "Vmemmap: No space for nodes field in page flags" | ||
612 | #endif | ||
613 | #define NODES_WIDTH 0 | ||
614 | #endif | ||
615 | |||
616 | /* Page flags: | [SECTION] | [NODE] | ZONE | ... | FLAGS | */ | 584 | /* Page flags: | [SECTION] | [NODE] | ZONE | ... | FLAGS | */ |
617 | #define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH) | 585 | #define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH) |
618 | #define NODES_PGOFF (SECTIONS_PGOFF - NODES_WIDTH) | 586 | #define NODES_PGOFF (SECTIONS_PGOFF - NODES_WIDTH) |
619 | #define ZONES_PGOFF (NODES_PGOFF - ZONES_WIDTH) | 587 | #define ZONES_PGOFF (NODES_PGOFF - ZONES_WIDTH) |
620 | 588 | ||
621 | /* | 589 | /* |
622 | * We are going to use the flags for the page to node mapping if its in | ||
623 | * there. This includes the case where there is no node, so it is implicit. | ||
624 | */ | ||
625 | #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0) | ||
626 | #define NODE_NOT_IN_PAGE_FLAGS | ||
627 | #endif | ||
628 | |||
629 | /* | ||
630 | * Define the bit shifts to access each section. For non-existent | 590 | * Define the bit shifts to access each section. For non-existent |
631 | * sections we define the shift as 0; that plus a 0 mask ensures | 591 | * sections we define the shift as 0; that plus a 0 mask ensures |
632 | * the compiler will optimise away reference to them. | 592 | * the compiler will optimise away reference to them. |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 47047cb4d8e5..d05d632c716e 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
13 | #include <linux/page-debug-flags.h> | 13 | #include <linux/page-debug-flags.h> |
14 | #include <linux/uprobes.h> | 14 | #include <linux/uprobes.h> |
15 | #include <linux/page-flags-layout.h> | ||
15 | #include <asm/page.h> | 16 | #include <asm/page.h> |
16 | #include <asm/mmu.h> | 17 | #include <asm/mmu.h> |
17 | 18 | ||
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 4f4c8c26fa9d..6c80d0ac14dd 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/seqlock.h> | 15 | #include <linux/seqlock.h> |
16 | #include <linux/nodemask.h> | 16 | #include <linux/nodemask.h> |
17 | #include <linux/pageblock-flags.h> | 17 | #include <linux/pageblock-flags.h> |
18 | #include <generated/bounds.h> | 18 | #include <linux/page-flags-layout.h> |
19 | #include <linux/atomic.h> | 19 | #include <linux/atomic.h> |
20 | #include <asm/page.h> | 20 | #include <asm/page.h> |
21 | 21 | ||
@@ -310,24 +310,6 @@ enum zone_type { | |||
310 | 310 | ||
311 | #ifndef __GENERATING_BOUNDS_H | 311 | #ifndef __GENERATING_BOUNDS_H |
312 | 312 | ||
313 | /* | ||
314 | * When a memory allocation must conform to specific limitations (such | ||
315 | * as being suitable for DMA) the caller will pass in hints to the | ||
316 | * allocator in the gfp_mask, in the zone modifier bits. These bits | ||
317 | * are used to select a priority ordered list of memory zones which | ||
318 | * match the requested limits. See gfp_zone() in include/linux/gfp.h | ||
319 | */ | ||
320 | |||
321 | #if MAX_NR_ZONES < 2 | ||
322 | #define ZONES_SHIFT 0 | ||
323 | #elif MAX_NR_ZONES <= 2 | ||
324 | #define ZONES_SHIFT 1 | ||
325 | #elif MAX_NR_ZONES <= 4 | ||
326 | #define ZONES_SHIFT 2 | ||
327 | #else | ||
328 | #error ZONES_SHIFT -- too many zones configured adjust calculation | ||
329 | #endif | ||
330 | |||
331 | struct zone { | 313 | struct zone { |
332 | /* Fields commonly accessed by the page allocator */ | 314 | /* Fields commonly accessed by the page allocator */ |
333 | 315 | ||
@@ -1055,8 +1037,6 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn) | |||
1055 | * PA_SECTION_SHIFT physical address to/from section number | 1037 | * PA_SECTION_SHIFT physical address to/from section number |
1056 | * PFN_SECTION_SHIFT pfn to/from section number | 1038 | * PFN_SECTION_SHIFT pfn to/from section number |
1057 | */ | 1039 | */ |
1058 | #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS) | ||
1059 | |||
1060 | #define PA_SECTION_SHIFT (SECTION_SIZE_BITS) | 1040 | #define PA_SECTION_SHIFT (SECTION_SIZE_BITS) |
1061 | #define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT) | 1041 | #define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT) |
1062 | 1042 | ||
diff --git a/include/linux/page-flags-layout.h b/include/linux/page-flags-layout.h new file mode 100644 index 000000000000..316805d6ba1b --- /dev/null +++ b/include/linux/page-flags-layout.h | |||
@@ -0,0 +1,71 @@ | |||
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 */ | ||