Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-09 Thread Eric DeVolder




On 11/9/22 15:31, Borislav Petkov wrote:

On Wed, Nov 09, 2022 at 09:48:33AM -0600, Eric DeVolder wrote:

...
which then defaults HOTPLUG_CPU to on and thus this code/ifdef in question.


defconfig can sometimes lag reality. In this case, the majority of
machines have SMP=y because the majority of machines out there are,
well, multicore.


So at this point, I'm still not sure if you want the ifdef line:
  - removed altogether
  - transitioned to CRASH_HOTPLUG
  - leave as is


So let's think out loud:

* the majority of machines will have CONFIG_HOTPLUG_CPU=y because
they're SMP machines and we want the elfcorehdr updates to happen when
CPUs get offlined or onlined.

CONFIG_MEMORY_HOTPLUG is most likely going to be =n on the majority of
machines out there.

(Note how the deciding factor for all this is what would make sense on
the prevailing majority of machines out there.)

And memory hotplug will be off for the simple reason that not so many
machines have memory hotplug hardware capability.

Which then means, IMHO, this functionality should be separate: have a
CPU hotplug callback and a memory hotplug callback.

And you kinda do that in

Subject: [PATCH v13 3/7] crash: add generic infrastructure for crash hotplug 
support

but then this all calls into a single handle_hotplug_event() and that
hp_action doesn't really matter.

It is used in the call to

   arch_crash_handle_hotplug_event(image, hp_action);

but that hp_action argument is unused in the x86 version. >
IOW, you can do this callback regardless whether it is a CPU or memory
hotplug event.

So thinking about it, a single CONFIG_CRASH_HOTPLUG which unifies those
CPU and memory hotplug callback functionality makes most sense to me.
Because you don't really differentiate between the two in the callback
actions.

Anyway, this is how I see it from here. I could very well be missing an
aspect, of course.

Thx.


OK, I'll put in CRASH_HOTPLUG! Expect v14 soon!
Thank you!
eric

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-09 Thread Borislav Petkov
On Wed, Nov 09, 2022 at 09:48:33AM -0600, Eric DeVolder wrote:
> ...
> which then defaults HOTPLUG_CPU to on and thus this code/ifdef in question.

defconfig can sometimes lag reality. In this case, the majority of
machines have SMP=y because the majority of machines out there are,
well, multicore.

> So at this point, I'm still not sure if you want the ifdef line:
>  - removed altogether
>  - transitioned to CRASH_HOTPLUG
>  - leave as is

So let's think out loud:

* the majority of machines will have CONFIG_HOTPLUG_CPU=y because
they're SMP machines and we want the elfcorehdr updates to happen when
CPUs get offlined or onlined.

CONFIG_MEMORY_HOTPLUG is most likely going to be =n on the majority of
machines out there.

(Note how the deciding factor for all this is what would make sense on
the prevailing majority of machines out there.)

And memory hotplug will be off for the simple reason that not so many
machines have memory hotplug hardware capability.

Which then means, IMHO, this functionality should be separate: have a
CPU hotplug callback and a memory hotplug callback.

And you kinda do that in

Subject: [PATCH v13 3/7] crash: add generic infrastructure for crash hotplug 
support

but then this all calls into a single handle_hotplug_event() and that
hp_action doesn't really matter.

It is used in the call to

  arch_crash_handle_hotplug_event(image, hp_action);

but that hp_action argument is unused in the x86 version.

IOW, you can do this callback regardless whether it is a CPU or memory
hotplug event.

So thinking about it, a single CONFIG_CRASH_HOTPLUG which unifies those
CPU and memory hotplug callback functionality makes most sense to me.
Because you don't really differentiate between the two in the callback
actions.

Anyway, this is how I see it from here. I could very well be missing an
aspect, of course.

Thx.

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-09 Thread Eric DeVolder




On 11/2/22 04:26, Borislav Petkov wrote:

On Tue, Nov 01, 2022 at 10:45:00AM -0500, Eric DeVolder wrote:

As I'm re-reading that message, I suspect now the preference is to just to
strike this ifdiffery line in this file and have the code always present?

If the preference is actually for CRASH_HOTPLUG, then let me know.


Well, it is this part:

"But on a plain simple laptop or workstation which has CPU hotplug,
would it make sense for the crash ranges to get updated too when CPUs
are offlined?

If so, I think you want this code present there too, without a Kconfig
item."

IOW, if this thing doesn't make sense to have on the majority of
machines out there - and memory hotplug machines are not the majority -
then it should be behind a Kconfig item which is default off and gets
enabled only when the user selects crash and memory hotplug...

I'd say.


Boris,
I apologize for the delay in responding, I've been away for the past week.

I'm re-reading the thread on this topic, and I apologize for backing up a bit,
but as I read the last paragraph again, your contention is that the bit of
code in this file *should* be behind a Kconfig item, and default to off, as
"memory hotplug machines are not the majority".

Does this mean then that I need to introduce CRASH_HOTPLUG again, so it can be
default off?

Examining arch/x86/configs/x86_64_defconfig, neither HOTPLUG_CPU or MEMORY_HOTPLUG are present, but 
CONFIG_SMP=y.


And in examining arch/x86/Kconfig, I see:

config HOTPLUG_CPU
def_bool y
depends on SMP

which then defaults HOTPLUG_CPU to on and thus this code/ifdef in question.

And as a reminder, the '#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)' shows up 
in only three locations: include/linux/kexec.h,  kernel/crash_core.c and arch/x86/kernel/crash.c.


And we resolved in this thread last week that this patch series is useful for 
cpu and/or memory hotplug.

So at this point, I'm still not sure if you want the ifdef line:
 - removed altogether
 - transitioned to CRASH_HOTPLUG
 - leave as is

If I could get clarity on that, that would be much appreciated!
Thanks!
eric




___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Borislav Petkov
On Wed, Nov 02, 2022 at 01:57:14PM -0500, Eric DeVolder wrote:
> But I sense I missing your point?

No no, you're spot on. So moving that into the kernel and making it more
robust is always a good thing.

Thx.

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Eric DeVolder




On 11/2/22 13:49, Borislav Petkov wrote:

On Wed, Nov 02, 2022 at 11:54:08AM -0500, Eric DeVolder wrote:

Technically the answer is no; cpu hotplug events are independent of memory
hotplug events, but both are written into the elfcorehdr, so in reality
yes... The elfcorehdr contains a single list of Phdrs describing CPUs and
crash memory ranges; the entire list is re-written on a hotplug change.


Then technically also yes. Otherwise your crash information will contain
wrong CPU numbers.

How has that not been a problem until now...?

I.e., offline a bunch of CPUs and then cause a crash dump.

Hmm.



There is a solution for updating the elfcorehdr today, for when say a bunch of CPUs are offlined. It 
is done via userspace udev rules to do a unload-then-reload of the entire crash kernel system 
(kernel, initrd, purgatory, boot_params, and of course elfcorehdr). This performs extremely poorly 
in highly dynamic hotplug situations (such as when adding alot of memory to a vm), and thus the 
attempt at this solution.


But I sense I missing your point?

Thanks!
eric

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Borislav Petkov
On Wed, Nov 02, 2022 at 11:54:08AM -0500, Eric DeVolder wrote:
> Technically the answer is no; cpu hotplug events are independent of memory
> hotplug events, but both are written into the elfcorehdr, so in reality
> yes... The elfcorehdr contains a single list of Phdrs describing CPUs and
> crash memory ranges; the entire list is re-written on a hotplug change.

Then technically also yes. Otherwise your crash information will contain
wrong CPU numbers.

How has that not been a problem until now...?

I.e., offline a bunch of CPUs and then cause a crash dump.

Hmm.

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Eric DeVolder




On 11/2/22 11:19, Borislav Petkov wrote:

On Wed, Nov 02, 2022 at 09:55:06AM -0500, Eric DeVolder wrote:

"But on a plain simple laptop or workstation which has CPU hotplug,
would it make sense for the crash ranges to get updated too when CPUs
are offlined?


Yes, it does.


Why?



Technically the answer is no; cpu hotplug events are independent of memory hotplug events, but both 
are written into the elfcorehdr, so in reality yes... The elfcorehdr contains a single list of Phdrs 
describing CPUs and crash memory ranges; the entire list is re-written on a hotplug change.


Eric


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Borislav Petkov
On Wed, Nov 02, 2022 at 09:55:06AM -0500, Eric DeVolder wrote:
> > "But on a plain simple laptop or workstation which has CPU hotplug,
> > would it make sense for the crash ranges to get updated too when CPUs
> > are offlined?
> 
> Yes, it does.

Why?

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Eric DeVolder




On 11/2/22 04:26, Borislav Petkov wrote:

On Tue, Nov 01, 2022 at 10:45:00AM -0500, Eric DeVolder wrote:

As I'm re-reading that message, I suspect now the preference is to just to
strike this ifdiffery line in this file and have the code always present?

If the preference is actually for CRASH_HOTPLUG, then let me know.


Well, it is this part:

"But on a plain simple laptop or workstation which has CPU hotplug,
would it make sense for the crash ranges to get updated too when CPUs
are offlined?


Yes, it does.



If so, I think you want this code present there too, without a Kconfig
item."


Ah, ok.



IOW, if this thing doesn't make sense to have on the majority of
machines out there - and memory hotplug machines are not the majority -
then it should be behind a Kconfig item which is default off and gets
enabled only when the user selects crash and memory hotplug...

I'd say.



Ok, I'll will remove the ifdef line/pair.

Thanks!
eric

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-02 Thread Borislav Petkov
On Tue, Nov 01, 2022 at 10:45:00AM -0500, Eric DeVolder wrote:
> As I'm re-reading that message, I suspect now the preference is to just to
> strike this ifdiffery line in this file and have the code always present?
> 
> If the preference is actually for CRASH_HOTPLUG, then let me know.

Well, it is this part:

"But on a plain simple laptop or workstation which has CPU hotplug,
would it make sense for the crash ranges to get updated too when CPUs
are offlined?

If so, I think you want this code present there too, without a Kconfig
item."

IOW, if this thing doesn't make sense to have on the majority of
machines out there - and memory hotplug machines are not the majority -
then it should be behind a Kconfig item which is default off and gets
enabled only when the user selects crash and memory hotplug...

I'd say.

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-11-01 Thread Eric DeVolder




On 10/31/22 16:04, Borislav Petkov wrote:

On Mon, Oct 31, 2022 at 03:36:04PM -0400, Eric DeVolder wrote:

+#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)


What happened to that here:

https://lore.kernel.org/r/y1e85gqb3kzlx...@zn.tnic

?



When I was evaluating the suggestions, I realized that that particular ifdiffery was now used in 
only 3 locations, twice in kernel/crash_core.c and once in x86 crash.c.


With that realization, and the fact that we just jettisoned CONFIG_CRASH_MAX_MEMORY_RANGES for a 
#define, it seemed that there wasn't a compelling need to replace the HOTPLUG_CPU || MEMORY_HOTPLUG 
with a new CRASH_HOTPLUG Kconfig item.


As I'm re-reading that message, I suspect now the preference is to just to strike this ifdiffery 
line in this file and have the code always present?


If the preference is actually for CRASH_HOTPLUG, then let me know.

Thanks!
eric

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v13 7/7] x86/crash: add x86 crash hotplug support

2022-10-31 Thread Borislav Petkov
On Mon, Oct 31, 2022 at 03:36:04PM -0400, Eric DeVolder wrote:
> +#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)

What happened to that here:

https://lore.kernel.org/r/y1e85gqb3kzlx...@zn.tnic

?

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec