Skip to content

Commit bbeae5b

Browse files
Peter Zijlstratorvalds
authored andcommitted
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 <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Simon Jeons <[email protected]> Cc: Wanpeng Li <[email protected]> Cc: Hugh Dickins <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3c0ff46 commit bbeae5b

File tree

4 files changed

+73
-61
lines changed

4 files changed

+73
-61
lines changed

include/linux/mm.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -581,51 +581,11 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
581581
* sets it, so none of the operations on it need to be atomic.
582582
*/
583583

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-
616584
/* Page flags: | [SECTION] | [NODE] | ZONE | ... | FLAGS | */
617585
#define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
618586
#define NODES_PGOFF (SECTIONS_PGOFF - NODES_WIDTH)
619587
#define ZONES_PGOFF (NODES_PGOFF - ZONES_WIDTH)
620588

621-
/*
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-
629589
/*
630590
* Define the bit shifts to access each section. For non-existent
631591
* sections we define the shift as 0; that plus a 0 mask ensures

include/linux/mm_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/cpumask.h>
1313
#include <linux/page-debug-flags.h>
1414
#include <linux/uprobes.h>
15+
#include <linux/page-flags-layout.h>
1516
#include <asm/page.h>
1617
#include <asm/mmu.h>
1718

include/linux/mmzone.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/seqlock.h>
1616
#include <linux/nodemask.h>
1717
#include <linux/pageblock-flags.h>
18-
#include <generated/bounds.h>
18+
#include <linux/page-flags-layout.h>
1919
#include <linux/atomic.h>
2020
#include <asm/page.h>
2121

@@ -310,24 +310,6 @@ enum zone_type {
310310

311311
#ifndef __GENERATING_BOUNDS_H
312312

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-
331313
struct zone {
332314
/* Fields commonly accessed by the page allocator */
333315

@@ -1055,8 +1037,6 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
10551037
* PA_SECTION_SHIFT physical address to/from section number
10561038
* PFN_SECTION_SHIFT pfn to/from section number
10571039
*/
1058-
#define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
1059-
10601040
#define PA_SECTION_SHIFT (SECTION_SIZE_BITS)
10611041
#define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)
10621042

include/linux/page-flags-layout.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */

0 commit comments

Comments
 (0)