[PATCH] makedumpfile: message on non-mmap kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 15 May 2013 13:43:59 -0500
Cliff Wickman <cpw at sgi.com> wrote:

> From: Cliff Wickman <cpw at sgi.com>
> 
> If the crash kernel does not support mmap(2) of /proc/vmcore, make
> makedumpfile fall back to using reads with a non-alarming message.
> 
> Signed-off-by: Cliff Wickman <cpw at sgi.com>
> ---
>  makedumpfile.c |   37 ++++++++++++++++++++++---------------
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 
> Index: makedumpfile.mmap/makedumpfile.c
> ===================================================================
> --- makedumpfile.mmap.orig/makedumpfile.c
> +++ makedumpfile.mmap/makedumpfile.c
> @@ -239,7 +239,7 @@ read_page_desc(unsigned long long paddr,
>  }
>  
>  static int
> -update_mmap_range(off_t offset) {
> +update_mmap_range(off_t offset, int initial) {
>  	off_t start_offset;
>  	off_t map_size;
>  	off_t max_offset = get_max_file_offset();
> @@ -258,10 +258,11 @@ update_mmap_range(off_t offset) {
>  				     info->fd_memory, start_offset);
>  
>  	if (info->mmap_buf == MAP_FAILED) {
> -		ERRMSG("Can't map [%llx-%llx] with mmap()\n %s",
> -		       (ulonglong)start_offset,
> -		       (ulonglong)(start_offset + map_size),
> -		       strerror(errno));
> +		if (!initial)
> +			ERRMSG("Can't map [%llx-%llx] with mmap()\n %s",
> +				(ulonglong)start_offset,
> +				(ulonglong)(start_offset + map_size),
> +				strerror(errno));
>  		return FALSE;
>  	}
>  
> @@ -285,7 +286,7 @@ is_mapped_with_mmap(off_t offset) {
>  int
>  initialize_mmap(void) {
>  	info->mmap_buf = MAP_FAILED;
> -	if (!update_mmap_range(0))
> +	if (!update_mmap_range(0, 1))
>  		return FALSE;
>  
>  	return TRUE;
> @@ -298,7 +299,7 @@ read_with_mmap(off_t offset, void *bufpt
>  next_region:
>  
>  	if (!is_mapped_with_mmap(offset)) {
> -		if (!update_mmap_range(offset))
> +		if (!update_mmap_range(offset, 0))
>  			return FALSE;
>  	}

Where came from this original code ?
The current code in mmap branch doesn't look the return value of
update_mmap_range():

	if (!is_mapped_with_mmap(offset))
		update_mmap_range(offset);

Anyway, I'll merge this patch into mmap branch after I push the patch
below.


Thanks
Atsushi Kumagai

-----------------------------------------------------------------------
Author: Atsushi Kumagai <kumagai-atsushi at mxc.nes.nec.co.jp>
Date:   Thu May 17 15:02:19 2013 +0900

    [PATCH] Add error handling for read_with_mmap().

    Add error handling for read_with_mmap the same as read()'s case.

    Signed-off-by: Atsushi Kumagai <kumagai-atsushi at mxc.nes.nec.co.jp>

diff --git a/makedumpfile.c b/makedumpfile.c
index fce2e35..1f656e8 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -291,7 +291,8 @@ read_with_mmap(off_t offset, void *bufptr, unsigned long size) {
 next_region:

        if (!is_mapped_with_mmap(offset))
-               update_mmap_range(offset);
+               if (!update_mmap_range(offset))
+                       return FALSE;

        read_size = MIN(info->mmap_end_offset - offset, size);

@@ -320,9 +321,13 @@ readpage_elf(unsigned long long paddr, void *bufptr)
                return FALSE;
        }

-       if (info->flag_usemmap)
-               read_with_mmap(offset, bufptr, info->page_size);
-       else {
+       if (info->flag_usemmap) {
+               if (!read_with_mmap(offset, bufptr, info->page_size)) {
+                       ERRMSG("Can't read the dump memory(%s) with mmap().\n",
+                               info->name_memory);
+                        return FALSE;
+               }
+       } else {
                if (lseek(info->fd_memory, offset, SEEK_SET) == failed) {
                        ERRMSG("Can't seek the dump memory(%s). (offset: %llx) %s\n",
                               info->name_memory, (unsigned long long)offset, strerror(errno));

  
> @@ -2984,14 +2985,20 @@ out:
>  	if (info->dump_level & DL_EXCLUDE_FREE)
>  		setup_page_is_buddy();
>  
> -	if (info->mmap_region_size > 0 && initialize_mmap()) {
> -		/*
> -		 * The map size is specified as Kbyte with
> -		 * --map-size <size> option.
> -		 */
> -		info->mmap_region_size <<= 10;
> -		info->flag_usemmap = TRUE;
> -		DEBUG_MSG("read %s with mmap()\n", info->name_memory);
> +	if (info->mmap_region_size > 0) {
> +		if (!initialize_mmap()) {
> +			/* this kernel does not support mmap of vmcore */
> +			ERRMSG("Kernel can't mmap vmcore, using reads.\n");
> +			info->flag_usemmap = FALSE;
> +		} else {
> +			/*
> +			 * The map size is specified as Kbyte with
> +			 * --map-size <size> option.
> +			 */
> +			info->mmap_region_size <<= 10;
> +			info->flag_usemmap = TRUE;
> +			DEBUG_MSG("read %s with mmap()\n", info->name_memory);
> +		}
>  	} else {
>  		info->flag_usemmap = FALSE;
>  		DEBUG_MSG("read %s with read()\n", info->name_memory);
> 
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux