|
|
1d9674 |
From 08e08d1330f5d4dd0989bfb1558d85c82254654e Mon Sep 17 00:00:00 2001
|
|
|
1d9674 |
From: Bhupesh Sharma <bhsharma@redhat.com>
|
|
|
1d9674 |
Date: Fri, 17 Nov 2017 06:30:41 +0900
|
|
|
1d9674 |
Subject: [PATCH 2/2] [PATCH 2/2] Fix 'kernel_version' variable being
|
|
|
1d9674 |
uninitialized & introduce minor reorganization
|
|
|
1d9674 |
|
|
|
1d9674 |
On executing `makedumpfile --mem-usage /proc/kcore`, it
|
|
|
1d9674 |
fails currently with the following error message on newer Linux kernels
|
|
|
1d9674 |
like 4.13.0 or 4.14.0:
|
|
|
1d9674 |
|
|
|
1d9674 |
mem-usage not supported for this kernel.
|
|
|
1d9674 |
You can try with -f if your kernel's kcore has valid p_paddr
|
|
|
1d9674 |
makedumpfile Failed.
|
|
|
1d9674 |
|
|
|
1d9674 |
This happens because 'info->kernel_version' is uninitialized in function
|
|
|
1d9674 |
main(). So when we perform the following check, it fails even though the
|
|
|
1d9674 |
kernel version is greater than 4.11.0:
|
|
|
1d9674 |
|
|
|
1d9674 |
if (info->kernel_version < KERNEL_VERSION(4, 11, 0) &&
|
|
|
1d9674 |
!info->flag_force) {
|
|
|
1d9674 |
|
|
|
1d9674 |
Fix this by reorganizing the code to:
|
|
|
1d9674 |
- Add an API to populate the kernel version.
|
|
|
1d9674 |
- Call this API rather than replicating the open code across other APIs
|
|
|
1d9674 |
across 'makedumpfile.c'
|
|
|
1d9674 |
|
|
|
1d9674 |
After this patch, '--mem-usage' can be used properly with makedumpfile.
|
|
|
1d9674 |
Here are the logs I observe on a Fedora 26 ppc64le system:
|
|
|
1d9674 |
|
|
|
1d9674 |
The kernel version is not supported.
|
|
|
1d9674 |
The makedumpfile operation may be incomplete.
|
|
|
1d9674 |
|
|
|
1d9674 |
TYPE PAGES EXCLUDABLE DESCRIPTION
|
|
|
1d9674 |
----------------------------------------------------------------------
|
|
|
1d9674 |
ZERO 99 yes Pages filled with zero
|
|
|
1d9674 |
NON_PRI_CACHE 7817 yes Cache pages without private flag
|
|
|
1d9674 |
PRI_CACHE 63603 yes Cache pages with private flag
|
|
|
1d9674 |
USER 4105 yes User process pages
|
|
|
1d9674 |
FREE 165446 yes Free pages
|
|
|
1d9674 |
KERN_DATA 6738 no Dumpable kernel data
|
|
|
1d9674 |
|
|
|
1d9674 |
page size: 65536
|
|
|
1d9674 |
Total pages on system: 247808
|
|
|
1d9674 |
Total size on system: 16240345088 Byte
|
|
|
1d9674 |
|
|
|
1d9674 |
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
|
|
|
1d9674 |
---
|
|
|
1d9674 |
makedumpfile.c | 31 ++++++++++++++++++++-----------
|
|
|
1d9674 |
1 file changed, 20 insertions(+), 11 deletions(-)
|
|
|
1d9674 |
|
|
|
1d9674 |
diff --git a/makedumpfile-1.6.2/makedumpfile.c b/makedumpfile-1.6.2/makedumpfile.c
|
|
|
1d9674 |
index 7ce0c6d648aa..4bde542b4f0c 100644
|
|
|
1d9674 |
--- a/makedumpfile-1.6.2/makedumpfile.c
|
|
|
1d9674 |
+++ b/makedumpfile-1.6.2/makedumpfile.c
|
|
|
1d9674 |
@@ -1089,6 +1089,21 @@ fallback_to_current_page_size(void)
|
|
|
1d9674 |
return TRUE;
|
|
|
1d9674 |
}
|
|
|
1d9674 |
|
|
|
1d9674 |
+static int populate_kernel_version(void)
|
|
|
1d9674 |
+{
|
|
|
1d9674 |
+ struct utsname utsname;
|
|
|
1d9674 |
+
|
|
|
1d9674 |
+ if (uname(&utsname)) {
|
|
|
1d9674 |
+ ERRMSG("Cannot get name and information about current kernel : %s\n",
|
|
|
1d9674 |
+ strerror(errno));
|
|
|
1d9674 |
+ return FALSE;
|
|
|
1d9674 |
+ }
|
|
|
1d9674 |
+
|
|
|
1d9674 |
+ info->kernel_version = get_kernel_version(utsname.release);
|
|
|
1d9674 |
+
|
|
|
1d9674 |
+ return TRUE;
|
|
|
1d9674 |
+}
|
|
|
1d9674 |
+
|
|
|
1d9674 |
int
|
|
|
1d9674 |
check_release(void)
|
|
|
1d9674 |
{
|
|
|
1d9674 |
@@ -1120,11 +1135,8 @@ check_release(void)
|
|
|
1d9674 |
}
|
|
|
1d9674 |
}
|
|
|
1d9674 |
|
|
|
1d9674 |
- info->kernel_version = get_kernel_version(info->system_utsname.release);
|
|
|
1d9674 |
- if (info->kernel_version == FALSE) {
|
|
|
1d9674 |
- ERRMSG("Can't get the kernel version.\n");
|
|
|
1d9674 |
+ if (!populate_kernel_version())
|
|
|
1d9674 |
return FALSE;
|
|
|
1d9674 |
- }
|
|
|
1d9674 |
|
|
|
1d9674 |
return TRUE;
|
|
|
1d9674 |
}
|
|
|
1d9674 |
@@ -10973,20 +10985,14 @@ int is_crashkernel_mem_reserved(void)
|
|
|
1d9674 |
|
|
|
1d9674 |
static int get_page_offset(void)
|
|
|
1d9674 |
{
|
|
|
1d9674 |
- struct utsname utsname;
|
|
|
1d9674 |
- if (uname(&utsname)) {
|
|
|
1d9674 |
- ERRMSG("Cannot get name and information about current kernel : %s",
|
|
|
1d9674 |
- strerror(errno));
|
|
|
1d9674 |
+ if (!populate_kernel_version())
|
|
|
1d9674 |
return FALSE;
|
|
|
1d9674 |
- }
|
|
|
1d9674 |
|
|
|
1d9674 |
- info->kernel_version = get_kernel_version(utsname.release);
|
|
|
1d9674 |
get_versiondep_info();
|
|
|
1d9674 |
|
|
|
1d9674 |
return TRUE;
|
|
|
1d9674 |
}
|
|
|
1d9674 |
|
|
|
1d9674 |
-
|
|
|
1d9674 |
/* Returns the physical address of start of crash notes buffer for a kernel. */
|
|
|
1d9674 |
static int get_sys_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
|
|
|
1d9674 |
{
|
|
|
1d9674 |
@@ -11363,6 +11369,9 @@ main(int argc, char *argv[])
|
|
|
1d9674 |
MSG("Try `makedumpfile --help' for more information.\n");
|
|
|
1d9674 |
goto out;
|
|
|
1d9674 |
}
|
|
|
1d9674 |
+ if (!populate_kernel_version())
|
|
|
1d9674 |
+ goto out;
|
|
|
1d9674 |
+
|
|
|
1d9674 |
if (info->kernel_version < KERNEL_VERSION(4, 11, 0) &&
|
|
|
1d9674 |
!info->flag_force) {
|
|
|
1d9674 |
MSG("mem-usage not supported for this kernel.\n");
|
|
|
1d9674 |
--
|
|
|
1d9674 |
2.7.4
|
|
|
1d9674 |
|