Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm: swap: remove duplicate nr_swap_pages decrement in" failed to apply to 6.17-stable tree

PATCH New [email protected] 2 participants 2 messages Dec 1, 2025

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.17-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.17.y
git checkout FETCH_HEAD
git cherry-pick -x f5e31a196edcd1f1bb44f26b6f9299b9a5b9b3c4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025120121-fifteen-liver-792b@gregkh' --subject-prefix 'PATCH 6.17.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From f5e31a196edcd1f1bb44f26b6f9299b9a5b9b3c4 Mon Sep 17 00:00:00 2001
From: Youngjun Park <[email protected]>
Date: Sun, 2 Nov 2025 17:24:56 +0900
Subject: [PATCH] mm: swap: remove duplicate nr_swap_pages decrement in
get_swap_page_of_type()

After commit 4f78252da887, nr_swap_pages is decremented in swap_range_alloc(). Since cluster_alloc_swap_entry() calls swap_range_alloc() internally, the decrement in get_swap_page_of_type() causes double-decrementing.

As a representative userspace-visible runtime example of the impact, /proc/meminfo reports increasingly inaccurate SwapFree values. The discrepancy grows with each swap allocation, and during hibernation when large amounts of memory are written to swap, the reported value can deviate significantly from actual available swap space, misleading users and monitoring tools.

Remove the duplicate decrement.

Fixes 4f78252da887 ("mm: swap: move nr_swap_pages counter decrement from folio_alloc_swap() to swap_range_alloc()")
Cc Baoquan He <[email protected]>
Cc Kemeng Shi <[email protected]>
Cc <[email protected]> [6.17+]
mm/swapfile.c +1 -3
index 10760240a3a2..a1b4b9d80e3b 100644
@@ -2005,10 +2005,8 @@ swp_entry_t get_swap_page_of_type(int type)
 			local_lock(&percpu_swap_cluster.lock);
 			offset = cluster_alloc_swap_entry(si, 0, 1);
 			local_unlock(&percpu_swap_cluster.lock);
-			if (offset) {
+			if (offset)
 				entry = swp_entry(si->type, offset);
-				atomic_long_dec(&nr_swap_pages);
-			}
 		}
 		put_swap_device(si);
 	}
maintainer
#1 lore raw

PATCH 1/1 mm: swap: remove duplicate nr_swap_pages decrement in get_swap_page_of_type()

From: Youngjun Park <[email protected]>

[ Upstream commit f5e31a196edcd1f1bb44f26b6f9299b9a5b9b3c4 ]

After commit 4f78252da887, nr_swap_pages is decremented in swap_range_alloc(). Since cluster_alloc_swap_entry() calls swap_range_alloc() internally, the decrement in get_swap_page_of_type() causes double-decrementing.

As a representative userspace-visible runtime example of the impact, /proc/meminfo reports increasingly inaccurate SwapFree values. The discrepancy grows with each swap allocation, and during hibernation when large amounts of memory are written to swap, the reported value can deviate significantly from actual available swap space, misleading users and monitoring tools.

Remove the duplicate decrement.

Fixes 4f78252da887 ("mm: swap: move nr_swap_pages counter decrement from folio_alloc_swap() to swap_range_alloc()")
Cc Baoquan He <[email protected]>
Cc Kemeng Shi <[email protected]>
Cc <[email protected]> [6.17+]
[ adjusted context ]
---
 mm/swapfile.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/swapfile.c +1 -3
index ad438a4d0e68c..73065d75d0e1f 100644
@@ -1866,10 +1866,8 @@ swp_entry_t get_swap_page_of_type(int type)
 	if (get_swap_device_info(si)) {
 		if (si->flags & SWP_WRITEOK) {
 			offset = cluster_alloc_swap_entry(si, 0, 1);
-			if (offset) {
+			if (offset)
 				entry = swp_entry(si->type, offset);
-				atomic_long_dec(&nr_swap_pages);
-			}
 		}
 		put_swap_device(si);
 	}
Signature · 1 line
2.51.0