Centos-kernel-stream-9/Documentation/admin-guide/mm
Mark Langsdorf 013a5d02a3 crash: memory and CPU hotplug sysfs attributes
JIRA: https://issues.redhat.com/browse/RHEL-26183
Conflicts:
	Documentation/ABI/testing/sysfs-devices-system-cpu -
The crash_hotplug text was added to the end of the file
in upstream, so I did the same here.
	include/linux/kexec.h - minor context differences

commit 88a6f89944216b028d3872b0cec0f51a2f955460
Author: Eric DeVolder <eric.devolder@oracle.com>
Date: Thu, 24 Aug 2023 16:25:14 +0000

Introduce the crash_hotplug attribute for memory and CPUs for use by
userspace.  These attributes directly facilitate the udev rule for
managing userspace re-loading of the crash kernel upon hot un/plug
changes.

For memory, expose the crash_hotplug attribute to the
/sys/devices/system/memory directory.  For example:

 # udevadm info --attribute-walk /sys/devices/system/memory/memory81
  looking at device '/devices/system/memory/memory81':
    KERNEL=="memory81"
    SUBSYSTEM=="memory"
    DRIVER==""
    ATTR{online}=="1"
    ATTR{phys_device}=="0"
    ATTR{phys_index}=="00000051"
    ATTR{removable}=="1"
    ATTR{state}=="online"
    ATTR{valid_zones}=="Movable"

  looking at parent device '/devices/system/memory':
    KERNELS=="memory"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{auto_online_blocks}=="offline"
    ATTRS{block_size_bytes}=="8000000"
    ATTRS{crash_hotplug}=="1"

For CPUs, expose the crash_hotplug attribute to the
/sys/devices/system/cpu directory. For example:

 # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0
  looking at device '/devices/system/cpu/cpu0':
    KERNEL=="cpu0"
    SUBSYSTEM=="cpu"
    DRIVER=="processor"
    ATTR{crash_notes}=="277c38600"
    ATTR{crash_notes_size}=="368"
    ATTR{online}=="1"

  looking at parent device '/devices/system/cpu':
    KERNELS=="cpu"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{crash_hotplug}=="1"
    ATTRS{isolated}==""
    ATTRS{kernel_max}=="8191"
    ATTRS{nohz_full}=="  (null)"
    ATTRS{offline}=="4-7"
    ATTRS{online}=="0-3"
    ATTRS{possible}=="0-7"
    ATTRS{present}=="0-3"

With these sysfs attributes in place, it is possible to efficiently
instruct the udev rule to skip crash kernel reloading for kernels
configured with crash hotplug support.

For example, the following is the proposed udev rule change for RHEL
system 98-kexec.rules (as the first lines of the rule file):

 # The kernel updates the crash elfcorehdr for CPU and memory changes
 SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end"
 SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end"

When examined in the context of 98-kexec.rules, the above rules test if
crash_hotplug is set, and if so, the userspace initiated
unload-then-reload of the crash kernel is skipped.

CPU and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU
and CONFIG_MEMORY_HOTPLUG kernel config options.  If an architecture
supports, for example, memory hotplug but not CPU hotplug, then the
/sys/devices/system/memory/crash_hotplug attribute file is present, but
the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be
present.  Thus the udev rule skips userspace processing of memory hot
un/plug events, but the udev rule will evaluate false for CPU events, thus
allowing userspace to process CPU hot un/plug events (ie the
unload-then-reload of the kdump capture kernel).

Link: https://lkml.kernel.org/r/20230814214446.6659-5-eric.devolder@oracle.com
Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Akhil Raj <lf32.dev@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Weißschuh <linux@weissschuh.net>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-05-31 15:37:43 -04:00
..
damon Docs/admin-guide/mm/damon/usage: add DAMON debugfs interface deprecation notice 2024-04-29 14:33:22 -04:00
cma_debugfs.rst mm/cma_debug: show complete cma name in debugfs directories 2023-10-20 06:13:26 -04:00
concepts.rst docs: rename Documentation/vm to Documentation/mm 2023-03-24 11:19:15 -04:00
hugetlbpage.rst selftests/vm: rename selftests/vm to selftests/mm 2024-01-19 10:06:45 -07:00
idle_page_tracking.rst tools/vm: rename tools/vm to tools/mm 2024-04-29 14:33:03 -04:00
index.rst mm: multi-gen LRU: admin guide 2023-10-20 06:13:47 -04:00
ksm.rst mm: add new KSM process and sysfs knobs 2024-04-30 07:01:04 -04:00
memory-hotplug.rst crash: memory and CPU hotplug sysfs attributes 2024-05-31 15:37:43 -04:00
multigen_lru.rst mm: multi-gen LRU: admin guide 2023-10-20 06:13:47 -04:00
nommu-mmap.rst
numa_memory_policy.rst Documentation: admin-guide: correct spelling 2023-11-08 08:28:11 -05:00
numaperf.rst Docs/admin-guide/mm/numaperf: increase depth of subsections 2024-04-29 14:33:03 -04:00
pagemap.rst tools/vm: rename tools/vm to tools/mm 2024-04-29 14:33:03 -04:00
shrinker_debugfs.rst mm: shrinkers: add scan interface for shrinker debugfs 2023-03-24 11:19:17 -04:00
soft-dirty.rst
swap_numa.rst Documentation/vm: move user guides to admin-guide/mm/ 2022-04-22 06:15:53 -04:00
transhuge.rst mm/khugepaged: attempt to map file/shmem-backed pte-mapped THPs by pmds 2023-10-20 06:14:50 -04:00
userfaultfd.rst mm/uffd: UFFD_FEATURE_WP_UNPOPULATED 2023-10-20 06:16:02 -04:00
zswap.rst Docs/admin-guide/mm/zswap: remove zsmalloc's lack of writeback warning 2024-04-30 17:51:24 -06:00