linux/drivers
Eric DeVolder 88a6f89944 crash: memory and CPU hotplug sysfs attributes
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>
2023-08-24 16:25:14 -07:00
..
accel Memory leak fixes in drm/client, memory access/leak fixes for 2023-07-21 12:14:05 +10:00
accessibility
acpi ACPI/IORT: Remove erroneous id_count check in iort_node_get_rmr_info() 2023-07-28 14:50:50 +01:00
amba
android
ata ata: libata-core: fix when to fetch sense data for successful commands 2023-07-28 11:30:34 +09:00
atm
auxdisplay
base crash: memory and CPU hotplug sysfs attributes 2023-08-24 16:25:14 -07:00
bcma
block A patch to reduce the potential for erroneous RBD exclusive lock 2023-07-28 10:47:24 -07:00
bluetooth Bluetooth: btusb: Fix bluetooth on Intel Macbook 2014 2023-07-20 11:26:56 -07:00
bus SoC fixes for 6.5, part 1 2023-07-06 09:56:53 -07:00
cdrom
cdx
char tpm_tis: Explicitly check for error code 2023-07-28 18:13:39 +00:00
clk Another set of clk driver updates and fixes for the merge window. The 2023-07-04 11:07:45 -07:00
clocksource
comedi
connector
counter
cpufreq cpufreq: sparc: Don't mark cpufreq callbacks with __init 2023-07-12 12:45:18 +02:00
cpuidle
crypto s390 updates for 6.5 merge window part 2 2023-07-06 13:18:30 -07:00
cxl cxl/acpi: Return 'rc' instead of '0' in cxl_parse_cfmws() 2023-07-18 11:55:09 -06:00
dax
dca
devfreq
dio
dma dmaengine updates for v6.5 2023-07-06 09:48:31 -07:00
dma-buf dma-buf/dma-resv: Stop leaking on krealloc() failure 2023-07-15 13:57:30 +02:00
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio gpio: mvebu: fix irq domain leak 2023-07-20 14:38:36 +02:00
gpu drm/i915: Move abs_diff() to math.h 2023-08-18 10:18:59 -07:00
greybus
hid for-linus-2023071101 2023-07-12 11:56:22 -07:00
hsi
hte
hv
hwmon hwmon: (k10temp) Enable AMD3255 Proc to show negative temperature 2023-07-27 09:41:07 -07:00
hwspinlock
hwtracing
i2c Part 2 of I2C patches for 6.5 2023-07-08 12:28:00 -07:00
i3c
idle Revert "intel_idle: Add support for using intel_idle in a VM guest using just hlt" 2023-07-19 20:10:03 +02:00
iio
infiniband RDMA/irdma: Report correct WC error 2023-07-26 14:58:42 +03:00
input
interconnect
iommu iommufd: Set end correctly when doing batch carry 2023-07-27 11:27:20 -03:00
ipack
irqchip irqchip/al-fic: make AL_FIC depend on HAS_IOMEM 2023-08-18 10:18:51 -07:00
isdn
leds
macintosh
mailbox
mcb
md dm cache policy smq: ensure IO doesn't prevent cleaner policy progress 2023-07-25 11:55:50 -04:00
media media: verisilicon: change confusingly named relaxed register access 2023-07-14 09:14:10 +02:00
memory asm-generic updates for 6.5 2023-07-06 10:06:04 -07:00
memstick
message
mfd
misc misc/genalloc: Name subpools by of_node_full_name() 2023-07-26 09:45:01 +02:00
mmc
most
mtd
mux
net net: altera-tse: make ALTERA_TSE depend on HAS_IOMEM 2023-08-18 10:18:51 -07:00
nfc
ntb ntb: hw: amd: Fix debugfs_create_dir error checking 2023-07-08 13:55:44 -04:00
nubus
nvdimm
nvme SCSI fixes on 20230714 2023-07-14 19:57:29 -07:00
nvmem
of of: Preserve "of-display" device name for compatibility 2023-07-11 16:33:01 -06:00
opp
parisc
parport
pci Fixes for pci_clean_master, error handling in driver inits, and various 2023-07-09 09:35:51 -07:00
pcmcia
peci
perf perf: RISC-V: Remove PERF_HES_STOPPED flag checking in riscv_pmu_start() 2023-07-12 07:41:23 -07:00
phy phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe() 2023-07-24 16:23:37 +05:30
pinctrl pinctrl: renesas: Fixes for v6.5 2023-07-13 00:05:52 +02:00
platform platform/x86: huawei-wmi: Silence ambient light sensor 2023-07-25 16:38:03 +02:00
pnp
power power supply and reset changes for the 6.5 series 2023-07-03 17:23:16 -07:00
powercap
pps
ps3
ptp ptp: Make max_phase_adjustment sysfs device attribute invisible when not supported 2023-07-03 13:17:25 -07:00
pwm pwm: Changes for v6.5-rc1 2023-07-05 12:55:06 -07:00
rapidio
ras
regulator regulator: mt6358: Fix incorrect VCN33 sync error message 2023-07-23 23:40:09 +01:00
remoteproc remoteproc updates for v6.5 2023-07-03 17:03:05 -07:00
reset
rpmsg
rtc
s390 block-6.5-2023-07-28 2023-07-28 10:23:41 -07:00
sbus
scsi scsi: sg: Fix checking return value of blk_get_queue() 2023-07-19 23:12:13 -04:00
sh
siox
slimbus
soc USB / Thunderbolt driver updates for 6.5-rc1 2023-07-03 13:23:10 -07:00
soundwire soundwire: amd: Fix a check for errors in probe() 2023-07-13 11:09:07 +05:30
spi spi: spi-qcom-qspi: Add mem_ops to avoid PIO for badly sized reads 2023-07-26 12:47:20 +01:00
spmi
ssb
staging Staging driver fixes for 6.5-rc4 2023-07-30 11:47:56 -07:00
target SCSI misc on 20230708 2023-07-08 12:35:18 -07:00
tc
tee
thermal thermal: of: fix double-free on unregistration 2023-07-24 09:51:31 +02:00
thunderbolt
tty kill do_each_thread() 2023-08-21 13:46:25 -07:00
ufs Merge branch '6.5/scsi-staging' into 6.5/scsi-fixes 2023-07-11 12:15:15 -04:00
uio
usb usb: misc: ehset: fix wrong if condition 2023-07-27 10:37:30 +02:00
vdpa virtio: features, fixes, cleanups 2023-07-03 15:38:26 -07:00
vfio
vhost virtio: features, fixes, cleanups 2023-07-03 15:38:26 -07:00
video drm/i915: Move abs_diff() to math.h 2023-08-18 10:18:59 -07:00
virt
virtio
vlynq
w1
watchdog
xen xen: speed up grant-table reclaim 2023-07-27 07:53:12 +02:00
zorro
Kconfig
Makefile