[PATCH 01/13] vmcore: allocate buffer for ELF headers on page-size alignment

Vivek Goyal vgoyal at redhat.com
Fri Feb 15 10:01:25 EST 2013


On Thu, Feb 14, 2013 at 07:11:48PM +0900, HATAYAMA Daisuke wrote:

[..]

I think it is a good idea to copy andrew morton for this patch series.
Generally he is the one who pulls in all the kexec/kdump related patches.

> ---
> 
>  fs/proc/vmcore.c |   30 +++++++++++++++++++++---------
>  1 files changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 0d5071d..85714c3 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -30,6 +30,7 @@ static LIST_HEAD(vmcore_list);
>  /* Stores the pointer to the buffer containing kernel elf core headers. */
>  static char *elfcorebuf;
>  static size_t elfcorebuf_sz;
> +static size_t elfcorebuf_sz_orig;
>  
>  /* Total size of vmcore file. */
>  static u64 vmcore_size;
> @@ -560,26 +561,31 @@ static int __init parse_crash_elf64_headers(void)
>  
>  	/* Read in all elf headers. */
>  	elfcorebuf_sz = sizeof(Elf64_Ehdr) + ehdr.e_phnum * sizeof(Elf64_Phdr);
> -	elfcorebuf = kmalloc(elfcorebuf_sz, GFP_KERNEL);
> +	elfcorebuf_sz_orig = elfcorebuf_sz;
> +	elfcorebuf = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
> +					       get_order(elfcorebuf_sz));
							    ^^^
Just a minor nit. Can you use elfcorebuf_sz_orig instead of elfcorebuf_sz
for allocation. This just makes it inline with free_pages() later.
elfcorebuf_sz_orig size pages are allocated and same size is freed.

Thanks
Vivek



More information about the kexec mailing list