Skip to contentSkip to conversation

Fix compilation warnings on ppc64/ppc64le platforms

PATCH In review Bhupesh Sharma 2 participants 3 messages Nov 16, 2017 – Nov 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 6d5fc8b95415..7ce0c6d648aa 100644
@@ -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
#1 lore raw

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 zero
NON_PRI_CACHE 7817 yes Cache pages
without private flag
PRI_CACHE 63603 yes Cache pages with
private flag
USER 4105 yes User process
pages
FREE 165446 yes Free pages
KERN_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
index 7ce0c6d648aa..4bde542b4f0c 100644
@@ -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
#2 lore raw
In reply to Bhupesh Sharma

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.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 +0 -0
index 6d5fc8b95415..7ce0c6d648aa 100644
@@ -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