From: <gregkh@linuxfoundation.org>
To: akpm@linux-foundation.org,akpm@linux-foundation.orgL,cerasuolodomenico@gmail.com,corbet@lwn.net,ddstreet@ieee.org,greg@kroah.com,gregkh@linuxfoundation.org,hannes@cmpxchg.org,lance.yang@linux.dev,leon.huangfu@shopee.com,linux-mm@kvack.org,lizefan.x@bytedance.com,mhocko@kernel.org,mhocko@suse.com,muchun.song@linux.dev,nphamcs@gmail.com,roman.gushchin@linux.dev,sashal@kernel.org,shakeelb@google.com,shy828301@gmail.com,sjenning@redhat.com,songmuchun@bytedance.com,tj@kernel.org,vernhao@tencent.com,vishal.moola@gmail.com,vitaly.wool@konsulko.com,yosryahmed@google.com
Cc: <stable-commits@vger.kernel.org>
Subject: Patch "mm: memcg: add THP swap out info for anonymous reclaim" has been added to the 6.6-stable tree
Date: Fri, 21 Nov 2025 11:08:43 +0100 [thread overview]
Message-ID: <2025112143-pull-ravioli-93d5@gregkh> (raw)
In-Reply-To: <20251103075135.20254-2-leon.huangfu@shopee.com>
This is a note to let you know that I've just added the patch titled
mm: memcg: add THP swap out info for anonymous reclaim
to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-memcg-add-thp-swap-out-info-for-anonymous-reclaim.patch
and it can be found in the queue-6.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
From leon.huangfu@shopee.com Mon Nov 3 08:53:02 2025
From: Leon Huang Fu <leon.huangfu@shopee.com>
Date: Mon, 3 Nov 2025 15:51:29 +0800
Subject: mm: memcg: add THP swap out info for anonymous reclaim
To: stable@vger.kernel.org, greg@kroah.com
Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, corbet@lwn.net, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, akpm@linux-foundation.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, lance.yang@linux.dev, leon.huangfu@shopee.com, shy828301@gmail.com, yosryahmed@google.com, sashal@kernel.org, vishal.moola@gmail.com, cerasuolodomenico@gmail.com, nphamcs@gmail.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Xin Hao <vernhao@tencent.com>, Michal Hocko <mhocko@suse.com>, Muchun Song <songmuchun@bytedance.com>
Message-ID: <20251103075135.20254-2-leon.huangfu@shopee.com>
From: Xin Hao <vernhao@tencent.com>
[ Upstream commit 811244a501b967b00fecb1ae906d5dc6329c91e0 ]
At present, we support per-memcg reclaim strategy, however we do not know
the number of transparent huge pages being reclaimed, as we know the
transparent huge pages need to be splited before reclaim them, and they
will bring some performance bottleneck effect. for example, when two
memcg (A & B) are doing reclaim for anonymous pages at same time, and 'A'
memcg is reclaiming a large number of transparent huge pages, we can
better analyze that the performance bottleneck will be caused by 'A'
memcg. therefore, in order to better analyze such problems, there add THP
swap out info for per-memcg.
[akpm@linux-foundation.orgL fix swap_writepage_fs(), per Johannes]
Link: https://lkml.kernel.org/r/20230913213343.GB48476@cmpxchg.org
Link: https://lkml.kernel.org/r/20230913164938.16918-1-vernhao@tencent.com
Signed-off-by: Xin Hao <vernhao@tencent.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Leon Huang Fu <leon.huangfu@shopee.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Documentation/admin-guide/cgroup-v2.rst | 9 +++++++++
mm/memcontrol.c | 2 ++
mm/page_io.c | 8 ++++----
mm/vmscan.c | 1 +
4 files changed, 16 insertions(+), 4 deletions(-)
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -1532,6 +1532,15 @@ PAGE_SIZE multiple when read back.
collapsing an existing range of pages. This counter is not
present when CONFIG_TRANSPARENT_HUGEPAGE is not set.
+ thp_swpout (npn)
+ Number of transparent hugepages which are swapout in one piece
+ without splitting.
+
+ thp_swpout_fallback (npn)
+ Number of transparent hugepages which were split before swapout.
+ Usually because failed to allocate some continuous swap space
+ for the huge page.
+
memory.numa_stat
A read-only nested-keyed file which exists on non-root cgroups.
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -704,6 +704,8 @@ static const unsigned int memcg_vm_event
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
THP_FAULT_ALLOC,
THP_COLLAPSE_ALLOC,
+ THP_SWPOUT,
+ THP_SWPOUT_FALLBACK,
#endif
};
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -208,8 +208,10 @@ int swap_writepage(struct page *page, st
static inline void count_swpout_vm_event(struct folio *folio)
{
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- if (unlikely(folio_test_pmd_mappable(folio)))
+ if (unlikely(folio_test_pmd_mappable(folio))) {
+ count_memcg_folio_events(folio, THP_SWPOUT, 1);
count_vm_event(THP_SWPOUT);
+ }
#endif
count_vm_events(PSWPOUT, folio_nr_pages(folio));
}
@@ -278,9 +280,6 @@ static void sio_write_complete(struct ki
set_page_dirty(page);
ClearPageReclaim(page);
}
- } else {
- for (p = 0; p < sio->pages; p++)
- count_swpout_vm_event(page_folio(sio->bvec[p].bv_page));
}
for (p = 0; p < sio->pages; p++)
@@ -296,6 +295,7 @@ static void swap_writepage_fs(struct pag
struct file *swap_file = sis->swap_file;
loff_t pos = page_file_offset(page);
+ count_swpout_vm_event(page_folio(page));
set_page_writeback(page);
unlock_page(page);
if (wbc->swap_plug)
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1922,6 +1922,7 @@ retry:
folio_list))
goto activate_locked;
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1);
count_vm_event(THP_SWPOUT_FALLBACK);
#endif
if (!add_to_swap(folio))
Patches currently in stable-queue which might be from leon.huangfu@shopee.com are
queue-6.6/mm-memcg-make-stats-flushing-threshold-per-memcg.patch
queue-6.6/mm-memcg-change-flush_next_time-to-flush_last_time.patch
queue-6.6/mm-memcg-restore-subtree-stats-flushing.patch
queue-6.6/mm-workingset-move-the-stats-flush-into-workingset_test_recent.patch
queue-6.6/mm-memcg-add-thp-swap-out-info-for-anonymous-reclaim.patch
queue-6.6/mm-memcg-add-per-memcg-zswap-writeback-stat.patch
queue-6.6/mm-memcg-move-vmstats-structs-definition-above-flushing-code.patch
next prev parent reply other threads:[~2025-11-21 10:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 7:51 [PATCH 6.6.y 0/7] mm: memcg: subtree stats flushing and thresholds Leon Huang Fu
2025-11-03 7:51 ` [PATCH 6.6.y 1/7] mm: memcg: add THP swap out info for anonymous reclaim Leon Huang Fu
2025-11-21 10:08 ` gregkh [this message]
2025-11-03 7:51 ` [PATCH 6.6.y 2/7] mm: memcg: add per-memcg zswap writeback stat Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: memcg: add per-memcg zswap writeback stat" has been added to the 6.6-stable tree gregkh
2025-11-03 7:51 ` [PATCH 6.6.y 3/7] mm: memcg: change flush_next_time to flush_last_time Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: memcg: change flush_next_time to flush_last_time" has been added to the 6.6-stable tree gregkh
2025-11-03 7:51 ` [PATCH 6.6.y 4/7] mm: memcg: move vmstats structs definition above flushing code Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: memcg: move vmstats structs definition above flushing code" has been added to the 6.6-stable tree gregkh
2025-11-03 7:51 ` [PATCH 6.6.y 5/7] mm: memcg: make stats flushing threshold per-memcg Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: memcg: make stats flushing threshold per-memcg" has been added to the 6.6-stable tree gregkh
2025-11-03 7:51 ` [PATCH 6.6.y 6/7] mm: workingset: move the stats flush into workingset_test_recent() Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: workingset: move the stats flush into workingset_test_recent()" has been added to the 6.6-stable tree gregkh
2025-11-03 7:51 ` [PATCH 6.6.y 7/7] mm: memcg: restore subtree stats flushing Leon Huang Fu
2025-11-21 10:08 ` Patch "mm: memcg: restore subtree stats flushing" has been added to the 6.6-stable tree gregkh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025112143-pull-ravioli-93d5@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=akpm@linux-foundation.orgL \
--cc=cerasuolodomenico@gmail.com \
--cc=corbet@lwn.net \
--cc=ddstreet@ieee.org \
--cc=greg@kroah.com \
--cc=hannes@cmpxchg.org \
--cc=lance.yang@linux.dev \
--cc=leon.huangfu@shopee.com \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=sashal@kernel.org \
--cc=shakeelb@google.com \
--cc=shy828301@gmail.com \
--cc=sjenning@redhat.com \
--cc=songmuchun@bytedance.com \
--cc=stable-commits@vger.kernel.org \
--cc=tj@kernel.org \
--cc=vernhao@tencent.com \
--cc=vishal.moola@gmail.com \
--cc=vitaly.wool@konsulko.com \
--cc=yosryahmed@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox