mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
PM: hibernate: add sysfs interface for hibernate_compression_threads
Add a sysfs attribute `/sys/power/hibernate_compression_threads` to
allow runtime configuration of the number of threads used for
compressing and decompressing hibernation images.
The new sysfs interface enables dynamic adjustment at runtime:
# cat /sys/power/hibernate_compression_threads
3
# echo 4 > /sys/power/hibernate_compression_threads
This change provides greater flexibility for debugging and performance
tuning of hibernation without requiring a reboot.
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
Link: https://patch.msgid.link/c68c62f97fabf32507b8794ad8c16cd22ee656ac.1761046167.git.luoxueqin@kylinos.cn
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
090bf5a0f4
commit
ea358066de
@@ -454,3 +454,19 @@ Description:
|
|||||||
disables it. Reads from the file return the current value.
|
disables it. Reads from the file return the current value.
|
||||||
The default is "1" if the build-time "SUSPEND_SKIP_SYNC" config
|
The default is "1" if the build-time "SUSPEND_SKIP_SYNC" config
|
||||||
flag is unset, or "0" otherwise.
|
flag is unset, or "0" otherwise.
|
||||||
|
|
||||||
|
What: /sys/power/hibernate_compression_threads
|
||||||
|
Date: October 2025
|
||||||
|
Contact: <luoxueqin@kylinos.cn>
|
||||||
|
Description:
|
||||||
|
Controls the number of threads used for compression
|
||||||
|
and decompression of hibernation images.
|
||||||
|
|
||||||
|
The value can be adjusted at runtime to balance
|
||||||
|
performance and CPU utilization.
|
||||||
|
|
||||||
|
The change takes effect on the next hibernation or
|
||||||
|
resume operation.
|
||||||
|
|
||||||
|
Minimum value: 1
|
||||||
|
Default value: 3
|
||||||
|
|||||||
@@ -1689,8 +1689,46 @@ int swsusp_unmark(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static ssize_t hibernate_compression_threads_show(struct kobject *kobj,
|
||||||
|
struct kobj_attribute *attr, char *buf)
|
||||||
|
{
|
||||||
|
return sysfs_emit(buf, "%d\n", hibernate_compression_threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t hibernate_compression_threads_store(struct kobject *kobj,
|
||||||
|
struct kobj_attribute *attr,
|
||||||
|
const char *buf, size_t n)
|
||||||
|
{
|
||||||
|
unsigned long val;
|
||||||
|
|
||||||
|
if (kstrtoul(buf, 0, &val))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (val < 1)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
hibernate_compression_threads = val;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
power_attr(hibernate_compression_threads);
|
||||||
|
|
||||||
|
static struct attribute *g[] = {
|
||||||
|
&hibernate_compression_threads_attr.attr,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group attr_group = {
|
||||||
|
.attrs = g,
|
||||||
|
};
|
||||||
|
|
||||||
static int __init swsusp_header_init(void)
|
static int __init swsusp_header_init(void)
|
||||||
{
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = sysfs_create_group(power_kobj, &attr_group);
|
||||||
|
if (error)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
|
swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
|
||||||
if (!swsusp_header)
|
if (!swsusp_header)
|
||||||
panic("Could not allocate memory for swsusp_header\n");
|
panic("Could not allocate memory for swsusp_header\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user