mm-shmem-move-unused-huge-shrinklist-queuing-past-the-truncation-check.patch removed from -mm tree
The quilt patch titled
Subject: mm: shmem: move unused huge shrinklist queuing past the truncation check
has been removed from the -mm tree. Its filename was
mm-shmem-move-unused-huge-shrinklist-queuing-past-the-truncation-check.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: Qi Zheng <[email protected]>
Subject: mm: shmem: move unused huge shrinklist queuing past the truncation check
Date: Mon, 17 Aug 2026 17:03:27 +0800
The shmem_get_folio_gfp() adds the inode to the unused huge shrinker list at the alloced label, but a subsequent truncation check may still fail and remove the folio, leaving the inode on the list with a stale folio.
The original code works because the shrinker re-looks-up the folio and drops stale entries, but it is cleaner to queue the inode only after all checks that might remove the folio have passed.
So just make the pure structural move with no functional change, and it serves as preparation for the memcg-aware shrinker conversion.
---
mm/shmem.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-)
mm/shmem.c renamed from mm/shmem.c~mm-shmem-move-unused-huge-shrinklist-queuing-past-the-truncation-check +27 -21
@@ -2539,27 +2539,6 @@ repeat: alloced: alloced = true; -if (folio_test_large (folio) && -DIV_ROUND_UP (i_size_read (inode),PAGE_SIZE ) < -folio_next_index (folio)) { -struct shmem_sb_info *sbinfo =SHMEM_SB (inode->i_sb); -struct shmem_inode_info *info =SHMEM_I (inode); -/* -* Part of the large folio is beyond i_size: subject -* to shrink under memory pressure. -*/ -spin_lock (&sbinfo->shrinklist_lock); -/* -* _careful to defend against unlocked access to -* ->shrink_list in shmem_unused_huge_shrink() -*/ -if (list_empty_careful (&info->shrinklist)) { -list_add_tail (&info->shrinklist, - &sbinfo->shrinklist); - sbinfo->shrinklist_len++; - } -spin_unlock (&sbinfo->shrinklist_lock); - }if (sgp ==SGP_WRITE )folio_set_referenced (folio);
@@ -2589,6 +2568,33 @@ clear: error = -EINVAL ; goto unlock; } + +/* +* Queue the inode on the shrink list only after all checks that might +* remove the folio have passed. Otherwise the inode could be left on +* the shrinker list with a stale folio. +*/ +if (alloced &&folio_test_large (folio) && +DIV_ROUND_UP (i_size_read (inode),PAGE_SIZE ) <folio_next_index (folio)) { +struct shmem_sb_info *sbinfo =SHMEM_SB (inode->i_sb); +struct shmem_inode_info *info =SHMEM_I (inode); +/* +* Part of the large folio is beyond i_size: subject +* to shrink under memory pressure. +*/ +spin_lock (&sbinfo->shrinklist_lock); +/* +* _careful to defend against unlocked access to +* ->shrink_list in shmem_unused_huge_shrink() +*/ +if (list_empty_careful (&info->shrinklist)) { +list_add_tail (&info->shrinklist, + &sbinfo->shrinklist); + sbinfo->shrinklist_len++; + } +spin_unlock (&sbinfo->shrinklist_lock); + } + out: *foliop = folio;return 0 ;
_
Patches currently in -mm which might be from [email protected] are