mm-commits Archive on
 help / color / Atom feed
* [merged] mm-memcg-fix-refcount-error-while-moving-and-swapping.patch removed from -mm tree
@ 2020-07-24 23:38 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2020-07-24 23:38 UTC (permalink / raw)
  To: alex.shi, hannes, hughd, mhocko, mm-commits, shakeelb, stable

The patch titled
     Subject: mm/memcg: fix refcount error while moving and swapping
has been removed from the -mm tree.  Its filename was

This patch was dropped because it was merged into mainline or a subsystem tree

From: Hugh Dickins <>
Subject: mm/memcg: fix refcount error while moving and swapping

It was hard to keep a test running, moving tasks between memcgs with
move_charge_at_immigrate, while swapping: mem_cgroup_id_get_many()'s
refcount is discovered to be 0 (supposedly impossible), so it is then
forced to REFCOUNT_SATURATED, and after thousands of warnings in quick
succession, the test is at last put out of misery by being OOM killed.

This is because of the way moved_swap accounting was saved up until the
task move gets completed in __mem_cgroup_clear_mc(), deferred from when
mem_cgroup_move_swap_account() actually exchanged old and new ids. 
Concurrent activity can free up swap quicker than the task is scanned,
bringing id refcount down 0 (which should only be possible when

Just skip that optimization: do that part of the accounting immediately.

Fixes: 615d66c37c75 ("mm: memcontrol: fix memcg id ref counter on swap charge move")
Signed-off-by: Hugh Dickins <>
Cc: Johannes Weiner <>
Cc: Alex Shi <>
Cc: Shakeel Butt <>
Cc: Michal Hocko <>
Cc: <>
Signed-off-by: Andrew Morton <>

 mm/memcontrol.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/mm/memcontrol.c~mm-memcg-fix-refcount-error-while-moving-and-swapping
+++ a/mm/memcontrol.c
@@ -5669,7 +5669,6 @@ static void __mem_cgroup_clear_mc(void)
 		if (!mem_cgroup_is_root(
 			page_counter_uncharge(&>memory, mc.moved_swap);
-		mem_cgroup_id_get_many(, mc.moved_swap);
 		css_put_many(&>css, mc.moved_swap);
 		mc.moved_swap = 0;
@@ -5860,7 +5859,8 @@ put:			/* get_mctgt_type() gets the page
 			ent = target.ent;
 			if (!mem_cgroup_move_swap_account(ent, mc.from, {
-				/* we fixup refcnts and charges later. */
+				mem_cgroup_id_get_many(, 1);
+				/* we fixup other refcnts and charges later. */

Patches currently in -mm which might be from are

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 23:38 [merged] mm-memcg-fix-refcount-error-while-moving-and-swapping.patch removed from -mm tree akpm

mm-commits Archive on

Archives are clonable:
	git clone --mirror mm-commits/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 mm-commits mm-commits/ \
	public-inbox-index mm-commits

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone