lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0go3fOmipsBmmqS9xbKA8AbnMqtu52XsrV3iGYEGhegZw@mail.gmail.com>
Date: Mon, 13 Oct 2025 20:35:44 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Xueqin Luo <luoxueqin@...inos.cn>
Cc: rafael@...nel.org, pavel@...nel.org, lenb@...nel.org, 
	linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] PM: hibernate: make compression threads configurable

On Mon, Sep 15, 2025 at 4:23 AM Xueqin Luo <luoxueqin@...inos.cn> wrote:
>
> The number of compression/decompression threads has a direct impact on
> hibernate image generation and resume latency. Using more threads can
> reduce overall resume time, but on systems with fewer CPU cores it may
> also introduce contention and reduce efficiency.
>
> Performance was evaluated on an 8-core ARM system, averaged over 10 runs:
>
>     cmp_threads   hibernate time (s)   resume time (s)
>     --------------------------------------------------
>           3             12.14              18.86
>           4             12.28              17.48
>           5             11.09              16.77
>           6             11.08              16.44
>
> With 5–6 threads, resume latency improves by approximately 12% compared
> to the default 3-thread configuration, with negligible impact on
> hibernate time.
>
> Introduce a new kernel parameter `cmp_threads=` that allows users and
> integrators to tune the number of compression/decompression threads at
> boot. This provides a way to balance performance and CPU utilization
> across a wide range of hardware without recompiling the kernel.
>
> Signed-off-by: Xueqin Luo <luoxueqin@...inos.cn>
> ---
>  kernel/power/swap.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index f8c13f5672ec..dfa9b7c0f96c 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -519,8 +519,8 @@ static int swap_writer_finish(struct swap_map_handle *handle,
>                                 CMP_HEADER, PAGE_SIZE)
>  #define CMP_SIZE       (CMP_PAGES * PAGE_SIZE)
>
> -/* Maximum number of threads for compression/decompression. */
> -#define CMP_THREADS    3
> +/* Default number of threads for compression/decompression. */
> +static int cmp_threads = 3;
>
>  /* Minimum/maximum number of pages for read buffering. */
>  #define CMP_MIN_RD_PAGES       1024
> @@ -741,7 +741,7 @@ static int save_compressed_image(struct swap_map_handle *handle,
>          * footprint.
>          */
>         nr_threads = num_online_cpus() - 1;
> -       nr_threads = clamp_val(nr_threads, 1, CMP_THREADS);
> +       nr_threads = clamp_val(nr_threads, 1, cmp_threads);
>
>         page = (void *)__get_free_page(GFP_NOIO | __GFP_HIGH);
>         if (!page) {
> @@ -1257,7 +1257,7 @@ static int load_compressed_image(struct swap_map_handle *handle,
>          * footprint.
>          */
>         nr_threads = num_online_cpus() - 1;
> -       nr_threads = clamp_val(nr_threads, 1, CMP_THREADS);
> +       nr_threads = clamp_val(nr_threads, 1, cmp_threads);
>
>         page = vmalloc_array(CMP_MAX_RD_PAGES, sizeof(*page));
>         if (!page) {
> @@ -1697,3 +1697,19 @@ static int __init swsusp_header_init(void)
>  }
>
>  core_initcall(swsusp_header_init);
> +
> +static int __init cmp_threads_setup(char *str)
> +{
> +       int rc = kstrtouint(str, 0, &cmp_threads);
> +
> +       if (rc)
> +               return rc;
> +
> +       if (cmp_threads < 1)
> +               cmp_threads = 1;

Why not use the default (3) here or return an error?

> +
> +       return 1;
> +
> +}
> +
> +__setup("cmp_threads=", cmp_threads_setup);
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ