linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <lliubbo@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	kamezawa.hiroyu@jp.fujitsu.com, cesarb@cesarb.net,
	emunson@mgebm.net, namhyung@gmail.com, hannes@cmpxchg.org,
	mhocko@suse.cz, lucas.demarchi@profusion.mobi,
	aarcange@redhat.com, tj@kernel.org, vapier@gentoo.org,
	jkosina@suse.cz, rientjes@google.com, dan.magenheimer@oracle.com,
	yinghai@kernel.org, hpa@zytor.com
Subject: Re: [PATCH 3/4] sparse: using kzalloc to clean up code
Date: Thu, 4 Aug 2011 14:55:17 +0800	[thread overview]
Message-ID: <CAA_GA1cLg6jwidoYKmxd9rTO8H2WYPzeKjVx6X5brpRizPU80Q@mail.gmail.com> (raw)
In-Reply-To: <CAOJsxLGRmR1RNEOrTjtU_y+6mPF0S+Lh5uZyyoKGZ1w0DLEYqQ@mail.gmail.com>

On Thu, Aug 4, 2011 at 2:10 PM, Pekka Enberg <penberg@kernel.org> wrote:
> On Thu, Aug 4, 2011 at 6:09 AM, Bob Liu <lliubbo@gmail.com> wrote:
>> This patch using kzalloc to clean up sparse_index_alloc() and
>> __GFP_ZERO to clean up __kmalloc_section_memmap().
>>
>> Signed-off-by: Bob Liu <lliubbo@gmail.com>
>> ---
>>  mm/sparse.c |   24 +++++++-----------------
>>  1 files changed, 7 insertions(+), 17 deletions(-)
>>
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index 858e1df..9596635 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid)
>>
>>        if (slab_is_available()) {
>>                if (node_state(nid, N_HIGH_MEMORY))
>> -                       section = kmalloc_node(array_size, GFP_KERNEL, nid);
>> +                       section = kzalloc_node(array_size, GFP_KERNEL, nid);
>>                else
>> -                       section = kmalloc(array_size, GFP_KERNEL);
>> +                       section = kzalloc(array_size, GFP_KERNEL);
>>        } else
>>                section = alloc_bootmem_node(NODE_DATA(nid), array_size);
>>
>> -       if (section)
>> -               memset(section, 0, array_size);
>> -
>
> You now broke the alloc_bootmem_node() path.
>

Yes.
But In my opinion, the alloc_bootmem_node() will also return zeroed memory.
I saw it has used kzalloc or memset() but i'm not pretty sure.
CC'd yinghai@kernel.org,hpa@zytor.com

Thanks for your review.

>>        return section;
>>  }
>>
>> @@ -636,19 +633,12 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
>>        struct page *page, *ret;
>>        unsigned long memmap_size = sizeof(struct page) * nr_pages;
>>
>> -       page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size));
>> +       page = alloc_pages(GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO,
>> +                                       get_order(memmap_size));
>>        if (page)
>> -               goto got_map_page;
>> -
>> -       ret = vmalloc(memmap_size);
>> -       if (ret)
>> -               goto got_map_ptr;
>> -
>> -       return NULL;
>> -got_map_page:
>> -       ret = (struct page *)pfn_to_kaddr(page_to_pfn(page));
>> -got_map_ptr:
>> -       memset(ret, 0, memmap_size);
>> +               ret = (struct page *)pfn_to_kaddr(page_to_pfn(page));
>> +       else
>> +               ret = vzalloc(memmap_size);
>>
>>        return ret;
>>  }
>> --
>> 1.6.3.3
>>
>>
>> --
>> 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/ .
>> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>>
>

-- 
Regards,
--Bob

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-08-04  6:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04  3:09 [PATCH 1/4] page cgroup: using vzalloc instead of vmalloc Bob Liu
2011-08-04  3:09 ` [PATCH 2/4] frontswap: " Bob Liu
2011-08-04  3:09   ` [PATCH 3/4] sparse: using kzalloc to clean up code Bob Liu
2011-08-04  3:09     ` [PATCH 4/4] percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc Bob Liu
2011-08-04  6:13       ` Pekka Enberg
2011-08-04  8:09       ` Michal Hocko
2011-08-04  9:04       ` Tejun Heo
2011-08-04  6:10     ` [PATCH 3/4] sparse: using kzalloc to clean up code Pekka Enberg
2011-08-04  6:55       ` Bob Liu [this message]
2011-08-04  7:22         ` Johannes Weiner
2011-08-04  7:26     ` Johannes Weiner
2011-08-04  7:37       ` Pekka Enberg
2011-08-04  8:07     ` Michal Hocko
2011-08-04  7:57   ` [PATCH 2/4] frontswap: using vzalloc instead of vmalloc Michal Hocko
2011-08-04  8:14     ` Johannes Weiner
2011-08-04  9:00       ` Michal Hocko
2011-08-04 16:47         ` Dan Magenheimer
2011-08-05  2:36           ` Bob Liu
2011-08-05  2:45             ` Dan Magenheimer
2011-08-05  2:57               ` Bob Liu
2011-08-05 18:13                 ` Dan Magenheimer
2011-08-06  3:59                   ` Bob Liu
2011-08-04  6:02 ` [PATCH 1/4] page cgroup: " Pekka Enberg
2011-08-04  7:23 ` Johannes Weiner
2011-08-04  7:53 ` Michal Hocko
2011-08-08  0:56 ` KAMEZAWA Hiroyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA_GA1cLg6jwidoYKmxd9rTO8H2WYPzeKjVx6X5brpRizPU80Q@mail.gmail.com \
    --to=lliubbo@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cesarb@cesarb.net \
    --cc=dan.magenheimer@oracle.com \
    --cc=emunson@mgebm.net \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=mhocko@suse.cz \
    --cc=namhyung@gmail.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=tj@kernel.org \
    --cc=vapier@gentoo.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox