Skip to content

Commit

Permalink
Clean up relay_alloc_page_array() slightly by using vzalloc rather th…
Browse files Browse the repository at this point in the history
…an vmalloc and memset

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.

Cuts down nicely on both source and object-code size.

Signed-off-by: Jesper Juhl <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Acked-by: Mathieu Desnoyers <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jjuhl authored and cayniarb committed Feb 28, 2012
1 parent 04a862e commit f5789f7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions kernel/relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit f5789f7

Please sign in to comment.