Lines Matching full:memory

3  * Procedures for maintaining information about logical memory blocks.
46 * Memblock is a method of managing memory regions during the early
47 * boot period when the usual kernel memory allocators are not up and
50 * Memblock views the system memory as collections of contiguous
53 * * ``memory`` - describes the physical memory available to the
54 * kernel; this may differ from the actual physical memory installed
55 * in the system, for instance when the memory is restricted with
58 * * ``physmem`` - describes the actual physical memory available during
59 * boot regardless of the possible restrictions and memory hot(un)plug;
64 * systems. Every memory type is described by the struct memblock_type
65 * which contains an array of memory regions along with
66 * the allocator metadata. The "memory" and "reserved" types are nicely
69 * %INIT_MEMBLOCK_MEMORY_REGIONS for "memory" and
74 * with care so that memory allocated for the region array will not
78 * memory layout is by using memblock_add() or memblock_add_node()
85 * Once memblock is setup the memory can be allocated using one of the
89 * address of the allocated memory
91 * of the allocated memory.
94 * memory ranges and the fallback methods. Consult the documentation
99 * function frees all the memory to the buddy page allocator.
130 .memory.regions = memblock_memory_init_regions,
131 .memory.max = INIT_MEMBLOCK_MEMORY_REGIONS,
132 .memory.name = "memory",
151 * keep a pointer to &memblock.memory in the text section to use it in
156 static __refdata struct memblock_type *memblock_memory = &memblock.memory;
182 /* skip non-scratch memory for kho early boot allocations */ in choose_memblock_flags()
227 * @flags: pick from blocks based on memory attributes
262 * @flags: pick from blocks based on memory attributes
301 * @flags: pick from blocks based on memory attributes
355 pr_warn_ratelimited("Could not allocate %pap bytes of mirrored memory\n", in memblock_find_in_range()
383 * memblock_discard - discard memory and reserved arrays if they were allocated
400 if (memblock.memory.regions != memblock_memory_init_regions) { in memblock_discard()
401 addr = memblock.memory.regions; in memblock_discard()
403 memblock.memory.max); in memblock_discard()
417 * @new_area_start: starting address of memory range to avoid overlap with
418 * @new_area_size: size of memory range to avoid overlap with
421 * allocate memory for a new reserved regions array and there is a previously
422 * allocated memory range [@new_area_start, @new_area_start + @new_area_size]
423 * waiting to be reserved, ensure the memory used by the new array does
440 * of memory that aren't suitable for allocation in memblock_double_array()
456 if (type == &memblock.memory) in memblock_double_array()
479 /* The memory may not have been accepted, yet. */ in memblock_double_array()
723 * Add new memblock region [@base, @base + @size) to the "memory"
737 return memblock_add_range(&memblock.memory, base, size, nid, flags); in memblock_add_node()
745 * Add new memblock region [@base, @base + @size) to the "memory"
758 return memblock_add_range(&memblock.memory, base, size, MAX_NUMNODES, 0); in memblock_add()
762 * memblock_validate_numa_coverage - check if amount of memory with
764 * @threshold_bytes: maximal memory size that can have unassigned node
767 * A buggy firmware may report memory that does not belong to any node.
768 * Check if amount of such memory is below @threshold_bytes.
894 return memblock_remove_range(&memblock.memory, base, size); in memblock_remove()
903 WARN(1, "Cannot free reserved memory because of deferred initialization of the memory map"); in __free_reserved_area()
919 * Perform a kasan-unchecked memset() since this memory in __free_reserved_area()
959 pr_info("Freeing %s memory: %ldK\n", s, K(pages)); in free_reserved_area()
965 * memblock_free - free boot memory allocation
966 * @ptr: starting address of the boot memory allocation
967 * @size: size of the boot memory block in bytes
969 * Free boot memory block previously allocated by memblock_alloc_xx() API.
970 * If called after the buddy allocator is available, the memory is released to
980 * memblock_phys_free - free boot memory block
981 * @base: phys starting address of the boot memory block
982 * @size: size of the boot memory block in bytes
984 * Free boot memory block previously allocated by memblock_phys_alloc_xx() API.
985 * If called after the buddy allocator is available, the memory is released to
1031 * memblock_setclr_flag - set or clear flag for a memory region
1065 * memblock_mark_hotplug - Mark hotpluggable memory with flag MEMBLOCK_HOTPLUG.
1073 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_HOTPLUG); in memblock_mark_hotplug()
1085 return memblock_setclr_flag(&memblock.memory, base, size, 0, MEMBLOCK_HOTPLUG); in memblock_clear_hotplug()
1089 * memblock_mark_mirror - Mark mirrored memory with flag MEMBLOCK_MIRROR.
1102 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_MIRROR); in memblock_mark_mirror()
1106 * memblock_mark_nomap - Mark a memory region with flag MEMBLOCK_NOMAP.
1110 * The memory regions marked with %MEMBLOCK_NOMAP will not be added to the
1111 * direct mapping of the physical memory. These regions will still be
1112 * covered by the memory map. The struct page representing NOMAP memory
1113 * frames in the memory map will be PageReserved()
1115 * Note: if the memory being marked %MEMBLOCK_NOMAP was allocated from
1116 * memblock, the caller must inform kmemleak to ignore that memory
1122 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_NOMAP); in memblock_mark_nomap()
1134 return memblock_setclr_flag(&memblock.memory, base, size, 0, MEMBLOCK_NOMAP); in memblock_clear_nomap()
1138 * memblock_reserved_mark_noinit - Mark a reserved memory region with flag
1163 * memblock_reserved_mark_kern - Mark a reserved memory region with flag
1178 * memblock_mark_kho_scratch - Mark a memory region as MEMBLOCK_KHO_SCRATCH.
1182 * Only memory regions marked with %MEMBLOCK_KHO_SCRATCH will be considered
1189 return memblock_setclr_flag(&memblock.memory, base, size, 1, in memblock_mark_kho_scratch()
1203 return memblock_setclr_flag(&memblock.memory, base, size, 0, in memblock_clear_kho_scratch()
1217 /* only memory regions are associated with nodes, check it */ in should_skip_region()
1221 /* skip hotpluggable memory regions if needed */ in should_skip_region()
1226 /* if we want mirror memory skip non-mirror memory regions */ in should_skip_region()
1230 /* skip nomap memory unless we were asked for it explicitly */ in should_skip_region()
1234 /* skip driver-managed memory unless we were asked for it explicitly */ in should_skip_region()
1252 * @flags: pick from blocks based on memory attributes
1254 * @type_b: pointer to memblock_type which excludes memory from being taken
1353 * @flags: pick from blocks based on memory attributes
1355 * @type_b: pointer to memblock_type which excludes memory from being taken
1450 struct memblock_type *type = &memblock.memory; in __next_mem_pfn_range()
1526 * require memory to be accepted before it can be used by the in memblock_prep_allocation()
1529 * Accept the memory of the allocated buffer. in memblock_prep_allocation()
1535 * memblock_alloc_range_nid - allocate boot memory block
1536 * @size: size of memory block to be allocated in bytes
1538 * @start: the lower bound of the memory region to allocate (phys address)
1539 * @end: the upper bound of the memory region to allocate (phys address)
1543 * The allocation is performed from memory region limited by
1546 * If the specified node can not hold the requested memory and @exact_nid
1549 * For systems with memory mirroring, the allocation is attempted first
1551 * memory region.
1554 * memory block, it is never reported as leaks.
1557 * Physical address of allocated memory block on success, %0 on failure.
1600 pr_warn_ratelimited("Could not allocate %pap bytes of mirrored memory\n", in memblock_alloc_range_nid()
1613 * memblock_phys_alloc_range - allocate a memory block inside specified range
1614 * @size: size of memory block to be allocated in bytes
1616 * @start: the lower bound of the memory region to allocate (physical address)
1617 * @end: the upper bound of the memory region to allocate (physical address)
1621 * Return: physical address of the allocated memory block on success,
1637 * memblock_phys_alloc_try_nid - allocate a memory block from specified NUMA node
1638 * @size: size of memory block to be allocated in bytes
1642 * Allocates memory block from the specified NUMA node. If the node
1643 * has no available memory, attempts to allocated from any node in the
1646 * Return: physical address of the allocated memory block on success,
1656 * memblock_alloc_internal - allocate boot memory block
1657 * @size: size of memory block to be allocated in bytes
1659 * @min_addr: the lower bound of the memory region to allocate (phys address)
1660 * @max_addr: the upper bound of the memory region to allocate (phys address)
1664 * Allocates memory block using memblock_alloc_range_nid() and
1668 * will fall back to memory below @min_addr. Other constraints, such
1669 * as node and mirrored memory will be handled again in
1673 * Virtual address of allocated memory block on success, NULL on failure.
1701 * memblock_alloc_exact_nid_raw - allocate boot memory block on the exact node
1702 * without zeroing memory
1703 * @size: size of memory block to be allocated in bytes
1705 * @min_addr: the lower bound of the memory region from where the allocation
1707 * @max_addr: the upper bound of the memory region from where the allocation
1709 * allocate only from memory limited by memblock.current_limit value
1713 * info), if enabled. Does not zero allocated memory.
1716 * Virtual address of allocated memory block on success, NULL on failure.
1732 * memblock_alloc_try_nid_raw - allocate boot memory block without zeroing
1733 * memory and without panicking
1734 * @size: size of memory block to be allocated in bytes
1736 * @min_addr: the lower bound of the memory region from where the allocation
1738 * @max_addr: the upper bound of the memory region from where the allocation
1740 * allocate only from memory limited by memblock.current_limit value
1744 * info), if enabled. Does not zero allocated memory, does not panic if request
1748 * Virtual address of allocated memory block on success, NULL on failure.
1764 * memblock_alloc_hugetlb - allocate boot memory for HugeTLB pages
1765 * @size: size of the memory to be allocated in bytes
1766 * @nid: nid of the free memory to find, %NUMA_NO_NODE for any node
1771 * @size. Since the memory is for userspace, mirrored memory is not used. The
1772 * memory is not zeroed. Does not panic if request cannot be satisfied.
1775 * Virtual address of allocated memory block on success, %NULL on failure.
1785 /* Don't waste mirrored memory on HugeTLB pages. */ in memblock_alloc_hugetlb()
1812 * HugeTLB pages can be preserved with KHO and no preserved memory can in memblock_alloc_hugetlb()
1835 * memblock_alloc_try_nid - allocate boot memory block
1836 * @size: size of memory block to be allocated in bytes
1838 * @min_addr: the lower bound of the memory region from where the allocation
1840 * @max_addr: the upper bound of the memory region from where the allocation
1842 * allocate only from memory limited by memblock.current_limit value
1846 * info), if enabled. This function zeroes the allocated memory.
1849 * Virtual address of allocated memory block on success, NULL on failure.
1870 * __memblock_alloc_or_panic - Try to allocate memory and panic on failure
1871 * @size: size of memory block to be allocated in bytes
1875 * This function attempts to allocate memory using memblock_alloc,
1895 return memblock.memory.total_size; in memblock_phys_mem_size()
1968 return memblock.memory.regions[0].base; in memblock_start_of_DRAM()
1973 int idx = memblock.memory.cnt - 1; in memblock_end_of_DRAM()
1975 return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); in memblock_end_of_DRAM()
1984 * translate the memory @limit size into the max address within one of in __find_max_addr()
1985 * the memory memblock regions, if the @limit exceeds the total size in __find_max_addr()
2008 /* @limit exceeds the total size of the memory, do nothing */ in memblock_enforce_memory_limit()
2012 /* truncate both memory and reserved regions */ in memblock_enforce_memory_limit()
2013 memblock_remove_range(&memblock.memory, max_addr, in memblock_enforce_memory_limit()
2028 pr_warn("%s: No memory registered yet\n", __func__); in memblock_cap_memory_range()
2032 ret = memblock_isolate_range(&memblock.memory, base, size, in memblock_cap_memory_range()
2038 for (i = memblock.memory.cnt - 1; i >= end_rgn; i--) in memblock_cap_memory_range()
2039 if (!memblock_is_nomap(&memblock.memory.regions[i])) in memblock_cap_memory_range()
2040 memblock_remove_region(&memblock.memory, i); in memblock_cap_memory_range()
2043 if (!memblock_is_nomap(&memblock.memory.regions[i])) in memblock_cap_memory_range()
2044 memblock_remove_region(&memblock.memory, i); in memblock_cap_memory_range()
2061 /* @limit exceeds the total size of the memory, do nothing */ in memblock_mem_limit_remove_map()
2093 return memblock_search(&memblock.memory, addr) != -1; in memblock_is_memory()
2098 int i = memblock_search(&memblock.memory, addr); in memblock_is_map_memory()
2102 return !memblock_is_nomap(&memblock.memory.regions[i]); in memblock_is_map_memory()
2108 struct memblock_type *type = &memblock.memory; in memblock_search_pfn_nid()
2121 * memblock_is_region_memory - check if a region is a subset of memory
2125 * Check if the region [@base, @base + @size) is a subset of a memory block.
2132 int idx = memblock_search(&memblock.memory, base); in memblock_is_region_memory()
2137 return (memblock.memory.regions[idx].base + in memblock_is_region_memory()
2138 memblock.memory.regions[idx].size) >= end; in memblock_is_region_memory()
2142 * memblock_is_region_reserved - check if a region intersects reserved memory
2147 * memory block.
2175 memblock_remove_region(&memblock.memory, in memblock_trim_memory()
2176 r - memblock.memory.regions); in memblock_trim_memory()
2221 pr_info(" memory size = %pa reserved size = %pa\n", in __memblock_dump_all()
2222 &memblock.memory.total_size, in __memblock_dump_all()
2225 memblock_dump(&memblock.memory); in __memblock_dump_all()
2278 * The mem_map array can get very big. Free the unused area of the memory map.
2303 * presume that there are no holes in the memory map inside in free_unused_memmap()
2317 * presume that there are no holes in the memory map inside in free_unused_memmap()
2506 /* Keep a table to reserve named memory */
2546 * reserve_mem_find_by_name - Find reserved memory region with a given name
2547 * @name: The name that is attached to a reserved memory region
2571 * reserve_mem_release_by_name - Release reserved memory region with a given name
2572 * @name: The name that is attached to a reserved memory region
2574 * Forcibly release the pages in the reserved memory region so that those memory
2575 * can be used as free memory. After released the reserved region size becomes 0.
2788 pr_info("Revived memory reservation '%s' from KHO\n", name); in reserve_mem_kho_revive()
2813 /* Check if there's room for more reserved memory */ in reserve_mem()
2815 pr_err("reserve_mem: no more room for reserved memory\n"); in reserve_mem()
2934 debugfs_create_file("memory", 0444, root, in memblock_debugfs_expose_arrays()
2935 &memblock.memory, &memblock_debug_fops); in memblock_debugfs_expose_arrays()