[PATCH 0/2] mm/swap: hibernate: improve hibernate performance with new allocator

Kairui Song posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
mm/swapfile.c | 56 ++++++++++++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 30 deletions(-)
[PATCH 0/2] mm/swap: hibernate: improve hibernate performance with new allocator
Posted by Kairui Song 1 month, 2 weeks ago
The new swap allocator didn't provide a high-performance allocation
method for hibernate, and just left it using the easy slow path. As a
result, hibernate performance is quite bad on some devices

Fix it by implementing hibernate support for the fast allocation path.

This regression seems only happen with SSD devices with poor 4k
performance. I've tested on several different NVME and SSD setups, the
performance diff is tiny on them, but testing on a Samsung SSD 830
Series (SATA II, 3.0 Gbps) showed a big difference [1]:

Test result with Samsung SSD 830 Series (SATA II, 3.0 Gbps) thanks
to Carsten Grohman [1]:
6.19:               324 seconds
After this series:  35 seconds

Test result with SAMSUNG MZ7LH480HAHQ-00005 (SATA 3.2, 6.0 Gb/s):
Before 0ff67f990bd4: Wrote 2230700 kbytes in 4.47 seconds (499.03 MB/s)
After 0ff67f990bd4: Wrote 2215472 kbytes in 4.44 seconds (498.98 MB/s)
After this series: Wrote 2038748 kbytes in 4.04 seconds (504.64 MB/s)

Test result with Memblaze P5910DT0384M00:
Before 0ff67f990bd4: Wrote 2222772 kbytes in 0.84 seconds (2646.15 MB/s)
After 0ff67f990bd4: Wrote 2224184 kbytes in 0.90 seconds (2471.31 MB/s)
After this series: Wrote 1559088 kbytes in 0.55 seconds (2834.70 MB/s)

The performance is almost the same for blazing fast SSDs, but for some
SSDs, the performance is several times better.

Patch 1 improves the hibernate performance by using the fast path, and
patch 2 cleans up the code a bit since there are now multiple fast path
users using similar conventions.

Signed-off-by: Kairui Song <kasong@tencent.com>
Tested-by: Carsten Grohmann <carstengrohmann@gmx.de>
Link: https://lore.kernel.org/linux-mm/8b4bdcfa-ce3f-4e23-839f-31367df7c18f@gmx.de/ [1]
---
Kairui Song (2):
      mm, swap: speed up hibernation allocation and writeout
      mm, swap: merge common convention and simplify allocation helper

 mm/swapfile.c | 56 ++++++++++++++++++++++++++------------------------------
 1 file changed, 26 insertions(+), 30 deletions(-)
---
base-commit: 53f061047924205138ad9bc315885255f7cc4944
change-id: 20260212-hibernate-perf-fb7783b2b252

Best regards,
-- 
Kairui Song <kasong@tencent.com>
Re: [PATCH 0/2] mm/swap: hibernate: improve hibernate performance with new allocator
Posted by Kairui Song 1 month, 2 weeks ago
On Sun, Feb 15, 2026 at 6:25 PM Kairui Song <ryncsn@gmail.com> wrote:
>
> The new swap allocator didn't provide a high-performance allocation
> method for hibernate, and just left it using the easy slow path. As a
> result, hibernate performance is quite bad on some devices
>
> Fix it by implementing hibernate support for the fast allocation path.
>
> This regression seems only happen with SSD devices with poor 4k
> performance. I've tested on several different NVME and SSD setups, the
> performance diff is tiny on them, but testing on a Samsung SSD 830
> Series (SATA II, 3.0 Gbps) showed a big difference [1]:
>
> Test result with Samsung SSD 830 Series (SATA II, 3.0 Gbps) thanks
> to Carsten Grohman [1]:
> 6.19:               324 seconds
> After this series:  35 seconds
>
> Test result with SAMSUNG MZ7LH480HAHQ-00005 (SATA 3.2, 6.0 Gb/s):
> Before 0ff67f990bd4: Wrote 2230700 kbytes in 4.47 seconds (499.03 MB/s)
> After 0ff67f990bd4: Wrote 2215472 kbytes in 4.44 seconds (498.98 MB/s)
> After this series: Wrote 2038748 kbytes in 4.04 seconds (504.64 MB/s)
>
> Test result with Memblaze P5910DT0384M00:
> Before 0ff67f990bd4: Wrote 2222772 kbytes in 0.84 seconds (2646.15 MB/s)
> After 0ff67f990bd4: Wrote 2224184 kbytes in 0.90 seconds (2471.31 MB/s)
> After this series: Wrote 1559088 kbytes in 0.55 seconds (2834.70 MB/s)
>
> The performance is almost the same for blazing fast SSDs, but for some
> SSDs, the performance is several times better.
>
> Patch 1 improves the hibernate performance by using the fast path, and
> patch 2 cleans up the code a bit since there are now multiple fast path
> users using similar conventions.
>
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Tested-by: Carsten Grohmann <carstengrohmann@gmx.de>
> Link: https://lore.kernel.org/linux-mm/8b4bdcfa-ce3f-4e23-839f-31367df7c18f@gmx.de/ [1]
> ---
> Kairui Song (2):
>       mm, swap: speed up hibernation allocation and writeout
>       mm, swap: merge common convention and simplify allocation helper
>
>  mm/swapfile.c | 56 ++++++++++++++++++++++++++------------------------------
>  1 file changed, 26 insertions(+), 30 deletions(-)
> ---
> base-commit: 53f061047924205138ad9bc315885255f7cc4944
> change-id: 20260212-hibernate-perf-fb7783b2b252
>
> Best regards,
> --
> Kairui Song <kasong@tencent.com>
>

Patch 1/2 is a wrong patch, sorry about this.

Just resent the series using B4 relay and marking it as V2 to
distinguish from this misformed one, please check that series instead,
thanks!
https://lore.kernel.org/linux-mm/20260215-hibernate-perf-v2-0-cf28c75b04b7@tencent.com/