aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>2016-01-22 18:11:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-22 20:02:18 -0500
commit1d5cfdb076288df5eb95545a547a39905e95c930 (patch)
treec644d2e609c3054833710b75ab1d0fe50fb17c01 /mm
parenteab95db69d334745d3034072f4a7204084136c88 (diff)
tree wide: use kvfree() than conditional kfree()/vfree()
There are many locations that do if (memory_was_allocated_by_vmalloc) vfree(ptr); else kfree(ptr); but kvfree() can handle both kmalloc()ed memory and vmalloc()ed memory using is_vmalloc_addr(). Unless callers have special reasons, we can replace this branch with kvfree(). Please check and reply if you found problems. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Jan Kara <jack@suse.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net> Acked-by: David Rientjes <rientjes@google.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Oleg Drokin <oleg.drokin@intel.com> Cc: Boris Petkov <bp@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/percpu.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/mm/percpu.c b/mm/percpu.c
index 8a943b97a053..998607adf6eb 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -305,16 +305,12 @@ static void *pcpu_mem_zalloc(size_t size)
305/** 305/**
306 * pcpu_mem_free - free memory 306 * pcpu_mem_free - free memory
307 * @ptr: memory to free 307 * @ptr: memory to free
308 * @size: size of the area
309 * 308 *
310 * Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc(). 309 * Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc().
311 */ 310 */
312static void pcpu_mem_free(void *ptr, size_t size) 311static void pcpu_mem_free(void *ptr)
313{ 312{
314 if (size <= PAGE_SIZE) 313 kvfree(ptr);
315 kfree(ptr);
316 else
317 vfree(ptr);
318} 314}
319 315
320/** 316/**
@@ -463,8 +459,8 @@ out_unlock:
463 * pcpu_mem_free() might end up calling vfree() which uses 459 * pcpu_mem_free() might end up calling vfree() which uses
464 * IRQ-unsafe lock and thus can't be called under pcpu_lock. 460 * IRQ-unsafe lock and thus can't be called under pcpu_lock.
465 */ 461 */
466 pcpu_mem_free(old, old_size); 462 pcpu_mem_free(old);
467 pcpu_mem_free(new, new_size); 463 pcpu_mem_free(new);
468 464
469 return 0; 465 return 0;
470} 466}
@@ -732,7 +728,7 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
732 chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC * 728 chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC *
733 sizeof(chunk->map[0])); 729 sizeof(chunk->map[0]));
734 if (!chunk->map) { 730 if (!chunk->map) {
735 pcpu_mem_free(chunk, pcpu_chunk_struct_size); 731 pcpu_mem_free(chunk);
736 return NULL; 732 return NULL;
737 } 733 }
738 734
@@ -753,8 +749,8 @@ static void pcpu_free_chunk(struct pcpu_chunk *chunk)
753{ 749{
754 if (!chunk) 750 if (!chunk)
755 return; 751 return;
756 pcpu_mem_free(chunk->map, chunk->map_alloc * sizeof(chunk->map[0])); 752 pcpu_mem_free(chunk->map);
757 pcpu_mem_free(chunk, pcpu_chunk_struct_size); 753 pcpu_mem_free(chunk);
758} 754}
759 755
760/** 756/**