diff mbox series

[RFC,2/6] PM: Hibernate: Add option to disable disk offset randomization

Message ID 1652860121-24092-3-git-send-email-quic_vivekuma@quicinc.com (mailing list archive)
State New, archived
Headers show
Series Bootloader based hibernation | expand

Commit Message

Vivek Kumar May 18, 2022, 7:48 a.m. UTC
Add a kernel parameter to disable the disk offset randomization
for SSD devices in which such feature is available at the
firmware level. This is helpful in improving hibernation
resume time.

Signed-off-by: Vivek Kumar <quic_vivekuma@quicinc.com>
Signed-off-by: Prasanna Kumar <quic_kprasan@quicinc.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 11 +++++++++++
 kernel/power/swap.c                             |  9 +++++++++
 2 files changed, 20 insertions(+)

Comments

Andrew Lunn May 18, 2022, 12:19 p.m. UTC | #1
On Wed, May 18, 2022 at 01:18:37PM +0530, Vivek Kumar wrote:
> Add a kernel parameter to disable the disk offset randomization
> for SSD devices in which such feature is available at the
> firmware level. This is helpful in improving hibernation
> resume time.
> 
> Signed-off-by: Vivek Kumar <quic_vivekuma@quicinc.com>
> Signed-off-by: Prasanna Kumar <quic_kprasan@quicinc.com>
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 11 +++++++++++
>  kernel/power/swap.c                             |  9 +++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 666ade9..06b4f10 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -5192,6 +5192,17 @@
>  			Useful for devices that are detected asynchronously
>  			(e.g. USB and MMC devices).
>  
> +	noswap_randomize
> +			Kernel uses random disk offsets to help with wear-levelling
> +			of SSD devices, while saving the hibernation snapshot image to
> +			disk. Use this parameter to disable this feature for SSD
> +			devices in scenarios when, such randomization is addressed at
> +			the firmware level and hibenration image is not re-generated
> +			frequently.
> +			(Useful for improving hibernation resume time as snapshot pages
> +			are available in disk serially and can be read in bigger chunks
> +			without seeking)

Seeking is a NOP for SSD, so it seems odd you mentioned that. Is the
real problem here that the bootloader driver is very simple, it does
not queue multiple reads to the hardware, but does it one block at a
time?

Do you have performance numbers for both the bootloader and Linux?
Does Linux performance reading the snapshot increase as much as for
the bootloader?

	Andrew
Christoph Hellwig May 18, 2022, 1 p.m. UTC | #2
On Wed, May 18, 2022 at 01:18:37PM +0530, Vivek Kumar wrote:
> Add a kernel parameter to disable the disk offset randomization
> for SSD devices in which such feature is available at the
> firmware level. This is helpful in improving hibernation
> resume time.

This patch just adds a global variable which is then entirely
igored.

But the idea of "randomizing" offsets on SSDs sounds like complete BS to
start with.  The whole job of the SSD is to remap from a random writable
block device to difference physical blocks to deal with erases and wear
leveling.  In other words it really doesn't matter what offset your
write to.  That being said I could not actually find any code that does
this randomization to start with, but that might just be my lack of grep
skills.
Randy Dunlap May 23, 2022, 8:49 p.m. UTC | #3
On 5/18/22 00:48, Vivek Kumar wrote:
> Add a kernel parameter to disable the disk offset randomization
> for SSD devices in which such feature is available at the
> firmware level. This is helpful in improving hibernation
> resume time.
> 
> Signed-off-by: Vivek Kumar <quic_vivekuma@quicinc.com>
> Signed-off-by: Prasanna Kumar <quic_kprasan@quicinc.com>
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 11 +++++++++++
>  kernel/power/swap.c                             |  9 +++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 666ade9..06b4f10 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -5192,6 +5192,17 @@
>  			Useful for devices that are detected asynchronously
>  			(e.g. USB and MMC devices).
>  
> +	noswap_randomize
> +			Kernel uses random disk offsets to help with wear-levelling

			                                             wear-leveling

> +			of SSD devices, while saving the hibernation snapshot image to
> +			disk. Use this parameter to disable this feature for SSD
> +			devices in scenarios when, such randomization is addressed at

			               no comma  ^

> +			the firmware level and hibenration image is not re-generated

			                       hibernation

> +			frequently.
> +			(Useful for improving hibernation resume time as snapshot pages
> +			are available in disk serially and can be read in bigger chunks
> +			without seeking)
> +
>  	retain_initrd	[RAM] Keep initrd memory after extraction
>  
>  	rfkill.default_state=
diff mbox series

Patch

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 666ade9..06b4f10 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5192,6 +5192,17 @@ 
 			Useful for devices that are detected asynchronously
 			(e.g. USB and MMC devices).
 
+	noswap_randomize
+			Kernel uses random disk offsets to help with wear-levelling
+			of SSD devices, while saving the hibernation snapshot image to
+			disk. Use this parameter to disable this feature for SSD
+			devices in scenarios when, such randomization is addressed at
+			the firmware level and hibenration image is not re-generated
+			frequently.
+			(Useful for improving hibernation resume time as snapshot pages
+			are available in disk serially and can be read in bigger chunks
+			without seeking)
+
 	retain_initrd	[RAM] Keep initrd memory after extraction
 
 	rfkill.default_state=
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 91fffdd..8d5c811 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -44,6 +44,7 @@  u32 swsusp_hardware_signature;
  */
 static bool clean_pages_on_read;
 static bool clean_pages_on_decompress;
+static bool noswap_randomize;
 
 /*
  *	The swap map is a data structure used for keeping track of each page
@@ -1616,3 +1617,11 @@  static int __init swsusp_header_init(void)
 }
 
 core_initcall(swsusp_header_init);
+
+static int __init noswap_randomize_setup(char *str)
+{
+	noswap_randomize = true;
+	return 1;
+}
+
+__setup("noswap_randomize", noswap_randomize_setup);