Lines Matching full:memory
3 * Procedures for maintaining information about logical memory blocks.
47 * Memblock is a method of managing memory regions during the early
48 * boot period when the usual kernel memory allocators are not up and
51 * Memblock views the system memory as collections of contiguous
54 * * ``memory`` - describes the physical memory available to the
55 * kernel; this may differ from the actual physical memory installed
56 * in the system, for instance when the memory is restricted with
59 * * ``physmem`` - describes the actual physical memory available during
60 * boot regardless of the possible restrictions and memory hot(un)plug;
65 * systems. Every memory type is described by the struct memblock_type
66 * which contains an array of memory regions along with
67 * the allocator metadata. The "memory" and "reserved" types are nicely
70 * %INIT_MEMBLOCK_MEMORY_REGIONS for "memory" and
75 * with care so that memory allocated for the region array will not
79 * memory layout is by using memblock_add() or memblock_add_node()
86 * Once memblock is setup the memory can be allocated using one of the
90 * address of the allocated memory
92 * of the allocated memory.
95 * memory ranges and the fallback methods. Consult the documentation
100 * function frees all the memory to the buddy page allocator.
131 .memory.regions = memblock_memory_init_regions,
132 .memory.max = INIT_MEMBLOCK_MEMORY_REGIONS,
133 .memory.name = "memory",
152 * keep a pointer to &memblock.memory in the text section to use it in
157 static __refdata struct memblock_type *memblock_memory = &memblock.memory;
183 /* skip non-scratch memory for kho early boot allocations */
228 * @flags: pick from blocks based on memory attributes
263 * @flags: pick from blocks based on memory attributes
302 * @flags: pick from blocks based on memory attributes
356 pr_warn_ratelimited("Could not allocate %pap bytes of mirrored memory\n",
384 * memblock_discard - discard memory and reserved arrays if they were allocated
401 if (memblock.memory.regions != memblock_memory_init_regions) {
402 addr = memblock.memory.regions;
404 memblock.memory.max);
418 * @new_area_start: starting address of memory range to avoid overlap with
419 * @new_area_size: size of memory range to avoid overlap with
422 * allocate memory for a new reserved regions array and there is a previously
423 * allocated memory range [@new_area_start, @new_area_start + @new_area_size]
424 * waiting to be reserved, ensure the memory used by the new array does
441 * of memory that aren't suitable for allocation
457 if (type == &memblock.memory)
480 /* The memory may not have been accepted, yet. */
724 * Add new memblock region [@base, @base + @size) to the "memory"
738 return memblock_add_range(&memblock.memory, base, size, nid, flags);
746 * Add new memblock region [@base, @base + @size) to the "memory"
759 return memblock_add_range(&memblock.memory, base, size, MAX_NUMNODES, 0);
763 * memblock_validate_numa_coverage - check if amount of memory with
765 * @threshold_bytes: maximal memory size that can have unassigned node
768 * A buggy firmware may report memory that does not belong to any node.
769 * Check if amount of such memory is below @threshold_bytes.
895 return memblock_remove_range(&memblock.memory, base, size);
904 WARN(1, "Cannot free reserved memory because of deferred initialization of the memory map");
920 * Perform a kasan-unchecked memset() since this memory
960 pr_info("Freeing %s memory: %ldK\n", s, K(pages));
966 * memblock_free - free boot memory allocation
967 * @ptr: starting address of the boot memory allocation
968 * @size: size of the boot memory block in bytes
970 * Free boot memory block previously allocated by memblock_alloc_xx() API.
971 * If called after the buddy allocator is available, the memory is released to
981 * memblock_phys_free - free boot memory block
982 * @base: phys starting address of the boot memory block
983 * @size: size of the boot memory block in bytes
985 * Free boot memory block previously allocated by memblock_phys_alloc_xx() API.
986 * If called after the buddy allocator is available, the memory is released to
1032 * memblock_setclr_flag - set or clear flag for a memory region
1066 * memblock_mark_hotplug - Mark hotpluggable memory with flag MEMBLOCK_HOTPLUG.
1074 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_HOTPLUG);
1086 return memblock_setclr_flag(&memblock.memory, base, size, 0, MEMBLOCK_HOTPLUG);
1090 * memblock_mark_mirror - Mark mirrored memory with flag MEMBLOCK_MIRROR.
1103 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_MIRROR);
1107 * memblock_mark_nomap - Mark a memory region with flag MEMBLOCK_NOMAP.
1111 * The memory regions marked with %MEMBLOCK_NOMAP will not be added to the
1112 * direct mapping of the physical memory. These regions will still be
1113 * covered by the memory map. The struct page representing NOMAP memory
1114 * frames in the memory map will be PageReserved()
1116 * Note: if the memory being marked %MEMBLOCK_NOMAP was allocated from
1117 * memblock, the caller must inform kmemleak to ignore that memory
1123 return memblock_setclr_flag(&memblock.memory, base, size, 1, MEMBLOCK_NOMAP);
1135 return memblock_setclr_flag(&memblock.memory, base, size, 0, MEMBLOCK_NOMAP);
1139 * memblock_reserved_mark_noinit - Mark a reserved memory region with flag
1164 * memblock_reserved_mark_kern - Mark a reserved memory region with flag
1179 * memblock_mark_kho_scratch - Mark a memory region as MEMBLOCK_KHO_SCRATCH.
1183 * Only memory regions marked with %MEMBLOCK_KHO_SCRATCH will be considered
1190 return memblock_setclr_flag(&memblock.memory, base, size, 1,
1204 return memblock_setclr_flag(&memblock.memory, base, size, 0,
1218 /* only memory regions are associated with nodes, check it */
1222 /* skip hotpluggable memory regions if needed */
1227 /* if we want mirror memory skip non-mirror memory regions */
1231 /* skip nomap memory unless we were asked for it explicitly */
1235 /* skip driver-managed memory unless we were asked for it explicitly */
1253 * @flags: pick from blocks based on memory attributes
1255 * @type_b: pointer to memblock_type which excludes memory from being taken
1354 * @flags: pick from blocks based on memory attributes
1356 * @type_b: pointer to memblock_type which excludes memory from being taken
1451 struct memblock_type *type = &memblock.memory;
1510 * memblock_alloc_range_nid - allocate boot memory block
1511 * @size: size of memory block to be allocated in bytes
1513 * @start: the lower bound of the memory region to allocate (phys address)
1514 * @end: the upper bound of the memory region to allocate (phys address)
1518 * The allocation is performed from memory region limited by
1521 * If the specified node can not hold the requested memory and @exact_nid
1524 * For systems with memory mirroring, the allocation is attempted first
1526 * memory region.
1529 * memory block, it is never reported as leaks.
1532 * Physical address of allocated memory block on success, %0 on failure.
1575 pr_warn_ratelimited("Could not allocate %pap bytes of mirrored memory\n",
1598 * require memory to be accepted before it can be used by the
1601 * Accept the memory of the allocated buffer.
1609 * memblock_phys_alloc_range - allocate a memory block inside specified range
1610 * @size: size of memory block to be allocated in bytes
1612 * @start: the lower bound of the memory region to allocate (physical address)
1613 * @end: the upper bound of the memory region to allocate (physical address)
1617 * Return: physical address of the allocated memory block on success,
1633 * memblock_phys_alloc_try_nid - allocate a memory block from specified NUMA node
1634 * @size: size of memory block to be allocated in bytes
1638 * Allocates memory block from the specified NUMA node. If the node
1639 * has no available memory, attempts to allocated from any node in the
1642 * Return: physical address of the allocated memory block on success,
1652 * memblock_alloc_internal - allocate boot memory block
1653 * @size: size of memory block to be allocated in bytes
1655 * @min_addr: the lower bound of the memory region to allocate (phys address)
1656 * @max_addr: the upper bound of the memory region to allocate (phys address)
1660 * Allocates memory block using memblock_alloc_range_nid() and
1664 * will fall back to memory below @min_addr. Other constraints, such
1665 * as node and mirrored memory will be handled again in
1669 * Virtual address of allocated memory block on success, NULL on failure.
1697 * memblock_alloc_exact_nid_raw - allocate boot memory block on the exact node
1698 * without zeroing memory
1699 * @size: size of memory block to be allocated in bytes
1701 * @min_addr: the lower bound of the memory region from where the allocation
1703 * @max_addr: the upper bound of the memory region from where the allocation
1705 * allocate only from memory limited by memblock.current_limit value
1709 * info), if enabled. Does not zero allocated memory.
1712 * Virtual address of allocated memory block on success, NULL on failure.
1728 * memblock_alloc_try_nid_raw - allocate boot memory block without zeroing
1729 * memory and without panicking
1730 * @size: size of memory block to be allocated in bytes
1732 * @min_addr: the lower bound of the memory region from where the allocation
1734 * @max_addr: the upper bound of the memory region from where the allocation
1736 * allocate only from memory limited by memblock.current_limit value
1740 * info), if enabled. Does not zero allocated memory, does not panic if request
1744 * Virtual address of allocated memory block on success, NULL on failure.
1760 * memblock_alloc_try_nid - allocate boot memory block
1761 * @size: size of memory block to be allocated in bytes
1763 * @min_addr: the lower bound of the memory region from where the allocation
1765 * @max_addr: the upper bound of the memory region from where the allocation
1767 * allocate only from memory limited by memblock.current_limit value
1771 * info), if enabled. This function zeroes the allocated memory.
1774 * Virtual address of allocated memory block on success, NULL on failure.
1795 * __memblock_alloc_or_panic - Try to allocate memory and panic on failure
1796 * @size: size of memory block to be allocated in bytes
1800 * This function attempts to allocate memory using memblock_alloc,
1820 return memblock.memory.total_size;
1871 return memblock.memory.regions[0].base;
1876 int idx = memblock.memory.cnt - 1;
1878 return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size);
1887 * translate the memory @limit size into the max address within one of
1888 * the memory memblock regions, if the @limit exceeds the total size
1911 /* @limit exceeds the total size of the memory, do nothing */
1915 /* truncate both memory and reserved regions */
1916 memblock_remove_range(&memblock.memory, max_addr,
1931 pr_warn("%s: No memory registered yet\n", __func__);
1935 ret = memblock_isolate_range(&memblock.memory, base, size,
1941 for (i = memblock.memory.cnt - 1; i >= end_rgn; i--)
1942 if (!memblock_is_nomap(&memblock.memory.regions[i]))
1943 memblock_remove_region(&memblock.memory, i);
1946 if (!memblock_is_nomap(&memblock.memory.regions[i]))
1947 memblock_remove_region(&memblock.memory, i);
1964 /* @limit exceeds the total size of the memory, do nothing */
1996 return memblock_search(&memblock.memory, addr) != -1;
2001 int i = memblock_search(&memblock.memory, addr);
2005 return !memblock_is_nomap(&memblock.memory.regions[i]);
2011 struct memblock_type *type = &memblock.memory;
2024 * memblock_is_region_memory - check if a region is a subset of memory
2028 * Check if the region [@base, @base + @size) is a subset of a memory block.
2035 int idx = memblock_search(&memblock.memory, base);
2040 return (memblock.memory.regions[idx].base +
2041 memblock.memory.regions[idx].size) >= end;
2045 * memblock_is_region_reserved - check if a region intersects reserved memory
2050 * memory block.
2078 memblock_remove_region(&memblock.memory,
2079 r - memblock.memory.regions);
2124 pr_info(" memory size = %pa reserved size = %pa\n",
2125 &memblock.memory.total_size,
2128 memblock_dump(&memblock.memory);
2181 * The mem_map array can get very big. Free the unused area of the memory map.
2206 * presume that there are no holes in the memory map inside
2220 * presume that there are no holes in the memory map inside
2411 /* Keep a table to reserve named memory */
2451 * reserve_mem_find_by_name - Find reserved memory region with a given name
2452 * @name: The name that is attached to a reserved memory region
2476 * reserve_mem_release_by_name - Release reserved memory region with a given name
2477 * @name: The name that is attached to a reserved memory region
2479 * Forcibly release the pages in the reserved memory region so that those memory
2480 * can be used as free memory. After released the reserved region size becomes 0.
2517 int i = memblock_search(&memblock.memory, addr);
2522 return memblock_is_kho_scratch(&memblock.memory.regions[i]);
2703 pr_info("Revived memory reservation '%s' from KHO\n", name);
2728 /* Check if there's room for more reserved memory */
2730 pr_err("reserve_mem: no more room for reserved memory\n");
2844 debugfs_create_file("memory", 0444, root,
2845 &memblock.memory, &memblock_debug_fops);