lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101030214704.GA20005@Krystal>
Date:	Sat, 30 Oct 2010 17:47:05 -0400
From:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
To:	Jesper Juhl <jj@...osbits.net>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Tom Zanussi <zanussi@...ibm.com>,
	Karim Yaghmour <karim@...rsys.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH] Optimize relay_alloc_page_array() slightly by using
	vzalloc rather than vmalloc and memset

* Jesper Juhl (jj@...osbits.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@...osbits.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@...osbits.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ