Skip to contentSkip to conversation

mm-zsmalloc-fix-release-order-of-locks-in-zs_page_migrate.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Aug 7

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/zsmalloc: fix release order of locks in zs_page_migrate()
has been removed from the -mm tree. Its filename was
mm-zsmalloc-fix-release-order-of-locks-in-zs_page_migrate.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Richard Chang <[email protected]>
Subject: mm/zsmalloc: fix release order of locks in zs_page_migrate()
Date: Tue, 28 Jul 2026 05:53:33 +0000

In zs_page_migrate(), locks are acquired in the following order:
1. write_lock(&pool->lock)
2. spin_lock(&class->lock)
3. zspage_write_trylock(zspage)

However, upon successful page migration, they were being released in forward acquisition (FIFO) order:
1. write_unlock(&pool->lock)
2. spin_unlock(&class->lock)
3. zspage_write_unlock(zspage)

Fix the unlocking order to release locks in strict reverse (LIFO) order of acquisition:
3. zspage_write_unlock(zspage)
2. spin_unlock(&class->lock)
1. write_unlock(&pool->lock)

Releasing locks in reverse order of acquisition adheres to standard kernel locking hygiene, prevents potential lock ordering and lockdep inconsistencies.

---

 mm/zsmalloc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~mm-zsmalloc-fix-release-order-of-locks-in-zs_page_migrate +2 -2
@@ -1926,9 +1926,9 @@ static int zs_page_migrate(struct page *
 	 * Since we complete the data copy and set up new zspage structure,
 	 * it's okay to release migration_lock.
 	 */
-	write_unlock(&pool->lock);
-	spin_unlock(&class->lock);
 	zspage_write_unlock(zspage);
+	spin_unlock(&class->lock);
+	write_unlock(&pool->lock);
 
 	zpdesc_get(newzpdesc);
 	if (zpdesc_zone(newzpdesc) != zpdesc_zone(zpdesc)) {

_

Patches currently in -mm which might be from [email protected] are