From 071ea2a277e5b57bd0734a59a107e5876b152ed8 Mon Sep 17 00:00:00 2001 From: Xunlei Pang Date: Sat, 29 Apr 2017 09:15:00 +0800 Subject: [PATCH] kdumpctl: bail out earlier in case of no reserved memory Some cloud people complained that VM boot speed is slower than Ubuntu and other distributions, after some debugging, we found that one of the causes is kdump service starts too slow(7seconds according to the test result on the test VM), actually there is no "crashkernel=X" specified. Although kdump service is parallel, it affects the speed more or less especially on VMs with few cpus, which is unacceptable. It is even worse when kdump initramfs is built out in case of no reserved memory at first boot. Commit afa4a35d3 ("kdumpctrl: kdump feasibility should fail if no crash memory") can actually solve this issue. This patch is a supplement of above-mentioned commit, we bail out start() even earlier in case of no reserved memory. Also made some cosmatic changes for check_crash_mem_reserved(). 1) Before this patch $ time kdumpctl start No memory reserved for crash kernel. Starting kdump: [FAILED] real 0m0.282s user 0m0.184s sys 0m0.146s 2) After this patch $ time kdumpctl start No memory reserved for crash kernel Starting kdump: [FAILED] real 0m0.010s user 0m0.008s sys 0m0.001s Signed-off-by: Xunlei Pang Acked-by: Pratyush Anand Acked-by: Dave Young --- kdumpctl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kdumpctl b/kdumpctl index 6b5be09..129cb6a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1074,10 +1074,11 @@ is_secure_boot_enforced() check_crash_mem_reserved() { - MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size) - if [ $MEM_RESERVED -eq 0 ] - then - echo "No memory reserved for crash kernel." >&2 + local mem_reserved + + mem_reserved=$(cat /sys/kernel/kexec_crash_size) + if [ $mem_reserved -eq 0 ]; then + echo "No memory reserved for crash kernel" return 1 fi @@ -1163,6 +1164,12 @@ check_default_config() start() { + check_dump_feasibility + if [ $? -ne 0 ]; then + echo "Starting kdump: [FAILED]" + return 1 + fi + check_config if [ $? -ne 0 ]; then echo "Starting kdump: [FAILED]" @@ -1172,13 +1179,8 @@ start() if sestatus 2>/dev/null | grep -q "SELinux status.*enabled"; then selinux_relabel fi - save_raw - if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" - return 1 - fi - check_dump_feasibility + save_raw if [ $? -ne 0 ]; then echo "Starting kdump: [FAILED]" return 1