From: Masami Hiramatsu <mhiramat@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: penberg@cs.helsinki.fi, zanussi@comcast.net, dwilder@us.ibm.com,
systemtap@sources.redhat.com, linux-kernel@vger.kernel.org,
tzanussi@gmail.com
Subject: Re: [PATCH -mm] relayfs: support larger relay buffer take 3
Date: Wed, 16 Apr 2008 17:00:08 -0400 [thread overview]
Message-ID: <480668D8.1080706@redhat.com> (raw)
In-Reply-To: <20080416134805.fdd139c1.akpm@linux-foundation.org>
Hi Andrew,
Andrew Morton wrote:
> On Wed, 16 Apr 2008 15:51:56 -0400
> Masami Hiramatsu <mhiramat@redhat.com> wrote:
>
>> +static struct page **relay_alloc_page_array(unsigned int n_pages)
>> +{
>> + struct page **array;
>> + unsigned int pa_size = n_pages * sizeof(struct page *);
>> +
>> + if (pa_size > PAGE_SIZE) {
>> + array = vmalloc(pa_size);
>> + if (array)
>> + memset(array, 0, pa_size);
>> + } else {
>> + array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
>> + }
>> + return array;
>> +}
>
> It's a bit odd to multiply n_pages*sizeof() and to then call kcalloc(),
> which needs to do the same multiplication.
>
> The compiler will presumably optimise that away, but still, how about this?
Sure, it looks good to me.
Thank you so much,
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
>
> --- a/kernel/relay.c~relayfs-support-larger-relay-buffer-take-3-cleanup
> +++ a/kernel/relay.c
> @@ -71,14 +71,14 @@ static struct vm_operations_struct relay
> static struct page **relay_alloc_page_array(unsigned int n_pages)
> {
> struct page **array;
> - unsigned int pa_size = n_pages * sizeof(struct page *);
> + size_t pa_size = n_pages * sizeof(struct page *);
>
> if (pa_size > PAGE_SIZE) {
> array = vmalloc(pa_size);
> if (array)
> memset(array, 0, pa_size);
> } else {
> - array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
> + array = kzalloc(pa_size, GFP_KERNEL);
> }
> return array;
> }
> _
>
>
> size_t is strictly the correct type for pa_size here. Even though
> vmalloc() takes a ulong.
Thanks for the advice,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
next prev parent reply other threads:[~2008-04-16 21:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-15 15:27 [PATCH -mm] relayfs: support larger relay buffer Masami Hiramatsu
2008-04-16 4:22 ` Tom Zanussi
2008-04-16 16:19 ` Masami Hiramatsu
2008-04-16 18:03 ` [PATCH -mm] relayfs: support larger relay buffer take 2 Masami Hiramatsu
2008-04-16 18:21 ` Pekka J Enberg
2008-04-16 18:34 ` Masami Hiramatsu
2008-04-16 19:51 ` [PATCH -mm] relayfs: support larger relay buffer take 3 Masami Hiramatsu
2008-04-16 19:54 ` Pekka Enberg
2008-04-16 20:48 ` Andrew Morton
2008-04-16 21:00 ` Masami Hiramatsu [this message]
2008-04-17 4:05 ` Tom Zanussi
2008-04-16 8:33 ` [PATCH -mm] relayfs: support larger relay buffer Pekka Enberg
2008-04-16 14:36 ` Masami Hiramatsu
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=480668D8.1080706@redhat.com \
--to=mhiramat@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dwilder@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=systemtap@sources.redhat.com \
--cc=tzanussi@gmail.com \
--cc=zanussi@comcast.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.