From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <zanussi@us.ibm.com>,
Karim Yaghmour <karim@opersys.com>,
Paul Mundt <lethal@linux-sh.org>,
Steven Rostedt <rostedt@goodmis.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH] Optimize relay_alloc_page_array() slightly by using vzalloc rather than vmalloc and memset
Date: Sat, 30 Oct 2010 17:47:05 -0400 [thread overview]
Message-ID: <20101030214704.GA20005@Krystal> (raw)
In-Reply-To: <alpine.LNX.2.00.1010302216550.1572@swampdragon.chaosbits.net>
* Jesper Juhl (jj@chaosbits.net) wrote:
> Hi,
>
> We can optimize kernel/relay.c::relay_alloc_page_array() slightly by using
> vzalloc. The patch makes these changes:
>
> - use vzalloc instead of vmalloc+memset.
> - remove redundant local variable 'array'.
> - declare local 'pa_size' as const.
Hrm ? How does declaring a local variable as const helps the compiler in
any way ?
Moreover, is there anyone still using this code ? LTTng uses the Generic
Ring Buffer library which completely deprecates relay.c. Perf and Ftrace
each have their own ring buffers, without dependency on relay.c.
BLK_DEV_IO_TRACE seems to still select RELAY. Has it completed its
transition to either Ftrace or Perf ? Depending on Jens, moving blktrace
relay dependency to the Generic Ring Buffer Library might be a good
option to consider.
Thanks,
Mathieu
>
> Cuts down nicely on both source and object-code size.
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> Compile tested only.
>
> relay.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/relay.c b/kernel/relay.c
> index c7cf397..859ea5a 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -70,17 +70,10 @@ static const struct vm_operations_struct relay_file_mmap_ops = {
> */
> static struct page **relay_alloc_page_array(unsigned int n_pages)
> {
> - struct page **array;
> - 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 = kzalloc(pa_size, GFP_KERNEL);
> - }
> - return array;
> + const size_t pa_size = n_pages * sizeof(struct page *);
> + if (pa_size > PAGE_SIZE)
> + return vzalloc(pa_size);
> + return kzalloc(pa_size, GFP_KERNEL);
> }
>
> /*
>
>
>
> --
> Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
> Plain text mails only, please http://www.expita.com/nomime.html
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2010-10-30 21:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-30 20:26 [PATCH] Optimize relay_alloc_page_array() slightly by using vzalloc rather than vmalloc and memset Jesper Juhl
2010-10-30 21:47 ` Mathieu Desnoyers [this message]
2010-10-30 21:50 ` Jesper Juhl
2010-10-31 18:39 ` Mathieu Desnoyers
2010-11-01 0:46 ` Andrew Morton
2010-11-01 6:58 ` Pekka Enberg
2010-11-01 11:27 ` Mathieu Desnoyers
2010-11-01 12:26 ` Américo Wang
2010-11-01 13:38 ` Mathieu Desnoyers
2010-11-01 12:22 ` Américo Wang
2010-11-01 13:00 ` el es
2010-11-01 12:48 ` Jens Axboe
2010-11-01 13:08 ` Mathieu Desnoyers
2010-11-01 13:34 ` Jens Axboe
2010-11-01 13:41 ` Pekka Enberg
2010-11-01 13:42 ` Jens Axboe
2010-11-01 16:00 ` Mathieu Desnoyers
2010-11-01 18:02 ` Jesper Juhl
2010-11-01 18:26 ` Mathieu Desnoyers
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=20101030214704.GA20005@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=jj@chaosbits.net \
--cc=karim@opersys.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=zanussi@us.ibm.com \
/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.