brintos

brintos / linux-shallow public Read only

0
0
Text · 3.5 KiB · 7d79818 Raw
116 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef PAGE_FLAGS_LAYOUT_H3#define PAGE_FLAGS_LAYOUT_H4 5#include <linux/numa.h>6#include <generated/bounds.h>7 8/*9 * When a memory allocation must conform to specific limitations (such10 * as being suitable for DMA) the caller will pass in hints to the11 * allocator in the gfp_mask, in the zone modifier bits.  These bits12 * are used to select a priority ordered list of memory zones which13 * match the requested limits. See gfp_zone() in include/linux/gfp.h14 */15#if MAX_NR_ZONES < 216#define ZONES_SHIFT 017#elif MAX_NR_ZONES <= 218#define ZONES_SHIFT 119#elif MAX_NR_ZONES <= 420#define ZONES_SHIFT 221#elif MAX_NR_ZONES <= 822#define ZONES_SHIFT 323#else24#error ZONES_SHIFT "Too many zones configured"25#endif26 27#define ZONES_WIDTH		ZONES_SHIFT28 29#ifdef CONFIG_SPARSEMEM30#include <asm/sparsemem.h>31#define SECTIONS_SHIFT	(MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)32#else33#define SECTIONS_SHIFT	034#endif35 36#ifndef BUILD_VDSO32_6437/*38 * page->flags layout:39 *40 * There are five possibilities for how page->flags get laid out.  The first41 * pair is for the normal case without sparsemem. The second pair is for42 * 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 separate44 * 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_SHIFT54#else55#define SECTIONS_WIDTH		056#endif57 58#if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_SHIFT \59	<= BITS_PER_LONG - NR_PAGEFLAGS60#define NODES_WIDTH		NODES_SHIFT61#elif defined(CONFIG_SPARSEMEM_VMEMMAP)62#error "Vmemmap: No space for nodes field in page flags"63#else64#define NODES_WIDTH		065#endif66 67/*68 * Note that this #define MUST have a value so that it can be tested with69 * the IS_ENABLED() macro.70 */71#if NODES_SHIFT != 0 && NODES_WIDTH == 072#define NODE_NOT_IN_PAGE_FLAGS	173#endif74 75#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)76#define KASAN_TAG_WIDTH 877#else78#define KASAN_TAG_WIDTH 079#endif80 81#ifdef CONFIG_NUMA_BALANCING82#define LAST__PID_SHIFT 883#define LAST__PID_MASK  ((1 << LAST__PID_SHIFT)-1)84 85#define LAST__CPU_SHIFT NR_CPUS_BITS86#define LAST__CPU_MASK  ((1 << LAST__CPU_SHIFT)-1)87 88#define LAST_CPUPID_SHIFT (LAST__PID_SHIFT+LAST__CPU_SHIFT)89#else90#define LAST_CPUPID_SHIFT 091#endif92 93#if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \94	KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS95#define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT96#else97#define LAST_CPUPID_WIDTH 098#endif99 100#if LAST_CPUPID_SHIFT != 0 && LAST_CPUPID_WIDTH == 0101#define LAST_CPUPID_NOT_IN_PAGE_FLAGS102#endif103 104#if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \105	KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS106#error "Not enough bits in page flags"107#endif108 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#endif115#endif /* _LINUX_PAGE_FLAGS_LAYOUT */116