From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDE57E81A28 for ; Mon, 16 Feb 2026 14:58:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 221BB6B0005; Mon, 16 Feb 2026 09:58:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D4206B008C; Mon, 16 Feb 2026 09:58:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03AE06B008A; Mon, 16 Feb 2026 09:58:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D66826B0088 for ; Mon, 16 Feb 2026 09:58:10 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6D079160B85 for ; Mon, 16 Feb 2026 14:58:10 +0000 (UTC) X-FDA: 84450625140.28.62CBFCD Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf06.hostedemail.com (Postfix) with ESMTP id 52E88180004 for ; Mon, 16 Feb 2026 14:58:08 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JZnc3x0J; spf=pass (imf06.hostedemail.com: domain of devnull+kasong.tencent.com@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=devnull+kasong.tencent.com@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1771253888; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=tkpXNUBY8zNjvw0YsFN3JwdapOt7a8R0Sgj70sq1pKM=; b=Yb44TRqyY5k4eMtoStPjEGNGPDxjwyziMwso8+hfq5cYA923ObNzxGE0HRjv/WlzWj9z9f ThYbrBh66RJGVQSL44guK01KX6Q6b8WygzwobKmkSfF/qNduz5zl41Wbd5pGbhaBI6n3f5 kQUTMn7ETgPjKmsMA53f/ldf89pvLLk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JZnc3x0J; spf=pass (imf06.hostedemail.com: domain of devnull+kasong.tencent.com@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=devnull+kasong.tencent.com@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1771253888; a=rsa-sha256; cv=none; b=xfR72PIlh1VZ0C92EIpMpVJQraAm0wVwEUkv+Db5km+y2pxB1NI12dlqx3f9JjJlfvX/Aq sm2lyTVHe3PF6JAMPJcjEA1WGBLIkeMacStjakmbIQ5tseS5uTZlbQhxnSP6hSOVd4jolA YiszB3TjvBlVGyp1NYVqjDEedr5mXQw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 5608F44400; Mon, 16 Feb 2026 14:58:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 321E6C116C6; Mon, 16 Feb 2026 14:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771253887; bh=sO7TBYofqYSM2bgeL92RYGu50mNH9qEmCpadIybs00Y=; h=From:Subject:Date:To:Cc:Reply-To:From; b=JZnc3x0JnNc+ceYmxA0Q8hIOBYkmwRQWjvhxe9xHkuPu7cxJ0AvJyyudsvWv9U7aN Gef8uu5TCBVlC75HHs7vj+HItKK3CzbqyjTzLkx8OcWPXXdkIowNIa/ZC2RtutpiiN LnGNUIkFVjOC+WbvwpMJfiYs0pqO3ev92Auw8A54Cp23izPE3GzJ6RYK6IyFsEUcyq k+xih5YhFITZxTXKNh5oC72gCBf8Mu/g9jJ0sXDhiuJ+ILXRt6qtc31EzNvWQ6rKOD MEGR1CbnRGQDv3Wjs2wVq96UxIhEIxbw79F+/SdsTBVdAGx2wwQBWlmGmiQogTLgSC Rp4Q5L25nMFmg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10722E81A28; Mon, 16 Feb 2026 14:58:07 +0000 (UTC) From: Kairui Song via B4 Relay Subject: [PATCH v4 0/3] mm/swap: hibernate: improve hibernate performance with new allocator Date: Mon, 16 Feb 2026 22:58:01 +0800 Message-Id: <20260216-hibernate-perf-v4-0-1ba9f0bf1ec9@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/33M0QqDIBiG4VsJj+fQv8za0e5j7CDtd3kwCxXZi O59Fgy2BTt8P/iemQT0FgM5FTPxmGywo8tRHQqih87dkNo+NwEGNQMOdLAKvesi0gm9oUZJ2ZQ KFAgg+TR5NPaxgZdr7sGGOPrn5ie+rm9K/FKJU0aNEIgtYi17dY7oNLp41OOdrFiC/wBkQBtot BSKVUrugfITqHdAmQFZIQPBWs4r8Q0sy/ICjdPWYDABAAA= X-Change-ID: 20260212-hibernate-perf-fb7783b2b252 To: linux-mm@kvack.org Cc: Andrew Morton , Chris Li , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Carsten Grohmann , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, "open list:SUSPEND TO RAM" , Carsten Grohmann , Kairui Song , stable@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771253885; l=2863; i=kasong@tencent.com; s=kasong-sign-tencent; h=from:subject:message-id; bh=sO7TBYofqYSM2bgeL92RYGu50mNH9qEmCpadIybs00Y=; b=CpIU6uKntmcDupIJYIVmNkZrat/SPDOFtjFTIqHnuR4BpQdR82jnesJYYScaxY4crDNFtIKs+ pzIT1VZg+Y9CEOaqZvFVJ7o4WqAzx1ovXKLIf+7wkElkcoOdiDUWyUK X-Developer-Key: i=kasong@tencent.com; a=ed25519; pk=kCdoBuwrYph+KrkJnrr7Sm1pwwhGDdZKcKrqiK8Y1mI= X-Endpoint-Received: by B4 Relay for kasong@tencent.com/kasong-sign-tencent with auth_id=562 X-Original-From: Kairui Song Reply-To: kasong@tencent.com X-Stat-Signature: c6epco4twe8z6et1sua5mdbpcu9u7qff X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 52E88180004 X-HE-Tag: 1771253888-251593 X-HE-Meta: U2FsdGVkX19T0jEjwi6PInz7U6lcS9TQuDoIlrXNYcKtKr1N/N6THt/CVleZdLKjEfoNVEB5PostEvwwf55GNUDWpIks5GrBtysnv4HS2G4ID5oj4Pp3rzxkM8EuFipic5cro7kKpoU4EyOr7fqGJLSJDXI+FZj3gdfTbqS3ff5ugDJVc8u/s6z9DgtAcvDUxgU0j8lAvvWfucXYL+4bydYpseJJqDB0LTllfNmv7Xagu2rJMPO6gnmxTeyWjEFwqQ3a9hpij1rQc+9woy9aF8Ynb5fmU/ipNyYFjV/3kvcpl3AIsmCjCbjaEd8Xt5Jhi874jxr0gF91QcLBuCjNiG5Ejeo0PyFx7BhLb4a4mPkqHyLdWsn2OAaCkleOe0o02IrN9ZG9ADxA+az2IRklnS4g6CwgdTfoU+HO/QNKlB22R60pOfPogJUx7xRkiAyEfwER/cdrc7aZIEFQ1x+u1oQpQBD+XgiNvqU3t/H8040rLiyQRMElYU8Tfsp0Hijb+657xBTumKz15EQuGtBSLHEz3h15M4audVy/RUu8N+NHZkmSOm0INfV//etfZnQ9E/4fdRuPbPYSDcnXtx6eqQTOcIsjOXe3D5WkctRBf5hm5mOIp9a7PfkEE2LJxbHINtnF71IWSu3wCbgiMXtk4CTirQhdvanfGDnvGSNXEFRnrM4QahAbWZSZLfXmAL5Lr808W+/o7M+ViwcCwGjAHQAtuPpmdcbDDA49CadtmegoxXsZIMVbjXW4gGVvo2B2KLY59kXPb/p9LpHzXBR5STZG77mEBO+wLDfjPF3LCBytkzghGNaehn9yCWZ8/ZVnceTr2Kscddpeko8mhkccMm7Pnsh8mUQ+0RP3p3jRzJCDRoE2mvh2os3Z/nWjh8E/h3vr49jJsZQeZuFyKFcOyQiG1WlfcpWXMDCn0sA1+wuc1QvguSDBC272lSLpdDXVb3HudUH6d2B5HSU0H+g O4OZDRAQ BzGcQWZwxrA4+uXxZ69lZjgN+5QTEYPyPRED0TsEcrSSrW2lwi00B9qQ+QgJ90A5auC1OUmcfNP39RbjY0s3pRgAs00q5vvUQ34FM0r0JynNeHWUWgaZT8huNmSCmUHdNqPF/3czy/gK+g7h6fHMO/jpRVEBaeGEjyPCPz8zPvetEZ4IZQ0rGu6y3ABspHAbQYMcnx8/d2TlR171zVukBjH7UVfPBw8gk4IvZRzCJ1k9eXy2nbFS2nuehCabRI9va4SBP2kil0bVkwaD8CJcMJkH9Uz4spJjzSVhUE8W4zu+DLTse/iUnPRe2jutu/26YGn6ACBVGonFnmzq2+aAAT/bAzsXFEH4zizhY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Grohmann [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 Tested-by: Carsten Grohmann Link: https://lore.kernel.org/linux-mm/8b4bdcfa-ce3f-4e23-839f-31367df7c18f@gmx.de/ [1] --- Changes in v4: - Reduce indent and improve code comment, as suggested by [ Barry Song ] - Link to v3: https://lore.kernel.org/r/20260216-hibernate-perf-v3-0-74e025091145@tencent.com Changes in v3: - Split the indention change to a standalone patch. - Update mail address and add Cc stable. - Link to v2: https://lore.kernel.org/r/20260215-hibernate-perf-v2-0-cf28c75b04b7@tencent.com Changes in v2: - Based on mm-unstable, resend using b4's relay to fix mismathed patch content. - Link to v1: https://lore.kernel.org/r/20260215-hibernate-perf-v1-0-f55ee9ee67db@tencent.com --- Kairui Song (3): mm, swap: speed up hibernation allocation and writeout mm, swap: reduce indention for hibernate allocation helper mm, swap: merge common convention and simplify allocation helper mm/swapfile.c | 92 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 39 deletions(-) --- base-commit: 53f061047924205138ad9bc315885255f7cc4944 change-id: 20260212-hibernate-perf-fb7783b2b252 Best regards, -- Kairui Song