From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763645AbYDOCVS (ORCPT ); Mon, 14 Apr 2008 22:21:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761279AbYDOCVE (ORCPT ); Mon, 14 Apr 2008 22:21:04 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:56639 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760536AbYDOCVC (ORCPT ); Mon, 14 Apr 2008 22:21:02 -0400 Date: Mon, 14 Apr 2008 19:20:42 -0700 From: Andrew Morton To: Li Zefan Cc: KAMEZAWA Hiroyuki , "balbir@linux.vnet.ibm.com" , "xemul@openvz.org" , menage@google.com, "linux-mm@kvack.org" , LKML Subject: Re: [PATCH] use vmalloc for mem_cgroup allocation. v2 Message-Id: <20080414192042.c50d8d58.akpm@linux-foundation.org> In-Reply-To: <48040E19.2090007@cn.fujitsu.com> References: <20080415105434.3044afb6.kamezawa.hiroyu@jp.fujitsu.com> <20080415111038.ffac0e12.kamezawa.hiroyu@jp.fujitsu.com> <48040E19.2090007@cn.fujitsu.com> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Apr 2008 10:08:25 +0800 Li Zefan wrote: > > @@ -992,8 +993,10 @@ mem_cgroup_create(struct cgroup_subsys * > > if (unlikely((cont->parent) == NULL)) { > > mem = &init_mem_cgroup; > > page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC); > > - } else > > - mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); > > + } else { > > + mem = vmalloc(sizeof(struct mem_cgroup)); > > + memset(mem, 0, sizeof(*mem)); > > what if mem == NULL. ;) > > > + } > > > > if (mem == NULL) > > return ERR_PTR(-ENOMEM); > > So we can move this NULL check to the above else branch, in the if brach, > mem won't be NULL. err, yes. So I have: if (unlikely((cont->parent) == NULL)) { mem = &init_mem_cgroup; page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC); } else { mem = vmalloc(sizeof(struct mem_cgroup)); if (mem == NULL) return ERR_PTR(-ENOMEM); memset(mem, 0, sizeof(*mem)); } From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 14 Apr 2008 19:20:42 -0700 From: Andrew Morton Subject: Re: [PATCH] use vmalloc for mem_cgroup allocation. v2 Message-Id: <20080414192042.c50d8d58.akpm@linux-foundation.org> In-Reply-To: <48040E19.2090007@cn.fujitsu.com> References: <20080415105434.3044afb6.kamezawa.hiroyu@jp.fujitsu.com> <20080415111038.ffac0e12.kamezawa.hiroyu@jp.fujitsu.com> <48040E19.2090007@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Li Zefan Cc: KAMEZAWA Hiroyuki , "balbir@linux.vnet.ibm.com" , "xemul@openvz.org" , menage@google.com, "linux-mm@kvack.org" , LKML List-ID: On Tue, 15 Apr 2008 10:08:25 +0800 Li Zefan wrote: > > @@ -992,8 +993,10 @@ mem_cgroup_create(struct cgroup_subsys * > > if (unlikely((cont->parent) == NULL)) { > > mem = &init_mem_cgroup; > > page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC); > > - } else > > - mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); > > + } else { > > + mem = vmalloc(sizeof(struct mem_cgroup)); > > + memset(mem, 0, sizeof(*mem)); > > what if mem == NULL. ;) > > > + } > > > > if (mem == NULL) > > return ERR_PTR(-ENOMEM); > > So we can move this NULL check to the above else branch, in the if brach, > mem won't be NULL. err, yes. So I have: if (unlikely((cont->parent) == NULL)) { mem = &init_mem_cgroup; page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC); } else { mem = vmalloc(sizeof(struct mem_cgroup)); if (mem == NULL) return ERR_PTR(-ENOMEM); memset(mem, 0, sizeof(*mem)); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org