diff options
author | Bhupesh Sharma <bhsharma@redhat.com> | 2017-11-17 06:30:41 +0900 |
---|---|---|
committer | Atsushi Kumagai <ats-kumagai@wm.jp.nec.com> | 2018-01-23 11:41:25 +0900 |
commit | d1ffe82bb5063048be1900fbf60d3074cae9392b (patch) | |
tree | 56818bd15ec7b0e2bc1b6b0a86591fc5fc63b99a /makedumpfile.c | |
parent | 0df157a0fcbaed97153740291e5223b2f448723d (diff) |
[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
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
Diffstat (limited to 'makedumpfile.c')
-rw-r--r-- | makedumpfile.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/makedumpfile.c b/makedumpfile.c index 106f55b..15e869a 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -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; } @@ -10960,20 +10972,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) { @@ -11350,6 +11356,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"); |