Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/sparse: optimize sparse_index_alloc

With CONFIG_SPARSEMEM_EXTREME, the two levels of memory section
descriptors are allocated from slab or bootmem. When allocating from
slab, let slab/bootmem allocator clear the memory chunk. We needn't clear
it explicitly.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Gavin Shan and committed by
Linus Torvalds
5b760e64 b2145145

+4 -6
+4 -6
mm/sparse.c
··· 65 65 66 66 if (slab_is_available()) { 67 67 if (node_state(nid, N_HIGH_MEMORY)) 68 - section = kmalloc_node(array_size, GFP_KERNEL, nid); 68 + section = kzalloc_node(array_size, GFP_KERNEL, nid); 69 69 else 70 - section = kmalloc(array_size, GFP_KERNEL); 71 - } else 70 + section = kzalloc(array_size, GFP_KERNEL); 71 + } else { 72 72 section = alloc_bootmem_node(NODE_DATA(nid), array_size); 73 - 74 - if (section) 75 - memset(section, 0, array_size); 73 + } 76 74 77 75 return section; 78 76 }