~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/page-flags-layout.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  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  * When a memory allocation must conform to specific limitations (such
 10  * as being suitable for DMA) the caller will pass in hints to the
 11  * allocator in the gfp_mask, in the zone modifier bits.  These bits
 12  * are used to select a priority ordered list of memory zones which
 13  * match the requested limits. See gfp_zone() in include/linux/gfp.h
 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"
 25 #endif
 26 
 27 #define ZONES_WIDTH             ZONES_SHIFT
 28 
 29 #ifdef CONFIG_SPARSEMEM
 30 #include <asm/sparsemem.h>
 31 #define SECTIONS_SHIFT  (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
 32 #else
 33 #define SECTIONS_SHIFT  0
 34 #endif
 35 
 36 #ifndef BUILD_VDSO32_64
 37 /*
 38  * page->flags layout:
 39  *
 40  * There are five possibilities for how page->flags get laid out.  The first
 41  * pair is for the normal case without sparsemem. The second pair is for
 42  * sparsemem when there is plenty of space for node and section information.
 43  * The last is when there is insufficient space in page->flags and a separate
 44  * lookup is necessary.
 45  *
 46  * No sparsemem or sparsemem vmemmap: |       NODE     | ZONE |             ... | FLAGS |
 47  *      " plus space for last_cpupid: |       NODE     | ZONE | LAST_CPUPID ... | FLAGS |
 48  * classic sparse with space for node:| SECTION | NODE | ZONE |             ... | FLAGS |
 49  *      " plus space for last_cpupid: | SECTION | NODE | ZONE | LAST_CPUPID ... | FLAGS |
 50  * classic sparse no space for node:  | SECTION |     ZONE    | ... | FLAGS |
 51  */
 52 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
 53 #define SECTIONS_WIDTH          SECTIONS_SHIFT
 54 #else
 55 #define SECTIONS_WIDTH          0
 56 #endif
 57 
 58 #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_SHIFT \
 59         <= BITS_PER_LONG - NR_PAGEFLAGS
 60 #define NODES_WIDTH             NODES_SHIFT
 61 #elif defined(CONFIG_SPARSEMEM_VMEMMAP)
 62 #error "Vmemmap: No space for nodes field in page flags"
 63 #else
 64 #define NODES_WIDTH             0
 65 #endif
 66 
 67 /*
 68  * Note that this #define MUST have a value so that it can be tested with
 69  * the IS_ENABLED() macro.
 70  */
 71 #if NODES_SHIFT != 0 && NODES_WIDTH == 0
 72 #define NODE_NOT_IN_PAGE_FLAGS  1
 73 #endif
 74 
 75 #if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
 76 #define KASAN_TAG_WIDTH 8
 77 #else
 78 #define KASAN_TAG_WIDTH 0
 79 #endif
 80 
 81 #ifdef CONFIG_NUMA_BALANCING
 82 #define LAST__PID_SHIFT 8
 83 #define LAST__PID_MASK  ((1 << LAST__PID_SHIFT)-1)
 84 
 85 #define LAST__CPU_SHIFT NR_CPUS_BITS
 86 #define LAST__CPU_MASK  ((1 << LAST__CPU_SHIFT)-1)
 87 
 88 #define LAST_CPUPID_SHIFT (LAST__PID_SHIFT+LAST__CPU_SHIFT)
 89 #else
 90 #define LAST_CPUPID_SHIFT 0
 91 #endif
 92 
 93 #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \
 94         KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
 95 #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT
 96 #else
 97 #define LAST_CPUPID_WIDTH 0
 98 #endif
 99 
100 #if LAST_CPUPID_SHIFT != 0 && LAST_CPUPID_WIDTH == 0
101 #define LAST_CPUPID_NOT_IN_PAGE_FLAGS
102 #endif
103 
104 #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \
105         KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
106 #error "Not enough bits in page flags"
107 #endif
108 
109 /* see the comment on MAX_NR_TIERS */
110 #define LRU_REFS_WIDTH  min(__LRU_REFS_WIDTH, BITS_PER_LONG - NR_PAGEFLAGS - \
111                             ZONES_WIDTH - LRU_GEN_WIDTH - SECTIONS_WIDTH - \
112                             NODES_WIDTH - KASAN_TAG_WIDTH - LAST_CPUPID_WIDTH)
113 
114 #endif
115 #endif /* _LINUX_PAGE_FLAGS_LAYOUT */
116 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php