Re: [PATCH 1/1] mm/thp: clear deferred split shrinker bits when queues drain

From: Lance Yang

Date: Tue Jun 02 2026 - 22:03:18 EST




On 2026/6/3 04:37, Andrew Morton wrote:
On Tue, 2 Jun 2026 12:34:53 +0800 Lance Yang <lance.yang@xxxxxxxxx> wrote:

From: Lance Yang <lance.yang@xxxxxxxxx>

deferred_split_count() returns the raw list_lru count. When the per-memcg,
per-node list is empty, that count is 0.

That skips scanning, but it does not tell memcg reclaim that the shrinker
is empty. shrink_slab_memcg() only clears the memcg shrinker bit when the
count callback reports SHRINK_EMPTY.

Return SHRINK_EMPTY for an empty deferred split list, so the bit can be
cleared once the queue has drained.

Signed-off-by: Lance Yang <lance.yang@xxxxxxxxx>
---
mm/huge_memory.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 72f6caf0fec6..62d598290c3b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4397,7 +4397,10 @@ void deferred_split_folio(struct folio *folio, bool partially_mapped)
static unsigned long deferred_split_count(struct shrinker *shrink,
struct shrink_control *sc)
{
- return list_lru_shrink_count(&deferred_split_lru, sc);
+ unsigned long count;
+
+ count = list_lru_shrink_count(&deferred_split_lru, sc);
+ return count ?: SHRINK_EMPTY;
}
static bool thp_underused(struct folio *folio)

Should this be handled as a fix against hannes's "mm: switch deferred
split shrinker to list_lru"?

Hmm ... I noticed this while looking at Johannes' work, but the
behavior is older than that ...

We also discussed the Fixes tag earlier[1] and decided to leave it
out. There is no missed reclaim, only some extra reclaim work :)

[1] https://lore.kernel.org/linux-mm/63797977-1c18-4885-8099-f5c21c80da39@xxxxxxxxx/

Cheers, Lance