Commit 90459ce06f410b983540be56209c0abcbce23944

Authored by Bob Liu
Committed by Tejun Heo
1 parent f8f5ed7c99

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: Bob Liu <lliubbo@gmail.com>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Tejun Heo <tj@kernel.org>

Showing 2 changed files with 11 additions and 11 deletions Side-by-side Diff

... ... @@ -50,14 +50,13 @@
50 50  
51 51 if (!pages || !bitmap) {
52 52 if (may_alloc && !pages)
53   - pages = pcpu_mem_alloc(pages_size);
  53 + pages = pcpu_mem_zalloc(pages_size);
54 54 if (may_alloc && !bitmap)
55   - bitmap = pcpu_mem_alloc(bitmap_size);
  55 + bitmap = pcpu_mem_zalloc(bitmap_size);
56 56 if (!pages || !bitmap)
57 57 return NULL;
58 58 }
59 59  
60   - memset(pages, 0, pages_size);
61 60 bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages);
62 61  
63 62 *bitmapp = bitmap;
... ... @@ -273,11 +273,11 @@
273 273 (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))
274 274  
275 275 /**
276   - * pcpu_mem_alloc - allocate memory
  276 + * pcpu_mem_zalloc - allocate memory
277 277 * @size: bytes to allocate
278 278 *
279 279 * Allocate @size bytes. If @size is smaller than PAGE_SIZE,
280   - * kzalloc() is used; otherwise, vmalloc() is used. The returned
  280 + * kzalloc() is used; otherwise, vzalloc() is used. The returned
281 281 * memory is always zeroed.
282 282 *
283 283 * CONTEXT:
... ... @@ -286,7 +286,7 @@
286 286 * RETURNS:
287 287 * Pointer to the allocated area on success, NULL on failure.
288 288 */
289   -static void *pcpu_mem_alloc(size_t size)
  289 +static void *pcpu_mem_zalloc(size_t size)
290 290 {
291 291 if (WARN_ON_ONCE(!slab_is_available()))
292 292 return NULL;
... ... @@ -302,7 +302,7 @@
302 302 * @ptr: memory to free
303 303 * @size: size of the area
304 304 *
305   - * Free @ptr. @ptr should have been allocated using pcpu_mem_alloc().
  305 + * Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc().
306 306 */
307 307 static void pcpu_mem_free(void *ptr, size_t size)
308 308 {
... ... @@ -384,7 +384,7 @@
384 384 size_t old_size = 0, new_size = new_alloc * sizeof(new[0]);
385 385 unsigned long flags;
386 386  
387   - new = pcpu_mem_alloc(new_size);
  387 + new = pcpu_mem_zalloc(new_size);
388 388 if (!new)
389 389 return -ENOMEM;
390 390  
391 391  
... ... @@ -604,11 +604,12 @@
604 604 {
605 605 struct pcpu_chunk *chunk;
606 606  
607   - chunk = pcpu_mem_alloc(pcpu_chunk_struct_size);
  607 + chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size);
608 608 if (!chunk)
609 609 return NULL;
610 610  
611   - chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0]));
  611 + chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC *
  612 + sizeof(chunk->map[0]));
612 613 if (!chunk->map) {
613 614 kfree(chunk);
614 615 return NULL;
... ... @@ -1889,7 +1890,7 @@
1889 1890  
1890 1891 BUILD_BUG_ON(size > PAGE_SIZE);
1891 1892  
1892   - map = pcpu_mem_alloc(size);
  1893 + map = pcpu_mem_zalloc(size);
1893 1894 BUG_ON(!map);
1894 1895  
1895 1896 spin_lock_irqsave(&pcpu_lock, flags);