Fix compilation warnings on ppc64/ppc64le platforms
Subsystems (2)
PATCH 1/2 Fix compilation warnings on ppc64/ppc64le platforms
I ran into the following compilation warnings while compiling makedumpfile on ppc64/ppc64le platforms:
-D_LARGEFILE64_SOURCE -DVERSION='"1.6.2"' -DRELEASE_DATE='"27 Jul 2017"' -D__powerpc64le__ -DUSELZO -DUSESNAPPY print_info.o dwarf_info.o elf_info.o erase_info.o sadump_info.o cache.o arch/arm.o arch/arm64.o arch/x86.o arch/x86_64.o arch/ia64.o arch/ppc64.o arch/s390x.o arch/ppc.o arch/sparc64.o -rdynamic -o makedumpfile makedumpfile.c -lpthread -lsnappy -llzo2 -ldw -lbz2 -lebl -ldl -lelf -lz
makedumpfile.c: In function ‘initial_xen’:
makedumpfile.c:9442:16: warning: unused variable ‘size’ [-Wunused-variable]
unsigned long size;
^
makedumpfile.c:9441:8: warning: unused variable ‘offset’ [-Wunused-variable]
off_t offset;
^
makedumpfile.c:9440:6: warning: unused variable ‘xen_info_required’ [-Wunused-variable]
int xen_info_required = TRUE;
^This is caused because while we don't support Xen on powerpc, we still have the above variables declared outside the '#if defined(__powerpc64__) || defined(__powerpc32__)' check.
This patch fixes the same by ensuring that these variables are only declared for archs != powerpc.
--- makedumpfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
makedumpfile.c +4 -4
@@ -9437,15 +9437,15 @@ exclude_xen_user_domain(void)int initial_xen (void ) { -int xen_info_required = TRUE; -off_t offset; -unsigned long size; - #if defined(__powerpc64__) || defined(__powerpc32__) MSG("\n"); MSG("Xen is not supported on powerpc.\n"); return FALSE; #else + int xen_info_required = TRUE; + off_t offset; + unsigned long size; + #ifndef __x86_64__ if (DL_EXCLUDE_ZERO < info->max_dump_level) { MSG("Dump_level is invalid. It should be 0 or 1.\n");
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/2 Fix 'kernel_version' variable being uninitialized & introduce minor reorganization
On executing makedumpfile --mem-usage /proc/kcore, it fails currently with the following error message on newer Linux kernels like 4.13.0 or 4.14.0:
mem-usage not supported for this kernel.
You can try with -f if your kernel's kcore has valid p_paddr makedumpfile Failed.
This happens because 'info->kernel_version' is uninitialized in function main(). So when we perform the following check, it fails even though the kernel version is greater than 4.11.0:
if (info->kernel_version < KERNEL_VERSION(4, 11, 0) &&
!info->flag_force) {Fix this by reorganizing the code to:
- Add an API to populate the kernel version.
- Call this API rather than replicating the open code across other APIs across 'makedumpfile.c'
After this patch, '--mem-usage' can be used properly with makedumpfile. Here are the logs I observe on a Fedora 26 ppc64le system:
The kernel version is not supported.
The makedumpfile operation may be incomplete.
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------
ZERO 99 yes Pages filled
with zeroNON_PRI_CACHE 7817 yes Cache pages
without private flagPRI_CACHE 63603 yes Cache pages with
private flag
USER 4105 yes User process
pages
FREE 165446 yes Free pagesKERN_DATA 6738 no Dumpable kernel
data
page size: 65536
Total pages on system: 247808
Total size on system: 16240345088 Byte
--- makedumpfile.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
makedumpfile.c +20 -11
@@ -1089,6 +1089,21 @@ fallback_to_current_page_size(void)return TRUE; } +static int populate_kernel_version (void ) +{ +struct utsname utsname; + +if (uname (&utsname)) { +ERRMSG ("Cannot get name and information about current kernel : %s\n" , +strerror (errno)); +return FALSE; + } + + info->kernel_version =get_kernel_version (utsname.release); + +return TRUE; +} +int check_release (void ) {
@@ -1120,11 +1135,8 @@ check_release(void) } } - info->kernel_version =get_kernel_version (info->system_utsname.release); -if (info->kernel_version == FALSE) { -ERRMSG ("Can't get the kernel version.\n" ); +if (!populate_kernel_version ())return FALSE; - }return TRUE; }
@@ -10973,20 +10985,14 @@ int is_crashkernel_mem_reserved(void)static int get_page_offset (void ) { -struct utsname utsname; -if (uname (&utsname)) { -ERRMSG ("Cannot get name and information about current kernel : %s" , -strerror (errno)); +if (!populate_kernel_version ())return FALSE; - } - info->kernel_version =get_kernel_version (utsname.release);get_versiondep_info ();return TRUE; } -/* Returns the physical address of start of crash notes buffer for a kernel. */ static int get_sys_kernel_vmcoreinfo (uint64_t *addr,uint64_t *len) {
@@ -11363,6 +11369,9 @@ main(int argc, char *argv[])MSG ("Try `makedumpfile --help' for more information.\n" ); goto out; } +if (!populate_kernel_version ()) + goto out; +if (info->kernel_version <KERNEL_VERSION (4 ,11 ,0 ) && !info->flag_force) {MSG ("mem-usage not supported for this kernel.\n" );
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hello Bhupesh,
Thanks for your work, I'll merge these patches into v1.6.3.
Regards
Atsushi Kumagai
Quoted 58 lines
I ran into the following compilation warnings while compiling makedumpfile on ppc64/ppc64le platforms:
(quoted diff) +0
-2-D_LARGEFILE64_SOURCE -DVERSION='"1.6.2"' -DRELEASE_DATE='"27 Jul 2017"' -D__powerpc64le__ -DUSELZO -DUSESNAPPY print_info.o dwarf_info.oelf_info.o erase_info.o sadump_info.o cache.o
arch/arm.oarch/arm64.oarch/x86.oarch/x86_64.oarch/ia64.oarch/ppc64.oarch/s390x.oarch/ppc.oarch/sparc64.o-rdynamic -o makedumpfilemakedumpfile.c-lpthread -lsnappy -llzo2 -ldw -lbz2 -lebl -ldl -lelf -lz
makedumpfile.c: In function ‘initial_xen’:
makedumpfile.c:9442:16: warning: unused variable ‘size’ [-Wunused-variable]unsigned long size; ^ makedumpfile.c:9441:8: warning: unused variable ‘offset’ [-Wunused-variable] off_t offset; ^ makedumpfile.c:9440:6: warning: unused variable ‘xen_info_required’ [-Wunused-variable] int xen_info_required = TRUE; ^This is caused because while we don't support Xen on powerpc, we still have the above variables declared outside the '#if
defined(__powerpc64__)||defined(__powerpc32__)' check.This patch fixes the same by ensuring that these variables are only declared for archs != powerpc.
Signed-off-by Bhupesh Sharma <[email protected]>---
makedumpfile.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)makedumpfile.c +0
-0@@ -9437,15 +9437,15 @@ exclude_xen_user_domain(void)int
initial_xen(void)
{makedumpfile.c +0
-4-int xen_info_required = TRUE; -off_t offset; -unsigned long size; -#if defined(__powerpc64__) || defined(__powerpc32__) MSG("\n"); MSG("Xen is not supported on powerpc.\n"); return FALSE;#else
makedumpfile.c +4
-0+int xen_info_required = TRUE; +off_t offset; +unsigned long size; +#ifndef __x86_64__ if (DL_EXCLUDE_ZERO < info->max_dump_level) { MSG("Dump_level is invalid. It should be 0 or 1.\n");
Quoted 2 lines
--
2.7.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec