Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754015Ab0KEDJQ (ORCPT ); Thu, 4 Nov 2010 23:09:16 -0400 Received: from mail.perches.com ([173.55.12.10]:4195 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753934Ab0KEDJK (ORCPT ); Thu, 4 Nov 2010 23:09:10 -0400 From: Joe Perches To: Jiri Kosina Cc: Balbir Singh , Daisuke Nishimura , KAMEZAWA Hiroyuki , Paul Menage , Li Zefan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org Subject: [PATCH 44/49] mm: Use vzalloc Date: Thu, 4 Nov 2010 20:08:08 -0700 Message-Id: X-Mailer: git-send-email 1.7.3.1.g432b3.dirty In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2493 Lines: 92 Signed-off-by: Joe Perches --- mm/memcontrol.c | 5 ++--- mm/page_cgroup.c | 3 +-- mm/percpu.c | 8 ++------ mm/swapfile.c | 3 +-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9a99cfa..90da698 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4199,14 +4199,13 @@ static struct mem_cgroup *mem_cgroup_alloc(void) /* Can be very big if MAX_NUMNODES is very big */ if (size < PAGE_SIZE) - mem = kmalloc(size, GFP_KERNEL); + mem = kzalloc(size, GFP_KERNEL); else - mem = vmalloc(size); + mem = vzalloc(size); if (!mem) return NULL; - memset(mem, 0, size); mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu); if (!mem->stat) { if (size < PAGE_SIZE) diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 5bffada..34970c7 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c @@ -450,11 +450,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) length = ((max_pages/SC_PER_PAGE) + 1); array_size = length * sizeof(void *); - array = vmalloc(array_size); + array = vzalloc(array_size); if (!array) goto nomem; - memset(array, 0, array_size); ctrl = &swap_cgroup_ctrl[type]; mutex_lock(&swap_cgroup_mutex); ctrl->length = length; diff --git a/mm/percpu.c b/mm/percpu.c index efe8168..9e16d1c 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -293,12 +293,8 @@ static void *pcpu_mem_alloc(size_t size) if (size <= PAGE_SIZE) return kzalloc(size, GFP_KERNEL); - else { - void *ptr = vmalloc(size); - if (ptr) - memset(ptr, 0, size); - return ptr; - } + else + return vzalloc(size); } /** diff --git a/mm/swapfile.c b/mm/swapfile.c index 67ddaaf..43e6988 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2044,13 +2044,12 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) goto bad_swap; /* OK, set up the swap map and apply the bad block list */ - swap_map = vmalloc(maxpages); + swap_map = vzalloc(maxpages); if (!swap_map) { error = -ENOMEM; goto bad_swap; } - memset(swap_map, 0, maxpages); nr_good_pages = maxpages - 1; /* omit header page */ for (i = 0; i < swap_header->info.nr_badpages; i++) { -- 1.7.3.1.g432b3.dirty -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/