* [merged mm-hotfixes-stable] mm-swap-fix-swap-cache-memcg-accounting.patch removed from -mm tree
@ 2026-03-28 0:39 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-03-28 0:39 UTC (permalink / raw)
To: mm-commits, stable, shikemeng, nphamcs, kasong, hannes, chrisl,
bhe, baohua, alex, akpm
The quilt patch titled
Subject: mm/swap: fix swap cache memcg accounting
has been removed from the -mm tree. Its filename was
mm-swap-fix-swap-cache-memcg-accounting.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Alexandre Ghiti <alex@ghiti.fr>
Subject: mm/swap: fix swap cache memcg accounting
Date: Fri, 20 Mar 2026 06:05:59 +0100
The swap readahead path was recently refactored and while doing this, the
order between the charging of the folio in the memcg and the addition of
the folio in the swap cache was inverted.
Since the accounting of the folio is done while adding the folio to the
swap cache and the folio is not charged in the memcg yet, the accounting
is then done at the node level, which is wrong.
Fix this by charging the folio in the memcg before adding it to the swap cache.
Link: https://lkml.kernel.org/r/20260320050601.1833108-1-alex@ghiti.fr
Fixes: 2732acda82c9 ("mm, swap: use swap cache as the swap in synchronize layer")
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Acked-by: Kairui Song <kasong@tencent.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Acked-by: Chris Li <chrisl@kernel.org>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Baoquan He <bhe@redhat.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/swap_state.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
--- a/mm/swap_state.c~mm-swap-fix-swap-cache-memcg-accounting
+++ a/mm/swap_state.c
@@ -494,6 +494,10 @@ static struct folio *__swap_cache_prepar
__folio_set_locked(folio);
__folio_set_swapbacked(folio);
+
+ if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry))
+ goto failed;
+
for (;;) {
ret = swap_cache_add_folio(folio, entry, &shadow);
if (!ret)
@@ -514,11 +518,6 @@ static struct folio *__swap_cache_prepar
goto failed;
}
- if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry)) {
- swap_cache_del_folio(folio);
- goto failed;
- }
-
memcg1_swapin(entry, folio_nr_pages(folio));
if (shadow)
workingset_refault(folio, shadow);
_
Patches currently in -mm which might be from alex@ghiti.fr are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-28 0:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-28 0:39 [merged mm-hotfixes-stable] mm-swap-fix-swap-cache-memcg-accounting.patch removed from -mm tree Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox