Lines Matching +full:a +full:- +full:z

1 /* SPDX-License-Identifier: GPL-2.0 */
18 #include <linux/pageblock-flags.h>
19 #include <linux/page-flags-layout.h>
22 #include <linux/page-flags.h>
25 /* Free memory management - zoned buddy allocator. */
31 #define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1))
54 * The way to use it is to change migratetype of a range of
57 * is that a range of pageblocks must be aligned to
59 * a single pageblock.
91 #define MIGRATETYPE_MASK ((1UL << PB_migratetype_bits) - 1)
104 return list_first_entry_or_null(&area->free_list[migratetype], in get_page_from_free_area()
110 return list_empty(&area->free_list[migratetype]); in free_area_empty()
116 * zone->lock and the zone lru_lock are two of the hottest locks in the kernel.
117 * So add a wild amount of padding here to ensure that they fall into separate
119 * consumption is not a concern here.
203 NR_KERNEL_MISC_RECLAIMABLE, /* reclaimable non-slab kernel pages */
221 * Global and per-node slab counters track slab pages. in vmstat_item_in_bytes()
225 * Per-memcg and per-lruvec counters track memory, consumed in vmstat_item_in_bytes()
227 * byte-precise. in vmstat_item_in_bytes()
273 * backed by a congested BDI
280 * These track the cost of reclaiming one LRU - file or anon -
286 /* Non-resident age, driven by LRU movement */
314 #define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost) argument
315 #define low_wmark_pages(z) (z->_watermark[WMARK_LOW] + z->watermark_boost) argument
316 #define high_wmark_pages(z) (z->_watermark[WMARK_HIGH] + z->watermark_boost) argument
317 #define wmark_pages(z, i) (z->_watermark[i] + z->watermark_boost) argument
324 /* Lists of pages, one per migrate type stored on the pcp-lists */
353 * DMA addressing constraints. This distinction is important as a 32bit
354 * DMA mask is assumed when ZONE_DMA32 is defined. Some 64-bit
360 * - i386 and x86_64 have a fixed 16M ZONE_DMA and ZONE_DMA32 for the
363 * - arm only uses ZONE_DMA, the size, up to 4G, may vary depending on
366 * - arm64 has a fixed 1G ZONE_DMA and ZONE_DMA32 for the rest of the
369 * - powerpc only uses ZONE_DMA, the size, up to 2G, may vary
372 * - s390 uses ZONE_DMA fixed to the lower 2G.
374 * - ia64 and riscv only use ZONE_DMA32.
376 * - parisc uses neither.
392 * A memory area that is only addressable by the kernel through
405 * likely to succeed, and to locally limit unmovable allocations - e.g.,
408 * 1. Pinned pages: (long-term) pinning of movable pages might
410 * retry a long time.
422 * buddy (e.g., via XEN-balloon, Hyper-V balloon, virtio-mem). The
424 * some cases (virtio-mem), such pages can be skipped during
428 * of memory unplug in virtio-mem).
449 /* Read-mostly fields */
476 * Flags for a pageblock_nr_pages block. See pageblock-flags.h.
488 * spanned_pages = zone_end_pfn - zone_start_pfn;
492 * present_pages = spanned_pages - absent_pages(pages in holes);
497 * managed_pages = present_pages - reserved_pages;
501 * (present_pages - managed_pages). And managed_pages should be used
508 * It is a seqlock because it has to be read outside of zone->lock,
512 * The span_seq lock is declared along with zone->lock because it is
513 * frequently read in proximity to zone->lock. It's good to
514 * give them a chance of being in the same cacheline.
518 * present_pages should get_online_mems() to get a stable value.
530 * of pageblock. Protected by zone->lock.
542 /* Write-intensive fields used from the page allocator */
554 /* Write-intensive fields used by compaction and vmstats. */
559 * when reading the number of free pages to avoid per-cpu counter
617 return (unsigned long)atomic_long_read(&zone->managed_pages); in zone_managed_pages()
622 return zone->zone_start_pfn + zone->spanned_pages; in zone_end_pfn()
627 return zone->zone_start_pfn <= pfn && pfn < zone_end_pfn(zone); in zone_spans_pfn()
632 return zone->initialized; in zone_is_initialized()
637 return zone->spanned_pages == 0; in zone_is_empty()
641 * Return true if [start_pfn, start_pfn + nr_pages) range has a non-empty
650 start_pfn + nr_pages <= zone->zone_start_pfn) in zone_intersects()
658 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
663 /* Maximum number of zones on a zonelist */
671 * restrict the allocations to a single node for __GFP_THISNODE.
679 * This struct contains information about a zone in a zonelist. It is stored
684 int zone_idx; /* zone_idx(zoneref->zone) */
688 * One allocation request operates on a zonelist. A zonelist
689 * is a list of zones, the first one is the 'goal' of the
695 * a struct zoneref are
697 * zonelist_zone() - Return the struct zone * for an entry in _zonerefs
698 * zonelist_zone_idx() - Return the index of the zone for an entry
699 * zonelist_node_idx() - Return the index of the node for an entry
706 /* The array of struct pages - for discontigmem use pgdat->lmem_map */
719 * On NUMA machines, each NUMA node would have a pg_data_t to describe
720 * it's memory layout. On UMA machines there is a single pglist_data which
723 * Memory statistics and page replacement data structures are maintained on a
724 * per-zone basis.
752 * Also synchronizes pgdat->first_deferred_pfn during deferred page
759 * Nests above zone->lock and zone->span_seqlock
784 * This is a per-node reserve of pages that are not available
797 /* Write-intensive fields used by page reclaim */
826 /* Per-node vmstats */
831 #define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
832 #define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
834 #define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr))
836 #define pgdat_page_nr(pgdat, pagenr) pfn_to_page((pgdat)->node_start_pfn + (pagenr))
840 #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
845 return pgdat->node_start_pfn + pgdat->node_spanned_pages; in pgdat_end_pfn()
850 return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; in pgdat_is_empty()
858 bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
861 bool zone_watermark_ok(struct zone *z, unsigned int order,
864 bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
883 return lruvec->pgdat; in lruvec_pgdat()
900 #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)
903 * Returns true if a zone has pages managed by the buddy allocator.
913 /* Returns true if a zone has memory */
916 return zone->present_pages; in populated_zone()
922 return zone->node; in zone_to_nid()
927 zone->node = nid; in zone_set_nid()
946 return (ZONE_MOVABLE - 1) == ZONE_HIGHMEM; in zone_movable_is_highmem()
962 * is_highmem - helper function to quickly check if a struct zone is a
964 * to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum.
965 * @zone - pointer to struct zone variable
1015 * for_each_online_pgdat - helper macro to iterate over all online nodes
1016 * @pgdat - pointer to a pg_data_t variable
1023 * for_each_zone - helper macro to iterate over all memory zones
1024 * @zone - pointer to struct zone variable
1030 for (zone = (first_online_pgdat())->node_zones; \
1035 for (zone = (first_online_pgdat())->node_zones; \
1044 return zoneref->zone; in zonelist_zone()
1049 return zoneref->zone_idx; in zonelist_zone_idx()
1054 return zone_to_nid(zoneref->zone); in zonelist_node_idx()
1057 struct zoneref *__next_zones_zonelist(struct zoneref *z,
1062 …xt_zones_zonelist - Returns the next zone at or below highest_zoneidx within the allowed nodemask …
1063 * @z - The cursor used as a starting point for the search
1064 * @highest_zoneidx - The zone index of the highest zone to return
1065 * @nodes - An optional nodemask to filter the zonelist with
1067 * This function returns the next zone at or below a given zone index that is
1068 * within the allowed nodemask using a cursor as the starting point for the
1069 * search. The zoneref returned is a cursor that represents the current zone
1073 static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z, in next_zones_zonelist() argument
1077 if (likely(!nodes && zonelist_zone_idx(z) <= highest_zoneidx)) in next_zones_zonelist()
1078 return z; in next_zones_zonelist()
1079 return __next_zones_zonelist(z, highest_zoneidx, nodes); in next_zones_zonelist()
1083 …* first_zones_zonelist - Returns the first zone at or below highest_zoneidx within the allowed nod…
1084 * @zonelist - The zonelist to search for a suitable zone
1085 * @highest_zoneidx - The zone index of the highest zone to return
1086 * @nodes - An optional nodemask to filter the zonelist with
1087 * @return - Zoneref pointer for the first suitable zone found (see below)
1089 * This function returns the first zone at or below a given zone index that is
1090 * within the allowed nodemask. The zoneref returned is a cursor that can be
1094 * When no eligible zone is found, zoneref->zone is NULL (zoneref itself is
1102 return next_zones_zonelist(zonelist->_zonerefs, in first_zones_zonelist()
1107 …ch_zone_zonelist_nodemask - helper macro to iterate over valid zones in a zonelist at or below a g…
1108 * @zone - The current zone in the iterator
1109 * @z - The current pointer within zonelist->_zonerefs being iterated
1110 * @zlist - The zonelist being iterated
1111 * @highidx - The zone index of the highest zone to return
1112 * @nodemask - Nodemask allowed by the allocator
1114 * This iterator iterates though all zones at or below a given zone index and
1115 * within a given nodemask
1117 #define for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, nodemask) \ argument
1118 for (z = first_zones_zonelist(zlist, highidx, nodemask), zone = zonelist_zone(z); \
1120 z = next_zones_zonelist(++z, highidx, nodemask), \
1121 zone = zonelist_zone(z))
1123 #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \ argument
1124 for (zone = z->zone; \
1126 z = next_zones_zonelist(++z, highidx, nodemask), \
1127 zone = zonelist_zone(z))
1131 …* for_each_zone_zonelist - helper macro to iterate over valid zones in a zonelist at or below a gi…
1132 * @zone - The current zone in the iterator
1133 * @z - The current pointer within zonelist->zones being iterated
1134 * @zlist - The zonelist being iterated
1135 * @highidx - The zone index of the highest zone to return
1137 * This iterator iterates though all zones at or below a given zone index.
1139 #define for_each_zone_zonelist(zone, z, zlist, highidx) \ argument
1140 for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, NULL)
1153 * SECTION_SHIFT #bits space required to store a section #
1159 #define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)
1164 #define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1))
1167 ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS)
1169 #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
1182 #define SECTION_ALIGN_UP(pfn) (((pfn) + PAGES_PER_SECTION - 1) & PAGE_SECTION_MASK)
1188 #define PFN_SUBSECTION_SHIFT (SUBSECTION_SHIFT - PAGE_SHIFT)
1190 #define PAGE_SUBSECTION_MASK (~(PAGES_PER_SUBSECTION-1))
1195 #define SUBSECTIONS_PER_SECTION (1UL << (SECTION_SIZE_BITS - SUBSECTION_SHIFT))
1215 * This is, logically, a pointer to an array of struct
1223 * Making it a UL at least makes someone do a cast
1238 * WARNING: mem_section must be a power-of-2 in size for the
1251 #define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1)
1261 return ms->usage->pageblock_flags; in section_to_usemap()
1279 * a little bit of information. The pointer is calculated
1280 * as mem_map - section_nr_to_pfn(pnum). The result is
1282 * 1. All mem_map arrays are page-aligned.
1284 * lowest bits. PFN_SECTION_SHIFT is arch-specific
1285 * (equal SECTION_SIZE_BITS - PAGE_SHIFT), and the
1295 #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
1300 unsigned long map = section->section_mem_map; in __section_mem_map_addr()
1307 return (section && (section->section_mem_map & SECTION_MARKED_PRESENT)); in present_section()
1317 return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP)); in valid_section()
1322 return (section && (section->section_mem_map & SECTION_IS_EARLY)); in early_section()
1332 return (section && (section->section_mem_map & SECTION_IS_ONLINE)); in online_section()
1364 return test_bit(idx, ms->usage->subsection_map); in pfn_section_valid()
1385 * the entire section-sized span. in pfn_valid()
1405 return -1; in next_present_section_nr()
1443 * If it is possible to have holes within a MAX_ORDER_NR_PAGES, then we
1446 * when we have no holes within a MAX_ORDER_NR_PAGES block.
1456 * pfn_valid() is meant to be able to tell if a given PFN has valid memmap
1457 * associated with it or not. This means that a struct page exists for this
1465 * that a valid section has a memmap for the entire section.
1470 * returns true. A walker of the full memmap must then do this additional