mm/memblock: Excluded memory
v4 cover mm/memblock: Excluded memory
Here is a new version of the memblock.nomap patch.
This time without the first patch (that has already been taken by akpm).
The second patch is now split into the functional part (Add support...) and the cleanup/refactoring part. This has been done for clarity as announced before.
Philipp Hachtmann (2):
mm/memblock: Add support for excluded memory areas mm/memblock: Cleanup and refactoring after addition of nomap
include/linux/memblock.h | 57 +++++++++--- mm/Kconfig | 3 + mm/memblock.c | 233 +++++++++++++++++++++++++++++++++++------------ mm/nobootmem.c | 9 ++ 4 files changed, 231 insertions(+), 71 deletions(-)
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v4 1/2 mm/memblock: Add support for excluded memory areas
Add a new memory state "nomap" to memblock. This can be used to truncate the usable memory in the system without forgetting about what is really installed.
--- include/linux/memblock.h | 25 +++++++ mm/Kconfig | 3 + mm/memblock.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++- mm/nobootmem.c | 9 +++ 4 files changed, 211 insertions(+), 1 deletion(-)
include/linux/memblock.h +25 -0
@@ -18,6 +18,7 @@#include <linux/mm.h> #define INIT_MEMBLOCK_REGIONS 128 +#define INIT_MEMBLOCK_NOMAP_REGIONS 4/* Definition of memblock flags. */ #define MEMBLOCK_HOTPLUG 0x1/* hotpluggable region */
@@ -43,6 +44,9 @@ struct memblock {phys_addr_t current_limit;struct memblock_type memory;struct memblock_type reserved; +#ifdef CONFIG_ARCH_MEMBLOCK_NOMAP +struct memblock_type nomap; +#endif };extern struct memblock memblock;
@@ -68,6 +72,10 @@ int memblock_add(phys_addr_t base, phys_addr_t size);int memblock_remove (phys_addr_t base,phys_addr_t size);int memblock_free (phys_addr_t base,phys_addr_t size);int memblock_reserve (phys_addr_t base,phys_addr_t size); +#ifdef CONFIG_ARCH_MEMBLOCK_NOMAP +int memblock_nomap (phys_addr_t base,phys_addr_t size); +int memblock_remap (phys_addr_t base,phys_addr_t size); +#endif void memblock_trim_memory (phys_addr_t align);int memblock_mark_hotplug (phys_addr_t base,phys_addr_t size);int memblock_clear_hotplug (phys_addr_t base,phys_addr_t size);
@@ -133,6 +141,23 @@ void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start, i != (u64 )ULLONG_MAX ; \ __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) + +#ifdef CONFIG_ARCH_MEMBLOCK_NOMAP +#define for_each_mapped_mem_range (i, nid, p_start, p_end, p_nid) \ + for (i = 0, \ + __next_mapped_mem_range(&i, nid, &memblock.memory, \ + &memblock.nomap, p_start, \ + p_end, p_nid); \ + i != (u64)ULLONG_MAX; \ + __next_mapped_mem_range(&i, nid, &memblock.memory, \ + &memblock.nomap, \ + p_start, p_end, p_nid)) + +void __next_mapped_mem_range (u64 *idx,int nid,phys_addr_t *out_start, +phys_addr_t *out_end,int *out_nid); + +#endif +void __next_free_mem_range_rev (u64 *idx,int nid,phys_addr_t *out_start,phys_addr_t *out_end,int *out_nid);
mm/Kconfig +3 -0
@@ -137,6 +137,9 @@ config HAVE_MEMBLOCK_NODE_MAP config ARCH_DISCARD_MEMBLOCK boolean +config ARCH_MEMBLOCK_NOMAP + boolean + config NO_BOOTMEM boolean
mm/memblock.c +174 -1
222 lines not on this page · raw message
mm/nobootmem.c +9 -0
@@ -137,6 +137,15 @@ static unsigned long __init free_low_memory_core_early(void) size =get_allocated_memblock_memory_regions_info (&start);if (size) count +=__free_memory_core (start, start + size); + +#ifdef CONFIG_ARCH_MEMBLOCK_NOMAP + +/* Free memblock.nomap array if it was allocated */ + size =get_allocated_memblock_memory_regions_info (&start); +if (size) + count +=__free_memory_core (start, start + size); + +#endif #endif return count;
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v4 2/2 mm/memblock: Cleanup and refactoring after addition of nomap
In reply to Philipp Hachtmann--- include/linux/memblock.h | 50 ++++++----- mm/memblock.c | 214 +++++++++++++++++------------------------------ 2 files changed, 107 insertions(+), 157 deletions(-)
include/linux/memblock.h +29 -21
@@ -121,8 +121,9 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ -void __next_free_mem_range (u64 *idx,int nid,phys_addr_t *out_start, -phys_addr_t *out_end,int *out_nid); +void __next_mem_range (u64 *idx,int nid,struct memblock_type *type_a, +struct memblock_type *type_b,phys_addr_t *out_start, +phys_addr_t *out_end,int *out_nid);/** * for_each_free_mem_range - iterate through free memblock areas
@@ -137,29 +138,31 @@ void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start,*/ #define for_each_free_mem_range (i, nid, p_start, p_end, p_nid) \ for (i = 0, \ - __next_free_mem_range(&i, nid, p_start, p_end, p_nid); \ + __next_mem_range(&i, nid, &memblock.memory, \ + &memblock.reserved, p_start, \ + p_end, p_nid); \ i != (u64)ULLONG_MAX; \ - __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) - + __next_mem_range(&i, nid, &memblock.memory, \ + &memblock.reserved, \ + p_start, p_end, p_nid))#ifdef CONFIG_ARCH_MEMBLOCK_NOMAP #define for_each_mapped_mem_range (i, nid, p_start, p_end, p_nid) \ for (i = 0, \ - __next_mapped_mem_range(&i, nid, &memblock.memory, \ + __next_mem_range(&i, nid, &memblock.memory, \ &memblock.nomap, p_start, \ p_end, p_nid); \ i != (u64)ULLONG_MAX; \ - __next_mapped_mem_range(&i, nid, &memblock.memory, \ - &memblock.nomap, \ - p_start, p_end, p_nid)) - -void __next_mapped_mem_range (u64 *idx,int nid,phys_addr_t *out_start, -phys_addr_t *out_end,int *out_nid); - + __next_mem_range(&i, nid, &memblock.memory, \ + &memblock.nomap, \ + p_start, p_end, p_nid))#endif -void __next_free_mem_range_rev (u64 *idx,int nid,phys_addr_t *out_start, -phys_addr_t *out_end,int *out_nid); +void __next_mem_range_rev (u64 *idx,int nid, +struct memblock_type *type_a, +struct memblock_type *type_b, +phys_addr_t *out_start, +phys_addr_t *out_end,int *out_nid);/** * for_each_free_mem_range_reverse - rev-iterate through free memblock areas
@@ -174,9 +177,15 @@ void __next_free_mem_range_rev(u64 *idx, int nid, phys_addr_t *out_start,*/ #define for_each_free_mem_range_reverse (i, nid, p_start, p_end, p_nid) \ for (i = (u64)ULLONG_MAX, \ - __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid); \ + __next_mem_range_rev(&i, nid, \ + &memblock.memory, \ + &memblock.reserved, \ + p_start, p_end, p_nid); \ i != (u64)ULLONG_MAX; \ - __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid)) + __next_mem_range_rev(&i, nid, \ + &memblock.memory, \ + &memblock.reserved, \ + p_start, p_end, p_nid))static inline void memblock_set_region_flags (struct memblock_region *r,unsigned long flags)
@@ -321,12 +330,11 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct membloreturn PFN_UP (reg->base + reg->size); } -#define for_each_memblock (memblock_type, region) \ - for (region = memblock.memblock_type.regions; \ - region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \ +#define for_each_memblock (type_name, region) \ + for (region = memblock.type_name.regions; \ + region < (memblock.type_name.regions + memblock.type_name.cnt); \ region++) -#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK #define __init_memblock __meminit#define __initdata_memblock __meminitdata
mm/memblock.c +78 -136
304 lines not on this page · raw message
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Patch fits Andrew's linux-next.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>