[RFC] makedumpfile: Improve reading speed with mmap()

Atsushi Kumagai kumagai-atsushi at mxc.nes.nec.co.jp
Mon Mar 11 02:57:13 EDT 2013


On Sat, 09 Mar 2013 15:08:05 +0900 (JST)
HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com> wrote:

> > But, anyway, I created the branch "mmap":
> > 
> > http://makedumpfile.git.sourceforge.net/git/gitweb.cgi?p=makedumpfile/makedumpfile;a=shortlog;h=refs/heads/mmap
> > 
> > Please use it for benchmark.
> 
> Thanks! It's very helpful.
> 
> Also, I tested a little the mmap branch code and found a small bug
> that max file offset used in calculating mmap()'s position is
> wrong. Please see the next patch.
> 
> # But sorry, I made this quickly so I didn't consider design enough.

Thanks, that's enough for now. 
I've pushed this into the mmap branch.


Atsushi Kumagai
 
> From 77ef0e836bba4713bfb578949d2785962179d630 Mon Sep 17 00:00:00 2001
> From: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
> Date: Sat, 9 Mar 2013 13:49:43 +0900
> Subject: [PATCH] makedumpfile: fix max offset relative to file
> 
> To see file offset of each memory chunk, it's correct to read p_offset
> in the corresponing PT_LOAD entrie.
> 
> On /proc/vmcore PT_LOAD entries are sorted on p_load values in
> increasing order. So, it's sufficient to refer to the last PT_LOAD
> entry only. But the code here doesn't assuming that, calculating
> maximum one from all the PT_LOAD entries.
> 
> Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
> ---
>  elf_info.c     | 12 ++++++++++++
>  elf_info.h     |  2 ++
>  makedumpfile.c |  2 +-
>  3 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/elf_info.c b/elf_info.c
> index 9bd8cd0..aa8cacb 100644
> --- a/elf_info.c
> +++ b/elf_info.c
> @@ -45,6 +45,7 @@ struct pt_load_segment {
>  };
>  
>  static int			nr_cpus;             /* number of cpu */
> +static off_t			max_file_offset;
>  
>  /*
>   * File information about /proc/vmcore:
> @@ -637,6 +638,12 @@ get_elf_info(int fd, char *filename)
>  			return FALSE;
>  		j++;
>  	}
> +	max_file_offset = 0;
> +	for (i = 0; i < num_pt_loads; ++i) {
> +		struct pt_load_segment *p = &pt_loads[i];
> +		max_file_offset=MAX(max_file_offset,
> +				    p->file_offset+p->phys_end-p->phys_start);
> +	}
>  	if (!has_pt_note()) {
>  		ERRMSG("Can't find PT_NOTE Phdr.\n");
>  		return FALSE;
> @@ -869,3 +876,8 @@ set_eraseinfo(off_t offset, unsigned long size)
>  	size_eraseinfo   = size;
>  }
>  
> +off_t
> +get_max_file_offset(void)
> +{
> +	return max_file_offset;
> +}
> diff --git a/elf_info.h b/elf_info.h
> index eb58023..61ab3c9 100644
> --- a/elf_info.h
> +++ b/elf_info.h
> @@ -71,6 +71,8 @@ int has_eraseinfo(void);
>  void get_eraseinfo(off_t *offset, unsigned long *size);
>  void set_eraseinfo(off_t offset, unsigned long size);
>  
> +off_t get_max_file_offset(void);
> +
>  #endif  /* ELF_INFO_H */
>  
>  
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 3351158..7acbf72 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -235,7 +235,7 @@ static int
>  update_mmap_range(off_t offset) {
>  	off_t start_offset;
>  	off_t map_size;
> -	off_t max_offset = info->max_mapnr * info->page_size;
> +	off_t max_offset = get_max_file_offset();
>  
>  	munmap(info->mmap_buf,
>  	       info->mmap_end_offset - info->mmap_start_offset);
> -- 
> 1.8.1.4



More information about the kexec mailing list