Re: [PATCH v12 7/7] x86/crash: Add x86 crash hotplug support

From: Eric DeVolder
Date: Fri Oct 28 2022 - 15:29:58 EST




On 10/28/22 12:06, Borislav Petkov wrote:
On Fri, Oct 28, 2022 at 10:29:45AM -0500, Eric DeVolder wrote:
So it is with this in mind that I suggest we stay with the statically sized elfcorehdr buffer.

If that can be agreed upon, then it is "just a matter" of picking a useful
elfcorehdr size. Currently that size is derived from the NR_DEFAULT_CPUS and
CRASH_MAX_MEMORY_RANGES. So, there is still the CRASH_MAX_MEMORY_RANGES knob
to help a dial in size, should there be some issue with the default
value/size.

Let's see

kbuf.memsz =
(CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES) *
sizeof(Elf64_Phdr);

which, IINM, is

(8192 + 32768) * 56

which is something like 2M.

(CONFIG_NR_CPUS_DEFAULT = 8192 - this is because of MAXSMP which gets
set on distro kernels)

Now, since userspace kexec tools uses 2048 for max memory ranges, that
size becomes smaller - around half a Mb. And since y'all wanna be on the
safe side, you can quadruple it and have

(8192 + 8192) * 56

which is still under a megabyte. And that's fine, I guess, on a big
server.

Excellent, I'll set CRASH_MAX_MEMORY_RANGES to 8192! That seems a quite fair trade off of elfcorehdr size vs system size (ie 1TiB w/ 128MiB memblock size).


Or if there is desire to drop computing the size from NR_DEFAULT_CPUs and

I think you should leave the dependency on the Kconfig size so that
smaller machines which are configured this way, don't end up wasting
unnecessary memory.

Excellent, I'll leave the computation as NR_DEFAULT_CPUS + CRASH_MAX_MEMORY_RANGES.


It is my intention to correct the CRASH_MAX_MEMORY_RANGES (if we keep it) as such:

config CRASH_MAX_MEMORY_RANGES
depends on CRASH_DUMP && KEXEC_FILE && MEMORY_HOTPLUG

Yes, but don't leave it to the user to decide what number to choose
- choose a high enough number, explain why you've chosen this with a
comment and that's it.

I currently have the Kconfig item as:

config CRASH_MAX_MEMORY_RANGES
depends on CRASH_DUMP && KEXEC_FILE && MEMORY_HOTPLUG
int
default 8192
help
For the kexec_file_load path, specify the maximum number of
memory regions, eg. as represented by the 'System RAM' entries
in /proc/iomem, that the elfcorehdr buffer/segment can accommodate.
This value is combined with NR_CPUS and multiplied by Elf64_Phdr
size to determine the final buffer size.

I'll work to provide information a better explanation as to the 8192 number.

Thank you!
eric


Thx.