Skip to contentSkip to conversation

mm-shrinker-simplify-shrinker_memcg_alloc-using-guard.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jun 2

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/shrinker: simplify shrinker_memcg_alloc() using guard()
has been removed from the -mm tree. Its filename was
mm-shrinker-simplify-shrinker_memcg_alloc-using-guard.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: wangxuewen <[email protected]>
Subject: mm/shrinker: simplify shrinker_memcg_alloc() using guard()
Date: Wed, 13 May 2026 15:52:14 +0800

Use guard(mutex) to automatically handle shrinker_mutex locking and unlocking in shrinker_memcg_alloc(). This removes the explicit mutex_unlock() call, the goto-based error path, and the redundant ret variable, resulting in cleaner and more concise code.

---

 mm/shrinker.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
mm/shrinker.c renamed from mm/shrinker.c~mm-shrinker-simplify-shrinker_memcg_alloc-using-guard +5 -8
@@ -216,29 +216,26 @@ static DEFINE_IDR(shrinker_idr);
 
 static int shrinker_memcg_alloc(struct shrinker *shrinker)
 {
-	int id, ret = -ENOMEM;
+	int id;
 
 	if (mem_cgroup_disabled())
 		return -ENOSYS;
 	if (mem_cgroup_kmem_disabled() && !(shrinker->flags & SHRINKER_NONSLAB))
 		return -ENOSYS;
 
-	mutex_lock(&shrinker_mutex);
+	guard(mutex)(&shrinker_mutex);
 	id = idr_alloc(&shrinker_idr, shrinker, 0, 0, GFP_KERNEL);
 	if (id < 0)
-		goto unlock;
+		return id;
 
 	if (id >= shrinker_nr_max) {
 		if (expand_shrinker_info(id)) {
 			idr_remove(&shrinker_idr, id);
-			goto unlock;
+			return -ENOMEM;
 		}
 	}
 	shrinker->id = id;
-	ret = 0;
-unlock:
-	mutex_unlock(&shrinker_mutex);
-	return ret;
+	return 0;
 }
 
 static void shrinker_memcg_remove(struct shrinker *shrinker)

_

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