lkml.org 
[lkml]   [2008]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] use vmalloc for mem_cgroup allocation. v2
From
Date
On Mon, 2008-04-14 at 19:20 -0700, Andrew Morton wrote:
> On Tue, 15 Apr 2008 10:08:25 +0800 Li Zefan <lizf@cn.fujitsu.com> 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)) {

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)

if (!mem)

> return ERR_PTR(-ENOMEM);
> memset(mem, 0, sizeof(*mem));
> }
>

Cheers,

Harvey




\
 
 \ /
  Last update: 2008-04-15 04:31    [W:0.038 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site