Clean up relay_alloc_page_array() slightly by using vzalloc rather than 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 <jj@chaosbits.net>
Acked-by: Pekka Enberg <penberg@kernel.org>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jesper Juhl and committed by
Linus Torvalds
408af87a 9a8a0cad

+4 -11
+4 -11
kernel/relay.c
··· 70 70 */ 71 71 static struct page **relay_alloc_page_array(unsigned int n_pages) 72 72 { 73 - struct page **array; 74 - size_t pa_size = n_pages * sizeof(struct page *); 75 - 76 - if (pa_size > PAGE_SIZE) { 77 - array = vmalloc(pa_size); 78 - if (array) 79 - memset(array, 0, pa_size); 80 - } else { 81 - array = kzalloc(pa_size, GFP_KERNEL); 82 - } 83 - return array; 73 + const size_t pa_size = n_pages * sizeof(struct page *); 74 + if (pa_size > PAGE_SIZE) 75 + return vzalloc(pa_size); 76 + return kzalloc(pa_size, GFP_KERNEL); 84 77 } 85 78 86 79 /*