···454454 disables it. Reads from the file return the current value.455455 The default is "1" if the build-time "SUSPEND_SKIP_SYNC" config456456 flag is unset, or "0" otherwise.457457+458458+What: /sys/power/hibernate_compression_threads459459+Date: October 2025460460+Contact: <luoxueqin@kylinos.cn>461461+Description:462462+ Controls the number of threads used for compression463463+ and decompression of hibernation images.464464+465465+ The value can be adjusted at runtime to balance466466+ performance and CPU utilization.467467+468468+ The change takes effect on the next hibernation or469469+ resume operation.470470+471471+ Minimum value: 1472472+ Default value: 3
+10
Documentation/admin-guide/kernel-parameters.txt
···19071907 /sys/power/pm_test). Only available when CONFIG_PM_DEBUG19081908 is set. Default value is 5.1909190919101910+ hibernate_compression_threads=19111911+ [HIBERNATION]19121912+ Set the number of threads used for compressing or decompressing19131913+ hibernation images.19141914+19151915+ Format: <integer>19161916+ Default: 319171917+ Minimum: 119181918+ Example: hibernate_compression_threads=419191919+19101920 highmem=nn[KMG] [KNL,BOOT,EARLY] forces the highmem zone to have an exact19111921 size of <nn>. This works even on boxes that have no19121922 highmem otherwise. This also works to reduce highmem
···11+.. SPDX-License-Identifier: GPL-2.022+33+Debugging Kernel Shutdown Hangs with pstore44++++++++++++++++++++++++++++++++++++++++++++55+66+Overview77+========88+If the system hangs while shutting down, the kernel logs may need to be99+retrieved to debug the issue.1010+1111+On systems that have a UART available, it is best to configure the kernel to use1212+this UART for kernel console output.1313+1414+If a UART isn't available, the ``pstore`` subsystem provides a mechanism to1515+persist this data across a system reset, allowing it to be retrieved on the next1616+boot.1717+1818+Kernel Configuration1919+====================2020+To enable ``pstore`` and enable saving kernel ring buffer logs, set the2121+following kernel configuration options:2222+2323+* ``CONFIG_PSTORE=y``2424+* ``CONFIG_PSTORE_CONSOLE=y``2525+2626+Additionally, enable a backend to store the data. Depending upon your platform2727+some potential options include:2828+2929+* ``CONFIG_EFI_VARS_PSTORE=y``3030+* ``CONFIG_PSTORE_RAM=y``3131+* ``CONFIG_CHROMEOS_PSTORE=y``3232+* ``CONFIG_PSTORE_BLK=y``3333+3434+Kernel Command-line Parameters3535+==============================3636+Add these parameters to your kernel command line:3737+3838+* ``printk.always_kmsg_dump=Y``3939+ * Forces the kernel to dump the entire message buffer to pstore during4040+ shutdown4141+* ``efi_pstore.pstore_disable=N``4242+ * For EFI-based systems, ensures the EFI backend is active4343+4444+Userspace Interaction and Log Retrieval4545+=======================================4646+On the next boot after a hang, pstore logs will be available in the pstore4747+filesystem (``/sys/fs/pstore``) and can be retrieved by userspace.4848+4949+On systemd systems, the ``systemd-pstore`` service will help do the following:5050+5151+#. Locate pstore data in ``/sys/fs/pstore``5252+#. Read and save it to ``/var/lib/systemd/pstore``5353+#. Clear pstore data for the next event
···3434#include <linux/cpufreq.h>3535#include <linux/devfreq.h>3636#include <linux/timer.h>3737+#include <linux/nmi.h>37383839#include "../base.h"3940#include "power.h"···9695 return "restore";9796 case PM_EVENT_RECOVER:9897 return "recover";9898+ case PM_EVENT_POWEROFF:9999+ return "poweroff";99100 default:100101 return "(unknown PM event)";101102 }···370367 case PM_EVENT_FREEZE:371368 case PM_EVENT_QUIESCE:372369 return ops->freeze;370370+ case PM_EVENT_POWEROFF:373371 case PM_EVENT_HIBERNATE:374372 return ops->poweroff;375373 case PM_EVENT_THAW:···405401 case PM_EVENT_FREEZE:406402 case PM_EVENT_QUIESCE:407403 return ops->freeze_late;404404+ case PM_EVENT_POWEROFF:408405 case PM_EVENT_HIBERNATE:409406 return ops->poweroff_late;410407 case PM_EVENT_THAW:···440435 case PM_EVENT_FREEZE:441436 case PM_EVENT_QUIESCE:442437 return ops->freeze_noirq;438438+ case PM_EVENT_POWEROFF:443439 case PM_EVENT_HIBERNATE:444440 return ops->poweroff_noirq;445441 case PM_EVENT_THAW:···521515#define DECLARE_DPM_WATCHDOG_ON_STACK(wd) \522516 struct dpm_watchdog wd523517518518+static bool __read_mostly dpm_watchdog_all_cpu_backtrace;519519+module_param(dpm_watchdog_all_cpu_backtrace, bool, 0644);520520+MODULE_PARM_DESC(dpm_watchdog_all_cpu_backtrace,521521+ "Backtrace all CPUs on DPM watchdog timeout");522522+524523/**525524 * dpm_watchdog_handler - Driver suspend / resume watchdog handler.526525 * @t: The timer that PM watchdog depends on.···541530 unsigned int time_left;542531543532 if (wd->fatal) {533533+ unsigned int this_cpu = smp_processor_id();534534+544535 dev_emerg(wd->dev, "**** DPM device timeout ****\n");545536 show_stack(wd->tsk, NULL, KERN_EMERG);537537+ if (dpm_watchdog_all_cpu_backtrace)538538+ trigger_allbutcpu_cpu_backtrace(this_cpu);546539 panic("%s %s: unrecoverable failure\n",547540 dev_driver_string(wd->dev), dev_name(wd->dev));548541 }
+1-3
drivers/base/power/trace.c
···238238 unsigned int hash = hash_string(DEVSEED, dev_name(dev),239239 DEVHASH);240240 if (hash == value) {241241- int len = snprintf(buf, size, "%s\n",241241+ int len = scnprintf(buf, size, "%s\n",242242 dev_driver_string(dev));243243- if (len > size)244244- len = size;245243 buf += len;246244 ret += len;247245 size -= len;
+11-13
drivers/base/power/wakeup.c
···189189 if (WARN_ON(!ws))190190 return;191191192192+ /*193193+ * After shutting down the timer, wakeup_source_activate() will warn if194194+ * the given wakeup source is passed to it.195195+ */196196+ timer_shutdown_sync(&ws->timer);197197+192198 raw_spin_lock_irqsave(&events_lock, flags);193199 list_del_rcu(&ws->entry);194200 raw_spin_unlock_irqrestore(&events_lock, flags);195201 synchronize_srcu(&wakeup_srcu);196196-197197- timer_delete_sync(&ws->timer);198198- /*199199- * Clear timer.function to make wakeup_source_not_registered() treat200200- * this wakeup source as not registered.201201- */202202- ws->timer.function = NULL;203202}204203205204/**···505506EXPORT_SYMBOL_GPL(device_set_wakeup_enable);506507507508/**508508- * wakeup_source_not_registered - validate the given wakeup source.509509+ * wakeup_source_not_usable - validate the given wakeup source.509510 * @ws: Wakeup source to be validated.510511 */511511-static bool wakeup_source_not_registered(struct wakeup_source *ws)512512+static bool wakeup_source_not_usable(struct wakeup_source *ws)512513{513514 /*514514- * Use timer struct to check if the given source is initialized515515- * by wakeup_source_add.515515+ * Use the timer struct to check if the given wakeup source has been516516+ * initialized by wakeup_source_add() and it is not going away.516517 */517518 return ws->timer.function != pm_wakeup_timer_fn;518519}···557558{558559 unsigned int cec;559560560560- if (WARN_ONCE(wakeup_source_not_registered(ws),561561- "unregistered wakeup source\n"))561561+ if (WARN_ONCE(wakeup_source_not_usable(ws), "unusable wakeup source\n"))562562 return;563563564564 ws->active = true;
···17481748 break;17491749 case PM_EVENT_SUSPEND:17501750 case PM_EVENT_HIBERNATE:17511751+ case PM_EVENT_POWEROFF:17511752 case PM_EVENT_PRETHAW: /* explicitly discard hw state */17521753 port_power(sl811, 0);17531754 break;
+8-4
include/linux/freezer.h
···2222extern unsigned int freeze_timeout_msecs;23232424/*2525- * Check if a process has been frozen2525+ * Check if a process has been frozen for PM or cgroup1 freezer. Note that2626+ * cgroup2 freezer uses the job control mechanism and does not interact with2727+ * the PM freezer.2628 */2729extern bool frozen(struct task_struct *p);28302931extern bool freezing_slow_path(struct task_struct *p);30323133/*3232- * Check if there is a request to freeze a process3434+ * Check if there is a request to freeze a task from PM or cgroup1 freezer.3535+ * Note that cgroup2 freezer uses the job control mechanism and does not3636+ * interact with the PM freezer.3337 */3438static inline bool freezing(struct task_struct *p)3539{···6763extern bool set_freezable(void);68646965#ifdef CONFIG_CGROUP_FREEZER7070-extern bool cgroup_freezing(struct task_struct *task);6666+extern bool cgroup1_freezing(struct task_struct *task);7167#else /* !CONFIG_CGROUP_FREEZER */7272-static inline bool cgroup_freezing(struct task_struct *task)6868+static inline bool cgroup1_freezing(struct task_struct *task)7369{7470 return false;7571}
+6-2
include/linux/pm.h
···25252626struct device; /* we have a circular dep with device.h */2727#ifdef CONFIG_VT_CONSOLE_SLEEP2828-extern void pm_vt_switch_required(struct device *dev, bool required);2828+extern int pm_vt_switch_required(struct device *dev, bool required);2929extern void pm_vt_switch_unregister(struct device *dev);3030#else3131-static inline void pm_vt_switch_required(struct device *dev, bool required)3131+static inline int pm_vt_switch_required(struct device *dev, bool required)3232{3333+ return 0;3334}3435static inline void pm_vt_switch_unregister(struct device *dev)3536{···508507 * RECOVER Creation of a hibernation image or restoration of the main509508 * memory contents from a hibernation image has failed, call510509 * ->thaw() and ->complete() for all devices.510510+ * POWEROFF System will poweroff, call ->poweroff() for all devices.511511 *512512 * The following PM_EVENT_ messages are defined for internal use by513513 * kernel subsystems. They are never issued by the PM core.···539537#define PM_EVENT_USER 0x0100540538#define PM_EVENT_REMOTE 0x0200541539#define PM_EVENT_AUTO 0x0400540540+#define PM_EVENT_POWEROFF 0x0800542541543542#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)544543#define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND)···554551#define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, })555552#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, })556553#define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, })554554+#define PMSG_POWEROFF ((struct pm_message){ .event = PM_EVENT_POWEROFF, })557555#define PMSG_RESUME ((struct pm_message){ .event = PM_EVENT_RESUME, })558556#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, })559557#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, })