From ee9505724799ca4ad7daa7e57e6954ac1b368cf2dc46f1a0c91c3d9d3c80dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 23 Jun 2017 12:09:29 +0000 Subject: [PATCH] Accepting request 505875 from home:ptesarik:branches:Kernel:kdump Improve SMP handling OBS-URL: https://build.opensuse.org/request/show/505875 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=135 --- ...-move-class-SystemCPU-to-header-file.patch | 139 ++++++++++++++ kdump-multithreading-by-default.patch | 116 ++++++++++++ ...t-KDUMP_CPUS-0-as-all-available-CPUs.patch | 176 ++++++++++++++++++ kdump.changes | 10 + kdump.spec | 6 + 5 files changed, 447 insertions(+) create mode 100644 kdump-move-class-SystemCPU-to-header-file.patch create mode 100644 kdump-multithreading-by-default.patch create mode 100644 kdump-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch diff --git a/kdump-move-class-SystemCPU-to-header-file.patch b/kdump-move-class-SystemCPU-to-header-file.patch new file mode 100644 index 0000000..8f3309f --- /dev/null +++ b/kdump-move-class-SystemCPU-to-header-file.patch @@ -0,0 +1,139 @@ +From: Petr Tesarik +Date: Fri Jun 23 13:19:41 2017 +0200 +Subject: Move class SystemCPU to a header file +References: bsc#1036223 +Upstream: v0.8.17 +Git-commit: ded0d2117cce72fc98a7ca9ee577090889ef9b16 + +This allows to reuse the class outside of calibrate.cc. + +Signed-off-by: Petr Tesarik + +--- + kdumptool/calibrate.cc | 47 --------------------------------------------- + kdumptool/calibrate.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 51 insertions(+), 47 deletions(-) + +--- a/kdumptool/calibrate.cc ++++ b/kdumptool/calibrate.cc +@@ -251,53 +251,6 @@ using std::ifstream; + + //{{{ SystemCPU ---------------------------------------------------------------- + +-class SystemCPU { +- +- public: +- /** +- * Initialize a new SystemCPU object. +- * +- * @param[in] sysdir Mount point for sysfs +- */ +- SystemCPU(const char *sysdir = "/sys") +- throw () +- : m_cpudir(FilePath(sysdir).appendPath("devices/system/cpu")) +- {} +- +- protected: +- /** +- * Path to the cpu system devices base directory +- */ +- const FilePath m_cpudir; +- +- /** +- * Count the number of CPUs in a cpuset +- * +- * @param[in] name Name of the cpuset ("possible", "present", "online") +- * +- * @exception KError if the file cannot be opened or parsed +- */ +- unsigned long count(const char *name); +- +- public: +- /** +- * Count the number of online CPUs +- * +- * @exception KError see @c count() +- */ +- unsigned long numOnline(void) +- { return count("online"); } +- +- /** +- * Count the number of offline CPUs +- * +- * @exception KError see @c count() +- */ +- unsigned long numOffline(void) +- { return count("offline"); } +- +-}; +- + // ----------------------------------------------------------------------------- + unsigned long SystemCPU::count(const char *name) + { +--- a/kdumptool/calibrate.h ++++ b/kdumptool/calibrate.h +@@ -20,6 +20,7 @@ + #define CALIBRATE_H + + #include "subcommand.h" ++#include "fileutil.h" + + //{{{ Calibrate ---------------------------------------------------------------- + +@@ -54,6 +55,56 @@ class Calibrate : public Subcommand { + }; + + //}}} ++//{{{ SystemCPU ---------------------------------------------------------------- ++ ++class SystemCPU { ++ ++ public: ++ /** ++ * Initialize a new SystemCPU object. ++ * ++ * @param[in] sysdir Mount point for sysfs ++ */ ++ SystemCPU(const char *sysdir = "/sys") ++ throw () ++ : m_cpudir(FilePath(sysdir).appendPath("devices/system/cpu")) ++ {} ++ ++ protected: ++ /** ++ * Path to the cpu system devices base directory ++ */ ++ const FilePath m_cpudir; ++ ++ /** ++ * Count the number of CPUs in a cpuset ++ * ++ * @param[in] name Name of the cpuset ("possible", "present", "online") ++ * ++ * @exception KError if the file cannot be opened or parsed ++ */ ++ unsigned long count(const char *name); ++ ++ public: ++ /** ++ * Count the number of online CPUs ++ * ++ * @exception KError see @c count() ++ */ ++ unsigned long numOnline(void) ++ { return count("online"); } ++ ++ /** ++ * Count the number of offline CPUs ++ * ++ * @exception KError see @c count() ++ */ ++ unsigned long numOffline(void) ++ { return count("offline"); } ++ ++}; ++ ++//}}} + + #endif /* CALIBRATE_H */ + diff --git a/kdump-multithreading-by-default.patch b/kdump-multithreading-by-default.patch new file mode 100644 index 0000000..c81c45c --- /dev/null +++ b/kdump-multithreading-by-default.patch @@ -0,0 +1,116 @@ +From: Petr Tesarik +Date: Fri Jun 23 13:47:28 2017 +0200 +Subject: Multithreading by default +References: bsc#1036223 +Upstream: v0.8.17 +Git-commit: 07534f44546e37c65a08fe7fb093255fbca6cd30 + +The "--num-threads" and "--split" makedumpfile options are mutually +exclusive. Before multithreading was implemented, "--split" was the +only way to use any additional CPUs. It makes more sense to use +multithreading by default. + +To use "--split", the SPLIT flag can be specified. + +Signed-off-by: Petr Tesarik + +--- + doc/man/kdump.5.txt.in | 16 +++++++++++----- + kdumptool/savedump.cc | 17 +++++++++++++++++ + kdumptool/savedump.h | 1 + + sysconfig.kdump.in | 5 +++-- + 4 files changed, 32 insertions(+), 7 deletions(-) + +--- a/doc/man/kdump.5.txt.in ++++ b/doc/man/kdump.5.txt.in +@@ -513,11 +513,17 @@ This is a space-separated list of flags + Because SFTP and FTP are not mounted, that option has no meaning when saving + the dump to SFTP and FTP. + +-*NOSPLIT*:: +- Disable the _--split_ option of *makedumpfile*(8). This option is normally +- added when KDUMP_CPUS>1, because otherwise the additional CPUs are idle. +- You can specify this flag to force the use of only one dumping process, +- regardless of the value of KDUMP_CPUS. ++*SPLIT*:: ++ If KDUMP_CPUS>1, use the _--split_ option of *makedumpfile*(8) instead of ++ the default _--num-threads_. ++ ++*SINGLE*:: ++ Specify this flag to force the use of only one CPU for dumping, regardless ++ of the value of KDUMP_CPUS. ++ It disables the _--split_ and _--num-threads_ options of *makedumpfile*(8). ++ ++ For compatibility with older versions, *NOSPLIT* is an alias for *SINGLE*. ++ Its use is deprecated. + + *XENALLDOMAINS*:: + When dumping a Xen virtualization host, *makedumpfile*(8) is normally +--- a/kdumptool/savedump.cc ++++ b/kdumptool/savedump.cc +@@ -291,11 +291,24 @@ void SaveDump::saveDump(const RootDirURL + cpus = syscpu.numOnline(); + } + if (!config->kdumptoolContainsFlag("NOSPLIT") && ++ !config->kdumptoolContainsFlag("SINGLE") && + cpus > 1) { + if (!useElf) + m_split = cpus; + else + cerr << "Splitting ELF dumps is not supported." << endl; ++ ++ if (config->kdumptoolContainsFlag("SPLIT")) { ++ if (!useElf) ++ m_split = cpus; ++ else ++ cerr << "Splitting ELF dumps is not supported." << endl; ++ } else { ++ if (!useElf) ++ m_threads = cpus - 1; ++ else ++ cerr << "Multithreading is unavailable for ELF dumps" << endl; ++ } + } + + bool excludeDomU = false; +@@ -313,6 +326,10 @@ void SaveDump::saveDump(const RootDirURL + cmdline << "makedumpfile "; + if (m_split) + cmdline << "--split "; ++ if (m_threads) { ++ SystemCPU syscpu; ++ cmdline << "--num-threads " << m_threads << " "; ++ } + cmdline << config->MAKEDUMPFILE_OPTIONS.value() << " "; + cmdline << "-d " << config->KDUMP_DUMPLEVEL.value() << " "; + if (excludeDomU) +--- a/kdumptool/savedump.h ++++ b/kdumptool/savedump.h +@@ -113,6 +113,7 @@ class SaveDump : public Subcommand { + bool m_usedDirectSave; + bool m_useMakedumpfile; + unsigned long m_split; ++ unsigned long m_threads; + std::string m_crashtime; + std::string m_crashrelease; + std::string m_rootdir; +--- a/sysconfig.kdump.in ++++ b/sysconfig.kdump.in +@@ -271,14 +271,15 @@ KDUMP_POSTSCRIPT="" + # + KDUMP_COPY_KERNEL="yes" + +-## Type: string(NOSPARSE,NOSPLIT,XENALLDOMAINS) ++## Type: string(NOSPARSE,SPLIT,SINGLE,XENALLDOMAINS) + ## Default: "" + ## ServiceRestart: kdump + # + # Space-separated list of flags to tweak the run-time behaviour of kdumptool: + # + # NOSPARSE disable creation of sparse files. +-# NOSPLIT do not pass "--split" to makedumpfile even if KDUMP_CPUS > 1 ++# SPLIT split the dump file with "makedumpfile --split" ++# SINGLE use single CPU to save the dump + # XENALLDOMAINS do not filter out Xen DomU pages + # + # See also: kdump(5). diff --git a/kdump-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch b/kdump-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch new file mode 100644 index 0000000..2a194ce --- /dev/null +++ b/kdump-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch @@ -0,0 +1,176 @@ +From: Petr Tesarik +Date: Fri Jun 23 13:43:15 2017 +0200 +Subject: Treat KDUMP_CPUS=0 as "all available CPUs" +References: bsc#1036223 +Upstream: v0.8.17 +Git-commit: 34192abe9a0f5ddbcd580fa52b7fa4400533b9a4 + +Since SMP after crash is now considered stable, remove the warnings and +make the feature more useful by not requiring a fixed number of CPUs. + +Signed-off-by: Petr Tesarik + +--- + doc/man/kdump.5.txt.in | 7 +++---- + init/load.sh | 7 +++++-- + kdumptool/calibrate.cc | 6 +++--- + kdumptool/savedump.cc | 23 ++++++++++++++--------- + kdumptool/savedump.h | 2 +- + sysconfig.kdump.in | 7 +------ + 6 files changed, 27 insertions(+), 25 deletions(-) + +--- a/doc/man/kdump.5.txt.in ++++ b/doc/man/kdump.5.txt.in +@@ -136,13 +136,12 @@ the number of CPUs in your system. + This parameter modifies the _maxcpus_ parameter of the kdump kernel and + the number of *makedumpfile*(8) processes created. + ++If the value is zero, all available CPUs are used, i.e. the _maxcpus_ ++parameter is not added to the kdump kernel command line. ++ + *Note:* This parameter does not work properly for the _ELF_ format, + because *makedumpfile*(8) does not support split _ELF_ dump files. + +-*WARNING:* SETTING THIS NUMBER TO A NUMBER HIGHER THAN 1 IS EXPERIMENTAL! +-SOME MACHINES ARE KNOWN TO HANG OR REBOOT RANDOMLY DURING INITIALISATION +-OF THE DUMP KERNEL IF KDUMP_CPUS > 1. +- + Default is 1. + + +--- a/init/load.sh ++++ b/init/load.sh +@@ -63,14 +63,17 @@ function build_kdump_commandline() + local commandline="$KDUMP_COMMANDLINE" + + if [ -z "$commandline" ] ; then +- local nr_cpus=$(cpus_param "$kdump_kernel") ++ local nr_cpus + commandline=$( + remove_from_commandline \ + 'root|resume|crashkernel|splash|mem|BOOT_IMAGE|showopts|zfcp\.allow_lun_scan|hugepages|acpi_no_memhotplug|cgroup_disable|unknown_nmi_panic|rd\.udev\.children-max' \ + < /proc/cmdline) ++ if [ ${KDUMP_CPUS:-1} -ne 0 ] ; then ++ nr_cpus=$(cpus_param "$kdump_kernel")=${KDUMP_CPUS:-1} ++ fi + # Use deadline for saving the memory footprint + commandline="$commandline elevator=deadline sysrq=yes reset_devices acpi_no_memhotplug cgroup_disable=memory" +- commandline="$commandline irqpoll ${nr_cpus}=${KDUMP_CPUS:-1}" ++ commandline="$commandline irqpoll ${nr_cpus}" + commandline="$commandline root=kdump rootflags=bind rd.udev.children-max=8" + case $(uname -i) in + i?86|x86_64) +--- a/kdumptool/calibrate.cc ++++ b/kdumptool/calibrate.cc +@@ -905,10 +905,10 @@ void Calibrate::execute() + } + + // Add memory based on CPU count +- unsigned long cpus; +- if (CAN_REDUCE_CPUS) { ++ unsigned long cpus = 0; ++ if (CAN_REDUCE_CPUS) + cpus = config->KDUMP_CPUS.value(); +- } else { ++ if (!cpus) { + SystemCPU syscpu; + unsigned long online = syscpu.numOnline(); + unsigned long offline = syscpu.numOffline(); +--- a/kdumptool/savedump.cc ++++ b/kdumptool/savedump.cc +@@ -41,6 +41,7 @@ + #include "identifykernel.h" + #include "email.h" + #include "routable.h" ++#include "calibrate.h" + + using std::string; + using std::list; +@@ -60,7 +61,7 @@ using std::ifstream; + SaveDump::SaveDump() + throw () + : m_dump(DEFAULT_DUMP), m_transfer(NULL), m_usedDirectSave(false), +- m_useMakedumpfile(false), m_useSplit(false), m_nomail(false) ++ m_useMakedumpfile(false), m_split(0), m_nomail(false) + { + Debug::debug()->trace("SaveDump::SaveDump()"); + +@@ -284,10 +285,15 @@ void SaveDump::saveDump(const RootDirURL + if (noDump) + return; // nothing to be done + ++ unsigned long cpus = config->KDUMP_CPUS.value(); ++ if (cpus) { ++ SystemCPU syscpu; ++ cpus = syscpu.numOnline(); ++ } + if (!config->kdumptoolContainsFlag("NOSPLIT") && +- config->KDUMP_CPUS.value() > 1) { ++ cpus > 1) { + if (!useElf) +- m_useSplit = true; ++ m_split = cpus; + else + cerr << "Splitting ELF dumps is not supported." << endl; + } +@@ -305,7 +311,7 @@ void SaveDump::saveDump(const RootDirURL + // use makedumpfile + ostringstream cmdline; + cmdline << "makedumpfile "; +- if (m_useSplit) ++ if (m_split) + cmdline << "--split "; + cmdline << config->MAKEDUMPFILE_OPTIONS.value() << " "; + cmdline << "-d " << config->KDUMP_DUMPLEVEL.value() << " "; +@@ -340,10 +346,9 @@ void SaveDump::saveDump(const RootDirURL + provider->setProgress(&progress); + else + cout << "Saving dump ..." << endl; +- if (m_useSplit) { ++ if (m_split) { + StringVector targets; +- const int cpus = config->KDUMP_CPUS.value(); +- for (int i = 1; i <= cpus; ++i) { ++ for (unsigned long i = 1; i <= m_split; ++i) { + ostringstream ss; + ss << "vmcore" << i; + targets.push_back(ss.str()); +@@ -482,8 +487,8 @@ void SaveDump::generateInfo() + ss << "Dump level : " + << Stringutil::number2string(config->KDUMP_DUMPLEVEL.value()) << endl; + ss << "Dump format : " << config->KDUMP_DUMPFORMAT.value() << endl; +- if (m_useSplit && m_usedDirectSave) +- ss << "Split parts : " << config->KDUMP_CPUS.value() << endl; ++ if (m_split && m_usedDirectSave) ++ ss << "Split parts : " << m_split << endl; + ss << endl; + + +--- a/kdumptool/savedump.h ++++ b/kdumptool/savedump.h +@@ -112,7 +112,7 @@ class SaveDump : public Subcommand { + Transfer *m_transfer; + bool m_usedDirectSave; + bool m_useMakedumpfile; +- bool m_useSplit; ++ unsigned long m_split; + std::string m_crashtime; + std::string m_crashrelease; + std::string m_rootdir; +--- a/sysconfig.kdump.in ++++ b/sysconfig.kdump.in +@@ -18,13 +18,8 @@ KDUMP_KERNELVER="" + # + # Number of CPUs to be used in the kdump environment. You may want to + # increase the number if computing power is the bottleneck in your setup. +-# This value is used as the maxcpus parameter of the secondary kernel, so +-# DON'T CHANGE IT unless your system can reliably re-initialize SMP after +-# a kernel crash. + # +-# WARNING: SETTING THIS NUMBER TO A NUMBER HIGHER THAN 1 IS EXPERIMENTAL! +-# SOME MACHINES ARE KNOWN TO HANG OR REBOOT RANDOMLY DURING INITIALISATION +-# OF THE DUMP KERNEL IF KDUMP_CPUS > 1. ++# If the value is zero, use all available CPUs. + # + # See also: kdump(5). + # diff --git a/kdump.changes b/kdump.changes index 6bb20ea..c26fd39 100644 --- a/kdump.changes +++ b/kdump.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Fri Jun 23 11:51:11 UTC 2017 - ptesarik@suse.com + +- kdump-move-class-SystemCPU-to-header-file.patch: Move class + SystemCPU to a header file (bsc#1036223). +- kdump-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch: Treat + KDUMP_CPUS=0 as "all available CPUs" (bsc#1036223). +- kdump-multithreading-by-default.patch: Use multithreading by + default (bsc#1036223). + ------------------------------------------------------------------- Thu Jun 22 12:42:50 UTC 2017 - ptesarik@suse.com diff --git a/kdump.spec b/kdump.spec index c84aa4d..0b01b56 100644 --- a/kdump.spec +++ b/kdump.spec @@ -61,6 +61,9 @@ Patch16: %{name}-source-save_dump.patch Patch17: %{name}-remount-sysroot-readwrite.patch Patch18: %{name}-fix-save_dump-to-NFS.patch Patch19: %{name}-invoke-subcommand-destructors-on-exit.patch +Patch20: %{name}-move-class-SystemCPU-to-header-file.patch +Patch21: %{name}-treat-KDUMP_CPUS-0-as-all-available-CPUs.patch +Patch22: %{name}-multithreading-by-default.patch BuildRequires: asciidoc BuildRequires: cmake BuildRequires: gcc-c++ @@ -140,6 +143,9 @@ cp %{S:1} tests/data/ %patch17 -p1 %patch18 -p1 %patch19 -p1 +%patch20 -p1 +%patch21 -p1 +%patch22 -p1 %build export CFLAGS="%{optflags}"