From: Michal Hocko <mhocko@suse.cz>
To: Bob Liu <lliubbo@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
kamezawa.hiroyu@jp.fujitsu.com, cesarb@cesarb.net,
emunson@mgebm.net, penberg@kernel.org, namhyung@gmail.com,
hannes@cmpxchg.org, lucas.demarchi@profusion.mobi,
aarcange@redhat.com, tj@kernel.org, vapier@gentoo.org,
jkosina@suse.cz, rientjes@google.com, dan.magenheimer@oracle.com
Subject: Re: [PATCH 4/4] percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc
Date: Thu, 4 Aug 2011 10:09:56 +0200 [thread overview]
Message-ID: <20110804080956.GH31039@tiehlicka.suse.cz> (raw)
In-Reply-To: <1312427390-20005-4-git-send-email-lliubbo@gmail.com>
On Thu 04-08-11 11:09:50, Bob Liu wrote:
> Currently pcpu_mem_alloc() is implemented always return zeroed memory.
> So rename it to make user like pcpu_get_pages_and_bitmap() know don't reinit it.
Makes sense. It fits better with internal kzalloc and vzalloc usage.
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/percpu-vm.c | 5 ++---
> mm/percpu.c | 17 +++++++++--------
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
> index ea53496..29e3730 100644
> --- a/mm/percpu-vm.c
> +++ b/mm/percpu-vm.c
> @@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk,
>
> if (!pages || !bitmap) {
> if (may_alloc && !pages)
> - pages = pcpu_mem_alloc(pages_size);
> + pages = pcpu_mem_zalloc(pages_size);
> if (may_alloc && !bitmap)
> - bitmap = pcpu_mem_alloc(bitmap_size);
> + bitmap = pcpu_mem_zalloc(bitmap_size);
> if (!pages || !bitmap)
> return NULL;
> }
>
> - memset(pages, 0, pages_size);
> bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages);
>
> *bitmapp = bitmap;
> diff --git a/mm/percpu.c b/mm/percpu.c
> index bf80e55..28c37a2 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,
> (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))
>
> /**
> - * pcpu_mem_alloc - allocate memory
> + * pcpu_mem_zalloc - allocate memory
> * @size: bytes to allocate
> *
> * Allocate @size bytes. If @size is smaller than PAGE_SIZE,
> - * kzalloc() is used; otherwise, vmalloc() is used. The returned
> + * kzalloc() is used; otherwise, vzalloc() is used. The returned
> * memory is always zeroed.
> *
> * CONTEXT:
> @@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,
> * RETURNS:
> * Pointer to the allocated area on success, NULL on failure.
> */
> -static void *pcpu_mem_alloc(size_t size)
> +static void *pcpu_mem_zalloc(size_t size)
> {
> if (WARN_ON_ONCE(!slab_is_available()))
> return NULL;
> @@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size)
> * @ptr: memory to free
> * @size: size of the area
> *
> - * Free @ptr. @ptr should have been allocated using pcpu_mem_alloc().
> + * Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc().
> */
> static void pcpu_mem_free(void *ptr, size_t size)
> {
> @@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
> size_t old_size = 0, new_size = new_alloc * sizeof(new[0]);
> unsigned long flags;
>
> - new = pcpu_mem_alloc(new_size);
> + new = pcpu_mem_zalloc(new_size);
> if (!new)
> return -ENOMEM;
>
> @@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
> {
> struct pcpu_chunk *chunk;
>
> - chunk = pcpu_mem_alloc(pcpu_chunk_struct_size);
> + chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size);
> if (!chunk)
> return NULL;
>
> - chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0]));
> + chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC *
> + sizeof(chunk->map[0]));
> if (!chunk->map) {
> kfree(chunk);
> return NULL;
> @@ -1889,7 +1890,7 @@ void __init percpu_init_late(void)
>
> BUILD_BUG_ON(size > PAGE_SIZE);
>
> - map = pcpu_mem_alloc(size);
> + map = pcpu_mem_zalloc(size);
> BUG_ON(!map);
>
> spin_lock_irqsave(&pcpu_lock, flags);
> --
> 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>
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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>
next prev parent reply other threads:[~2011-08-04 8:09 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 [this message]
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
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=20110804080956.GH31039@tiehlicka.suse.cz \
--to=mhocko@suse.cz \
--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=jkosina@suse.cz \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lliubbo@gmail.com \
--cc=lucas.demarchi@profusion.mobi \
--cc=namhyung@gmail.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=tj@kernel.org \
--cc=vapier@gentoo.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;
as well as URLs for NNTP newsgroup(s).