All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: Changed CMP_THREADS from hardwired value to configurable value
@ 2025-02-14 11:57 Jay Penny
  0 siblings, 0 replies; only message in thread
From: Jay Penny @ 2025-02-14 11:57 UTC (permalink / raw)
  To: rafael; +Cc: linux-kernel

From a873292405b37921d6a7428a7e9263f662e957cf Mon Sep 17 00:00:00 2001
From: Jay Penny <hills.a.joel@gmail.com>
Date: Fri, 14 Feb 2025 22:27:39 +1100
Subject: [PATCH] power: Changed CMP_THREADS from hardwired value to
 configurable value

I don't know what the rules are (unspoken or otherwise) for stating
that this is your patch - The CoC doesn't say anything regarding it,
so I'm just going to mention it here. This is my first kernel patch,
so if I mess something up, it's due to a lack of experience on my part.

Changed CMP_THREADS in kernel/power/swap.c from a hardwired 3 threads,
to a configurable one, and created a corresponding config option in
kernel/power/Kconfig.

The fact that this is such a simple change that hasn't been made yet
probably means that it shouldn't be made. That, or I'm just being
pessimistic.

Signed-off-by: Jay Penny <hills.a.joel@gmail.com>
---
 kernel/power/Kconfig | 13 +++++++++++++
 kernel/power/swap.c  |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index ca947ed32e3d..432e75c76c49 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -80,6 +80,19 @@ config HIBERNATION
 
 	  For more information take a look at
<file:Documentation/power/swsusp.rst>.
 
+config HIBERNATION_THREADS
+	int "Hibernation threads"
+	depends on HIBERNATION
+	range 1 65535
+	default 3
+	help
+	  The maximum number of threads that should be used when
+	  compressing/decompressing a hibernation image. The number
+	  of threads used is calculated as:
+	  clamp(num_online_cpus() - 1, 1, HIBERNATION_THREADS).
+
+	  If in doubt, leave at the default of 3
+
 config HIBERNATION_SNAPSHOT_DEV
 	bool "Userspace snapshot device"
 	depends on HIBERNATION
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 82b884b67152..6ac787f8421a 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -534,7 +534,7 @@ static int swap_writer_finish(struct
swap_map_handle *handle,
 #define CMP_SIZE	(CMP_PAGES * PAGE_SIZE)
 
 /* Maximum number of threads for compression/decompression. */
-#define CMP_THREADS	3
+#define CMP_THREADS	CONFIG_HIBERNATION_THREADS
 
 /* Minimum/maximum number of pages for read buffering. */
 #define CMP_MIN_RD_PAGES	1024
-- 
2.48.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-14 11:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 11:57 [PATCH] power: Changed CMP_THREADS from hardwired value to configurable value Jay Penny

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.