mm: define memblock_virt_alloc_try_nid_raw
[email protected]
maintainerPATCH 85/131 mm: define memblock_virt_alloc_try_nid_raw
From: Pavel Tatashin <[email protected]>
Subject: mm: define memblock_virt_alloc_try_nid_raw
* A new variant of memblock_virt_alloc_* allocations:memblock_virt_alloc_try_nid_raw()
- Does not zero the allocated memory
- Does not panic if request cannot be satisfied
* optimize early system hash allocations
Clients can call alloc_large_system_hash() with flag: HASH_ZERO to specify that memory that was allocated for system hash needs to be zeroed, otherwise the memory does not need to be zeroed, and client will initialize it.
If memory does not need to be zero'd, call the new memblock_virt_alloc_raw() interface, and thus improve the boot performance.
* debug for raw alloctor
When CONFIG_DEBUG_VM is enabled, this patch sets all the memory that is returned by memblock_virt_alloc_try_nid_raw() to ones to ensure that no places excpect zeroed memory.
---
include/linux/bootmem.h | 27 +++++++++++++++++ mm/memblock.c | 60 +++++++++++++++++++++++++++++++++----- mm/page_alloc.c | 15 ++++----- 3 files changed, 87 insertions(+), 15 deletions(-)
include/linux/bootmem.h renamed from include/linux/bootmem.h~mm-defining-memblock_virt_alloc_try_nid_raw +27 -0
@@ -161,6 +161,9 @@ extern void *__alloc_bootmem_low_node(pg#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0)/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */ +void *memblock_virt_alloc_try_nid_raw (phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr, +phys_addr_t max_addr,int nid);void *memblock_virt_alloc_try_nid_nopanic (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid);
@@ -177,6 +180,14 @@ static inline void * __init memblock_vir NUMA_NO_NODE); } +static inline void *__init memblock_virt_alloc_raw ( +phys_addr_t size,phys_addr_t align) +{ +return memblock_virt_alloc_try_nid_raw (size, align,BOOTMEM_LOW_LIMIT , +BOOTMEM_ALLOC_ACCESSIBLE , +NUMA_NO_NODE ); +} +static inline void *__init memblock_virt_alloc_nopanic (phys_addr_t size,phys_addr_t align) {
@@ -258,6 +269,14 @@ static inline void * __init memblock_virreturn __alloc_bootmem (size, align,BOOTMEM_LOW_LIMIT ); } +static inline void *__init memblock_virt_alloc_raw ( +phys_addr_t size,phys_addr_t align) +{ +if (!align) + align =SMP_CACHE_BYTES ; +return __alloc_bootmem_nopanic (size, align,BOOTMEM_LOW_LIMIT ); +} +static inline void *__init memblock_virt_alloc_nopanic (phys_addr_t size,phys_addr_t align) {
@@ -310,6 +329,14 @@ static inline void * __init memblock_vir min_addr); } +static inline void *__init memblock_virt_alloc_try_nid_raw ( +phys_addr_t size,phys_addr_t align, +phys_addr_t min_addr,phys_addr_t max_addr,int nid) +{ +return ___alloc_bootmem_node_nopanic (NODE_DATA (nid), size, align, + min_addr, max_addr); +} +static inline void *__init memblock_virt_alloc_try_nid_nopanic (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid)
mm/memblock.c renamed from mm/memblock.c~mm-defining-memblock_virt_alloc_try_nid_raw +53 -7
100 lines not on this page · raw message
mm/page_alloc.c renamed from mm/page_alloc.c~mm-defining-memblock_virt_alloc_try_nid_raw +7 -8
@@ -7313,18 +7313,17 @@ void *__init alloc_large_system_hash(con log2qty =ilog2 (numentries); -/* -* memblock allocator returns zeroed memory already, so HASH_ZERO is -* currently not used when HASH_EARLY is specified. -*/ gfp_flags = (flags &HASH_ZERO ) ?GFP_ATOMIC | __GFP_ZERO :GFP_ATOMIC ; do { size = bucketsize << log2qty; - if (flags & HASH_EARLY) - table = memblock_virt_alloc_nopanic(size, 0); - else if (hashdist) + if (flags & HASH_EARLY) { + if (flags & HASH_ZERO) + table = memblock_virt_alloc_nopanic(size, 0); + else + table = memblock_virt_alloc_raw(size, 0); + } else if (hashdist) { table = __vmalloc(size, gfp_flags, PAGE_KERNEL); - else { + } else { /* * If bucketsize is not a power-of-two, we may free * some pages at the end of hash table which
_