Skip to contentSkip to conversation

memcg-v1-bail-out-reclaim-when-memcg-is-dying.patch removed from -mm tree

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

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: memcg-v1: bail out reclaim when memcg is dying
has been removed from the -mm tree. Its filename was
memcg-v1-bail-out-reclaim-when-memcg-is-dying.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: Jiayuan Chen <[email protected]>
Subject: memcg-v1: bail out reclaim when memcg is dying
Date: Thu, 2 Jul 2026 20:02:30 +0800

The legacy memory.limit_in_bytes and memory.memsw.limit_in_bytes writers retry page_counter_set_max() by reclaiming synchronously in the writer context. memory.force_empty similarly loops in synchronous reclaim until the cgroup is empty or reclaim stops making progress.

These writes hold a kernfs active reference on the file. If cgroup removal starts in parallel, the remover sets CSS_DYING and then waits in kernfs_drain() under cgroup_mutex for the active reference to drain. Continuing reclaim after the memcg is dying can therefore delay cgroup removal and keep cgroup_mutex held for a long time.

Stop the v1 reclaim loops once the memcg is dying. For limit resizing, keep the existing -EBUSY semantics when the new limit could not be installed. For memory.force_empty, keep the existing best-effort success semantics.

Cc Jiayuan Chen <[email protected]>
Cc Axel Rasmussen <[email protected]>
Cc Barry Song <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Kairui Song <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Muchun Song <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Wei Xu <[email protected]>
Cc Yuanchu Xie <[email protected]>

---

 mm/memcontrol-v1.c |    8 ++++++++
 1 file changed, 8 insertions(+)
mm/memcontrol-v1.c renamed from mm/memcontrol-v1.c~memcg-v1-bail-out-reclaim-when-memcg-is-dying +8 -0
@@ -1805,6 +1805,10 @@ static int mem_cgroup_resize_max(struct
 		if (!ret)
 			break;
 
+		/* cgroup_rmdir() waits for us with cgroup_mutex held. */
+		if (memcg_is_dying(memcg))
+			break;
+
 		if (!drained) {
 			drain_all_stock(memcg);
 			drained = true;
@@ -1843,6 +1847,10 @@ static int mem_cgroup_force_empty(struct
 		if (signal_pending(current))
 			return -EINTR;
 
+		/* cgroup_rmdir() waits for us with cgroup_mutex held. */
+		if (memcg_is_dying(memcg))
+			break;
+
 		if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_KERNEL,
 						  MEMCG_RECLAIM_MAY_SWAP, NULL))
 			nr_retries--;

_

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