提交 90459ce0 编写于 作者: B Bob Liu 提交者: Tejun Heo

percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc

Currently pcpu_mem_alloc() is implemented always return zeroed memory.
So rename it to make user like pcpu_get_pages_and_bitmap() know don't
reinit it.
Signed-off-by: NBob Liu <lliubbo@gmail.com>
Reviewed-by: NPekka Enberg <penberg@kernel.org>
Reviewed-by: NMichal Hocko <mhocko@suse.cz>
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 f8f5ed7c
...@@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk, ...@@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk,
if (!pages || !bitmap) { if (!pages || !bitmap) {
if (may_alloc && !pages) if (may_alloc && !pages)
pages = pcpu_mem_alloc(pages_size); pages = pcpu_mem_zalloc(pages_size);
if (may_alloc && !bitmap) if (may_alloc && !bitmap)
bitmap = pcpu_mem_alloc(bitmap_size); bitmap = pcpu_mem_zalloc(bitmap_size);
if (!pages || !bitmap) if (!pages || !bitmap)
return NULL; return NULL;
} }
memset(pages, 0, pages_size);
bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages); bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages);
*bitmapp = bitmap; *bitmapp = bitmap;
......
...@@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk, ...@@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,
(rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end))) (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))
/** /**
* pcpu_mem_alloc - allocate memory * pcpu_mem_zalloc - allocate memory
* @size: bytes to allocate * @size: bytes to allocate
* *
* Allocate @size bytes. If @size is smaller than PAGE_SIZE, * Allocate @size bytes. If @size is smaller than PAGE_SIZE,
* kzalloc() is used; otherwise, vmalloc() is used. The returned * kzalloc() is used; otherwise, vzalloc() is used. The returned
* memory is always zeroed. * memory is always zeroed.
* *
* CONTEXT: * CONTEXT:
...@@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk, ...@@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,
* RETURNS: * RETURNS:
* Pointer to the allocated area on success, NULL on failure. * Pointer to the allocated area on success, NULL on failure.
*/ */
static void *pcpu_mem_alloc(size_t size) static void *pcpu_mem_zalloc(size_t size)
{ {
if (WARN_ON_ONCE(!slab_is_available())) if (WARN_ON_ONCE(!slab_is_available()))
return NULL; return NULL;
...@@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size) ...@@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size)
* @ptr: memory to free * @ptr: memory to free
* @size: size of the area * @size: size of the area
* *
* Free @ptr. @ptr should have been allocated using pcpu_mem_alloc(). * Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc().
*/ */
static void pcpu_mem_free(void *ptr, size_t size) static void pcpu_mem_free(void *ptr, size_t size)
{ {
...@@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) ...@@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
size_t old_size = 0, new_size = new_alloc * sizeof(new[0]); size_t old_size = 0, new_size = new_alloc * sizeof(new[0]);
unsigned long flags; unsigned long flags;
new = pcpu_mem_alloc(new_size); new = pcpu_mem_zalloc(new_size);
if (!new) if (!new)
return -ENOMEM; return -ENOMEM;
...@@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) ...@@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
{ {
struct pcpu_chunk *chunk; struct pcpu_chunk *chunk;
chunk = pcpu_mem_alloc(pcpu_chunk_struct_size); chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size);
if (!chunk) if (!chunk)
return NULL; return NULL;
chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0])); chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC *
sizeof(chunk->map[0]));
if (!chunk->map) { if (!chunk->map) {
kfree(chunk); kfree(chunk);
return NULL; return NULL;
...@@ -1889,7 +1890,7 @@ void __init percpu_init_late(void) ...@@ -1889,7 +1890,7 @@ void __init percpu_init_late(void)
BUILD_BUG_ON(size > PAGE_SIZE); BUILD_BUG_ON(size > PAGE_SIZE);
map = pcpu_mem_alloc(size); map = pcpu_mem_zalloc(size);
BUG_ON(!map); BUG_ON(!map);
spin_lock_irqsave(&pcpu_lock, flags); spin_lock_irqsave(&pcpu_lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册