AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/08/17 10:13 flow patch-triage
2m Args:
null

Results:
{
  "EnableConfigs": [
    "TRANSPARENT_HUGEPAGE",
    "MEMCG",
    "SHMEM",
    "ZSWAP"
  ],
  "FocusSymbols": [
    "shmem_get_folio",
    "shmem_read_folio_gfp",
    "shmem_read_mapping_page_gfp"
  ],
  "KMSANReasoning": "The patch series refactors the shmem unused huge page shrinker to use `list_lru` and `obj_cgroup` for memcg-aware shrinking. It modifies `struct shmem_inode_info` and `struct shmem_sb_info` to support this, and updates `fs/super.c` and `mm/zswap.c` to simplify memcg checks. The new fields in `struct shmem_inode_info` are properly initialized in `__shmem_get_inode`. The changes primarily involve list management, locking, and memcg accounting. Any bugs introduced by these changes would likely be use-after-free, NULL pointer dereferences, list corruption, or locking deadlocks, which are effectively caught by KASAN, LOCKDEP, and standard kernel debugging tools. There is no introduction of uninitialized memory being exposed to userspace or used in control flow, so a dedicated KMSAN fuzzing session is not required.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies the shmem subsystem to use a per-memcg list_lru for tracking unused huge pages instead of a global shrinklist. This allows the shrinker to reclaim unused huge pages on a per-memcg basis, avoiding duplicate work and respecting memcg boundaries. It also modifies `obj_cgroup_memcg` to handle NULL pointers, which affects zswap as well. The changes involve core memory management and shmem logic, specifically around page allocation, eviction, and memory reclaim (shrinker). This is a significant functional change that should be heavily fuzzed to ensure no memory leaks, use-after-free, or deadlocks occur during memcg reclaim or shmem operations.",
  "WorthFuzzing": true
}

1/1 2026/08/17 10:13 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit b27c75b9e87bfd237638cc76a52d37576e801f9c\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Aug 17 10:13:48 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/fs/super.c b/fs/super.c\nindex 05e4431730387..3ecce24328f67 100644\n--- a/fs/super.c\n+++ b/fs/super.c\n@@ -171,19 +171,6 @@ static void super_wake(struct super_block *sb, unsigned int flag)\n \twake_up_var(\u0026sb-\u003es_flags);\n }\n \n-/*\n- * The s_op-\u003enr_cached_objects hooks (used for example by btrfs and xfs)\n- * operate on filesystem-global state and ignore sc-\u003ememcg. Driving them\n- * from per-memcg shrink_slab_memcg() invocations only burns CPU walking\n- * per-cpu counters and queueing duplicate work: the actual reclaim happens on\n- * the global path (kswapd or root direct reclaim) regardless. Restrict them\n- * to that path.\n- */\n-static inline bool super_fs_objects_eligible(struct shrink_control *sc)\n-{\n-\treturn !sc-\u003ememcg || mem_cgroup_is_root(sc-\u003ememcg);\n-}\n-\n /*\n  * One thing we have to be careful of with a per-sb shrinker is that we don't\n  * drop the last active reference to the superblock from within the shrinker.\n@@ -213,7 +200,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink,\n \tif (!super_trylock_shared(sb))\n \t\treturn SHRINK_STOP;\n \n-\tif (sb-\u003es_op-\u003enr_cached_objects \u0026\u0026 super_fs_objects_eligible(sc))\n+\tif (sb-\u003es_op-\u003enr_cached_objects)\n \t\tfs_objects = sb-\u003es_op-\u003enr_cached_objects(sb, sc);\n \n \tinodes = list_lru_shrink_count(\u0026sb-\u003es_inode_lru, sc);\n@@ -274,8 +261,7 @@ static unsigned long super_cache_count(struct shrinker *shrink,\n \t\treturn 0;\n \tsmp_rmb();\n \n-\tif (sb-\u003es_op \u0026\u0026 sb-\u003es_op-\u003enr_cached_objects \u0026\u0026\n-\t    super_fs_objects_eligible(sc))\n+\tif (sb-\u003es_op \u0026\u0026 sb-\u003es_op-\u003enr_cached_objects)\n \t\ttotal_objects = sb-\u003es_op-\u003enr_cached_objects(sb, sc);\n \n \ttotal_objects += list_lru_shrink_count(\u0026sb-\u003es_dentry_lru, sc);\ndiff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h\nindex cba35690c21aa..5107c227ae9b8 100644\n--- a/include/linux/memcontrol.h\n+++ b/include/linux/memcontrol.h\n@@ -375,7 +375,7 @@ enum objext_flags {\n static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)\n {\n \tlockdep_assert_once(rcu_read_lock_held() || lockdep_is_held(\u0026cgroup_mutex));\n-\treturn READ_ONCE(objcg-\u003ememcg);\n+\treturn objcg ? READ_ONCE(objcg-\u003ememcg) : NULL;\n }\n \n /*\n@@ -428,7 +428,7 @@ static inline struct mem_cgroup *folio_memcg(struct folio *folio)\n {\n \tstruct obj_cgroup *objcg = folio_objcg(folio);\n \n-\treturn objcg ? obj_cgroup_memcg(objcg) : NULL;\n+\treturn obj_cgroup_memcg(objcg);\n }\n \n /*\n@@ -471,7 +471,7 @@ static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)\n \n \tobjcg = (void *)(memcg_data \u0026 ~OBJEXTS_FLAGS_MASK);\n \n-\treturn objcg ? obj_cgroup_memcg(objcg) : NULL;\n+\treturn obj_cgroup_memcg(objcg);\n }\n \n static inline struct mem_cgroup *page_memcg_check(struct page *page)\n@@ -1045,6 +1045,11 @@ void mem_cgroup_flush_workqueue(void);\n extern int mem_cgroup_init(void);\n #else /* CONFIG_MEMCG */\n \n+static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)\n+{\n+\treturn NULL;\n+}\n+\n #define MEM_CGROUP_ID_SHIFT\t0\n \n #define root_mem_cgroup\t\t(NULL)\ndiff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h\nindex 5663dff53186e..a7c7a96a7cbf9 100644\n--- a/include/linux/shmem_fs.h\n+++ b/include/linux/shmem_fs.h\n@@ -11,6 +11,7 @@\n #include \u003clinux/fs_parser.h\u003e\n #include \u003clinux/userfaultfd_k.h\u003e\n #include \u003clinux/bits.h\u003e\n+#include \u003clinux/list_lru.h\u003e\n \n /* inode in-kernel data */\n \n@@ -54,6 +55,11 @@ struct shmem_inode_info {\n \tstruct dquot __rcu\t*i_dquot[MAXQUOTAS];\n #endif\n \tstruct inode\t\tvfs_inode;\n+\n+#ifdef CONFIG_TRANSPARENT_HUGEPAGE\n+\tstruct obj_cgroup\t*shrinklist_objcg;\n+\tint\t\t\tshrinklist_nid;\n+#endif\n };\n \n #define SHMEM_FL_USER_VISIBLE\t\t(FS_FL_USER_VISIBLE | FS_CASEFOLD_FL)\n@@ -83,9 +89,9 @@ struct shmem_sb_info {\n \tino_t next_ino;\t\t    /* The next per-sb inode number to use */\n \tino_t __percpu *ino_batch;  /* The next per-cpu inode number to use */\n \tstruct mempolicy *mpol;     /* default memory policy for mappings */\n-\tspinlock_t shrinklist_lock;   /* Protects shrinklist */\n-\tstruct list_head shrinklist;  /* List of shinkable inodes */\n-\tunsigned long shrinklist_len; /* Length of shrinklist */\n+#ifdef CONFIG_TRANSPARENT_HUGEPAGE\n+\tstruct list_lru shrinklist; /* List of shrinkable inodes */\n+#endif\n \tstruct shmem_quota_limits qlimits; /* Default quota limits */\n \tstruct simple_xattr_cache xa_cache;\n };\ndiff --git a/mm/page_owner.c b/mm/page_owner.c\nindex fbbda7ba914ba..3fc37d9b908ef 100644\n--- a/mm/page_owner.c\n+++ b/mm/page_owner.c\n@@ -575,7 +575,7 @@ static inline int print_page_owner_memcg(char *kbuf, size_t count, int ret,\n \t}\n \n \tobjcg = (void *)(memcg_data \u0026 ~OBJEXTS_FLAGS_MASK);\n-\tmemcg = objcg ? obj_cgroup_memcg(objcg) : NULL;\n+\tmemcg = obj_cgroup_memcg(objcg);\n \tif (!memcg)\n \t\tgoto out_unlock;\n \ndiff --git a/mm/shmem.c b/mm/shmem.c\nindex 897fa2b61346f..bd5b53ee3a189 100644\n--- a/mm/shmem.c\n+++ b/mm/shmem.c\n@@ -725,51 +725,258 @@ static const char *shmem_format_huge(int huge)\n }\n #endif\n \n-static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n-\t\tstruct shrink_control *sc, unsigned long nr_to_free)\n+static bool is_shmem_unused_huge_isolated(struct shmem_inode_info *info)\n {\n-\tLIST_HEAD(list), *pos, *next;\n-\tstruct inode *inode;\n+\n+\treturn info-\u003eshrinklist_nid == -1;\n+}\n+\n+static void set_shmem_unused_huge_isolated(struct shmem_inode_info *info)\n+{\n+\tinfo-\u003eshrinklist_nid = -1;\n+}\n+\n+static struct obj_cgroup *shmem_get_and_clear_objcg(struct shmem_inode_info *info)\n+{\n+\tstruct obj_cgroup *objcg = info-\u003eshrinklist_objcg;\n+\n+\tinfo-\u003eshrinklist_objcg = NULL;\n+\n+\treturn objcg;\n+}\n+\n+#ifdef CONFIG_MEMCG\n+static struct obj_cgroup *\n+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\n+\t\t\t    gfp_t gfp)\n+{\n+\tint ret;\n+\n+\tret = folio_memcg_list_lru_alloc(folio, \u0026sbinfo-\u003eshrinklist, gfp);\n+\tif (ret)\n+\t\treturn ERR_PTR(ret);\n+\n+\treturn get_obj_cgroup_from_folio(folio);\n+}\n+#else\n+static struct obj_cgroup *\n+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\n+\t\t\t    gfp_t gfp)\n+{\n+\treturn NULL;\n+}\n+#endif\n+\n+static void shmem_unused_huge_lru_add(struct shmem_sb_info *sbinfo,\n+\t\t\t\t      struct list_head *item, int nid,\n+\t\t\t\t      struct obj_cgroup *objcg)\n+{\n+\tstruct mem_cgroup *memcg;\n+\n+\trcu_read_lock();\n+\tmemcg = obj_cgroup_memcg(objcg);\n+\tlist_lru_add(\u0026sbinfo-\u003eshrinklist, item, nid, memcg);\n+\trcu_read_unlock();\n+}\n+\n+static void shmem_unused_huge_lru_del(struct shmem_sb_info *sbinfo,\n+\t\t\t\t      struct list_head *item, int nid,\n+\t\t\t\t      struct obj_cgroup *objcg)\n+{\n+\tstruct mem_cgroup *memcg;\n+\n+\trcu_read_lock();\n+\tmemcg = obj_cgroup_memcg(objcg);\n+\tlist_lru_del(\u0026sbinfo-\u003eshrinklist, item, nid, memcg);\n+\trcu_read_unlock();\n+}\n+\n+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,\n+\t\t\t\t  gfp_t gfp)\n+{\n+\tstruct shmem_inode_info *info = SHMEM_I(inode);\n+\tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode-\u003ei_sb);\n+\tint nid = folio_nid(folio);\n+\tstruct obj_cgroup *objcg = NULL, *old_objcg = NULL;\n+\n+\tobjcg = shmem_unused_huge_alloc_lru(sbinfo, folio, gfp);\n+\tif (IS_ERR(objcg))\n+\t\treturn;\n+\n+\tspin_lock(\u0026info-\u003elock);\n+\tif (!list_empty(\u0026info-\u003eshrinklist)) {\n+\t\t/* isolated on scan list, let shrink handle it */\n+\t\tif (is_shmem_unused_huge_isolated(info))\n+\t\t\tgoto unlock;\n+\n+\t\tif (info-\u003eshrinklist_nid == nid \u0026\u0026\n+\t\t    info-\u003eshrinklist_objcg == objcg)\n+\t\t\tgoto unlock;\n+\n+\t\tshmem_unused_huge_lru_del(sbinfo, \u0026info-\u003eshrinklist,\n+\t\t\t\t\t  info-\u003eshrinklist_nid,\n+\t\t\t\t\t  info-\u003eshrinklist_objcg);\n+\t\told_objcg = shmem_get_and_clear_objcg(info);\n+\t}\n+\n+\tinfo-\u003eshrinklist_objcg = objcg;\n+\tinfo-\u003eshrinklist_nid = nid;\n+\tshmem_unused_huge_lru_add(sbinfo, \u0026info-\u003eshrinklist, nid, objcg);\n+\tobjcg = NULL;\n+unlock:\n+\tspin_unlock(\u0026info-\u003elock);\n+\tobj_cgroup_put(old_objcg);\n+\tobj_cgroup_put(objcg);\n+}\n+\n+static void shmem_unused_huge_del(struct inode *inode)\n+{\n+\tstruct shmem_inode_info *info = SHMEM_I(inode);\n+\tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode-\u003ei_sb);\n+\tstruct obj_cgroup *objcg = NULL;\n+\n+\tspin_lock(\u0026info-\u003elock);\n+\tif (!list_empty(\u0026info-\u003eshrinklist)) {\n+\t\tshmem_unused_huge_lru_del(sbinfo, \u0026info-\u003eshrinklist,\n+\t\t\t\t\t  info-\u003eshrinklist_nid,\n+\t\t\t\t\t  info-\u003eshrinklist_objcg);\n+\t\tobjcg = shmem_get_and_clear_objcg(info);\n+\t}\n+\tspin_unlock(\u0026info-\u003elock);\n+\n+\tobj_cgroup_put(objcg);\n+}\n+\n+struct shmem_unused_huge_scan {\n+\tstruct list_head list;\n+\tstruct shrink_control *sc;\n+};\n+\n+static enum lru_status shmem_unused_huge_isolate(struct list_head *item,\n+\t\t\t\t\t\t struct list_lru_one *lru,\n+\t\t\t\t\t\t void *arg)\n+{\n+\tstruct shmem_unused_huge_scan *scan = arg;\n \tstruct shmem_inode_info *info;\n-\tstruct folio *folio;\n-\tunsigned long batch = sc ? sc-\u003enr_to_scan : 128;\n-\tunsigned long split = 0, freed = 0;\n+\tstruct inode *inode;\n+\tstruct obj_cgroup *objcg = NULL;\n \n-\tif (list_empty(\u0026sbinfo-\u003eshrinklist))\n-\t\treturn SHRINK_STOP;\n+\tinfo = list_entry(item, struct shmem_inode_info, shrinklist);\n \n-\tspin_lock(\u0026sbinfo-\u003eshrinklist_lock);\n-\tlist_for_each_safe(pos, next, \u0026sbinfo-\u003eshrinklist) {\n-\t\tinfo = list_entry(pos, struct shmem_inode_info, shrinklist);\n+\t/*\n+\t * Use trylock to avoid ABBA deadlock: add/del path takes info-\u003elock\n+\t * before the list_lru bucket lock, while here the order is reversed.\n+\t */\n+\tif (!spin_trylock(\u0026info-\u003elock))\n+\t\treturn LRU_SKIP;\n+\n+\t/* pin the inode */\n+\tinode = igrab(\u0026info-\u003evfs_inode);\n+\t/* inode is about to be evicted */\n+\tif (!inode) {\n+\t\tlist_lru_isolate(lru, item);\n+\t\tobjcg = shmem_get_and_clear_objcg(info);\n+\t\tspin_unlock(\u0026info-\u003elock);\n+\t\tobj_cgroup_put(objcg);\n+\t\treturn LRU_REMOVED;\n+\t}\n \n-\t\t/* pin the inode */\n-\t\tinode = igrab(\u0026info-\u003evfs_inode);\n+\tlist_lru_isolate(lru, item);\n+\tobjcg = shmem_get_and_clear_objcg(info);\n+\tset_shmem_unused_huge_isolated(info);\n+\tlist_add_tail(\u0026info-\u003eshrinklist, \u0026scan-\u003elist);\n+\tspin_unlock(\u0026info-\u003elock);\n+\tobj_cgroup_put(objcg);\n \n-\t\t/* inode is about to be evicted */\n-\t\tif (!inode) {\n-\t\t\tlist_del_init(\u0026info-\u003eshrinklist);\n-\t\t\tgoto next;\n-\t\t}\n+\treturn LRU_REMOVED;\n+}\n \n-\t\tlist_move(\u0026info-\u003eshrinklist, \u0026list);\n-next:\n-\t\tsbinfo-\u003eshrinklist_len--;\n-\t\tif (!--batch)\n-\t\t\tbreak;\n+static bool is_shmem_unused_huge_match(struct folio *folio,\n+\t\t\t\t       struct shrink_control *sc)\n+{\n+\tstruct mem_cgroup *memcg = NULL;\n+\tbool match;\n+\n+\t/* shmem quota reclaim has no NUMA node or memcg restriction */\n+\tif (!sc)\n+\t\treturn true;\n+\n+\tif (folio_nid(folio) != sc-\u003enid)\n+\t\treturn false;\n+\n+\t/*\n+\t * Only non-root memcg reclaim needs to match the folio charge against\n+\t * sc-\u003ememcg. Skip the folio memcg check for global shrinker reclaim and\n+\t * root memcg reclaim.\n+\t */\n+\tif (!sc-\u003ememcg || mem_cgroup_is_root(sc-\u003ememcg))\n+\t\treturn true;\n+\n+\tmemcg = get_mem_cgroup_from_folio(folio);\n+\tmatch = memcg == sc-\u003ememcg;\n+\tmem_cgroup_put(memcg);\n+\n+\treturn match;\n+}\n+\n+static void shmem_unused_huge_drop(struct inode *inode)\n+{\n+\tstruct shmem_inode_info *info = SHMEM_I(inode);\n+\n+\tspin_lock(\u0026info-\u003elock);\n+\tlist_del_init(\u0026info-\u003eshrinklist);\n+\tspin_unlock(\u0026info-\u003elock);\n+}\n+\n+static void shmem_unused_huge_requeue(struct inode *inode, struct folio *folio)\n+{\n+\tstruct shmem_inode_info *info = SHMEM_I(inode);\n+\tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode-\u003ei_sb);\n+\tstruct obj_cgroup *objcg;\n+\tint nid = folio_nid(folio);\n+\n+\tobjcg = shmem_unused_huge_alloc_lru(sbinfo, folio, GFP_NOWAIT);\n+\tif (IS_ERR(objcg)) {\n+\t\tshmem_unused_huge_drop(inode);\n+\t\treturn;\n \t}\n-\tspin_unlock(\u0026sbinfo-\u003eshrinklist_lock);\n \n-\tlist_for_each_safe(pos, next, \u0026list) {\n-\t\tpgoff_t next, end;\n+\tspin_lock(\u0026info-\u003elock);\n+\t/* Requeue the inode to shrinklist */\n+\tlist_del_init(\u0026info-\u003eshrinklist);\n+\tshmem_unused_huge_lru_add(sbinfo, \u0026info-\u003eshrinklist, nid, objcg);\n+\tinfo-\u003eshrinklist_objcg = objcg;\n+\tinfo-\u003eshrinklist_nid = nid;\n+\tspin_unlock(\u0026info-\u003elock);\n+}\n+\n+static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n+\t\tstruct shrink_control *sc, unsigned long nr_to_free)\n+{\n+\tstruct shmem_unused_huge_scan scan;\n+\tstruct inode *inode;\n+\tstruct shmem_inode_info *info;\n+\tstruct folio *folio;\n+\tstruct list_head *pos, *next;\n+\tunsigned long split = 0, freed = 0;\n+\n+\tINIT_LIST_HEAD(\u0026scan.list);\n+\tscan.sc = sc;\n+\tif (sc)\n+\t\tlist_lru_shrink_walk(\u0026sbinfo-\u003eshrinklist, sc,\n+\t\t\t\t     shmem_unused_huge_isolate, \u0026scan);\n+\telse\n+\t\tlist_lru_walk(\u0026sbinfo-\u003eshrinklist, shmem_unused_huge_isolate,\n+\t\t\t      \u0026scan, 128);\n+\n+\tlist_for_each_safe(pos, next, \u0026scan.list) {\n+\t\tpgoff_t folio_end, end;\n \t\tloff_t i_size;\n \t\tint ret;\n \n \t\tinfo = list_entry(pos, struct shmem_inode_info, shrinklist);\n \t\tinode = \u0026info-\u003evfs_inode;\n \n-\t\tif (nr_to_free \u0026\u0026 freed \u003e= nr_to_free)\n-\t\t\tgoto move_back;\n-\n \t\ti_size = i_size_read(inode);\n \t\tfolio = filemap_get_entry(inode-\u003ei_mapping, i_size / PAGE_SIZE);\n \t\tif (!folio || xa_is_value(folio))\n@@ -782,13 +989,19 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n \t\t}\n \n \t\t/* Check if there is anything to gain from splitting */\n-\t\tnext = folio_next_index(folio);\n+\t\tfolio_end = folio_next_index(folio);\n \t\tend = shmem_fallocend(inode, DIV_ROUND_UP(i_size, PAGE_SIZE));\n-\t\tif (end \u003c= folio-\u003eindex || end \u003e= next) {\n+\t\tif (end \u003c= folio-\u003eindex || end \u003e= folio_end) {\n \t\t\tfolio_put(folio);\n \t\t\tgoto drop;\n \t\t}\n \n+\t\tif (!is_shmem_unused_huge_match(folio, scan.sc))\n+\t\t\tgoto move_back;\n+\n+\t\tif (nr_to_free \u0026\u0026 freed \u003e= nr_to_free)\n+\t\t\tgoto move_back;\n+\n \t\t/*\n \t\t * Move the inode on the list back to shrinklist if we failed\n \t\t * to lock the page at this time.\n@@ -796,35 +1009,30 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n \t\t * Waiting for the lock may lead to deadlock in the\n \t\t * reclaim path.\n \t\t */\n-\t\tif (!folio_trylock(folio)) {\n-\t\t\tfolio_put(folio);\n+\t\tif (!folio_trylock(folio))\n+\t\t\tgoto move_back;\n+\n+\t\tif (!is_shmem_unused_huge_match(folio, scan.sc)) {\n+\t\t\tfolio_unlock(folio);\n \t\t\tgoto move_back;\n \t\t}\n \n \t\tret = split_folio(folio);\n \t\tfolio_unlock(folio);\n-\t\tfolio_put(folio);\n \n \t\t/* If split failed move the inode on the list back to shrinklist */\n \t\tif (ret)\n \t\t\tgoto move_back;\n \n-\t\tfreed += next - end;\n+\t\tfreed += folio_end - end;\n \t\tsplit++;\n+\t\tfolio_put(folio);\n drop:\n-\t\tlist_del_init(\u0026info-\u003eshrinklist);\n+\t\tshmem_unused_huge_drop(inode);\n \t\tgoto put;\n move_back:\n-\t\t/*\n-\t\t * Make sure the inode is either on the global list or deleted\n-\t\t * from any local list before iput() since it could be deleted\n-\t\t * in another thread once we put the inode (then the local list\n-\t\t * is corrupted).\n-\t\t */\n-\t\tspin_lock(\u0026sbinfo-\u003eshrinklist_lock);\n-\t\tlist_move(\u0026info-\u003eshrinklist, \u0026sbinfo-\u003eshrinklist);\n-\t\tsbinfo-\u003eshrinklist_len++;\n-\t\tspin_unlock(\u0026sbinfo-\u003eshrinklist_lock);\n+\t\tshmem_unused_huge_requeue(inode, folio);\n+\t\tfolio_put(folio);\n put:\n \t\tiput(inode);\n \t}\n@@ -837,7 +1045,7 @@ static long shmem_unused_huge_scan(struct super_block *sb,\n {\n \tstruct shmem_sb_info *sbinfo = SHMEM_SB(sb);\n \n-\tif (!READ_ONCE(sbinfo-\u003eshrinklist_len))\n+\tif (!list_lru_shrink_count(\u0026sbinfo-\u003eshrinklist, sc))\n \t\treturn SHRINK_STOP;\n \n \treturn shmem_unused_huge_shrink(sbinfo, sc, 0);\n@@ -848,21 +1056,21 @@ static long shmem_unused_huge_count(struct super_block *sb,\n {\n \tstruct shmem_sb_info *sbinfo = SHMEM_SB(sb);\n \n-\t/*\n-\t * The per-superblock shrinklist is filesystem-global and does not\n-\t * honour sc-\u003ememcg, so it is only meaningful on the global (kswapd or\n-\t * root direct reclaim) shrink path. Skip the per-memcg iterations of\n-\t * shrink_slab_memcg() to avoid queueing duplicate global work.\n-\t */\n-\tif (!mem_cgroup_shrink_is_root(sc))\n-\t\treturn 0;\n-\n-\treturn READ_ONCE(sbinfo-\u003eshrinklist_len);\n+\treturn list_lru_shrink_count(\u0026sbinfo-\u003eshrinklist, sc);\n }\n #else /* !CONFIG_TRANSPARENT_HUGEPAGE */\n \n #define shmem_huge SHMEM_HUGE_DENY\n \n+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,\n+\t\t\t\t  gfp_t gfp)\n+{\n+}\n+\n+static void shmem_unused_huge_del(struct inode *inode)\n+{\n+}\n+\n static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n \t\tstruct shrink_control *sc, unsigned long nr_to_free)\n {\n@@ -1418,14 +1626,7 @@ static void shmem_evict_inode(struct inode *inode)\n \t\tinode-\u003ei_size = 0;\n \t\tmapping_set_exiting(inode-\u003ei_mapping);\n \t\tshmem_truncate_range(inode, 0, (loff_t)-1);\n-\t\tif (!list_empty(\u0026info-\u003eshrinklist)) {\n-\t\t\tspin_lock(\u0026sbinfo-\u003eshrinklist_lock);\n-\t\t\tif (!list_empty(\u0026info-\u003eshrinklist)) {\n-\t\t\t\tlist_del_init(\u0026info-\u003eshrinklist);\n-\t\t\t\tsbinfo-\u003eshrinklist_len--;\n-\t\t\t}\n-\t\t\tspin_unlock(\u0026sbinfo-\u003eshrinklist_lock);\n-\t\t}\n+\t\tshmem_unused_huge_del(inode);\n \t\twhile (!list_empty(\u0026info-\u003eswaplist)) {\n \t\t\t/* Wait while shmem_unuse() is scanning this inode... */\n \t\t\twait_var_event(\u0026info-\u003estop_eviction,\n@@ -2536,27 +2737,6 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,\n \n alloced:\n \talloced = true;\n-\tif (folio_test_large(folio) \u0026\u0026\n-\t    DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE) \u003c\n-\t\t\t\t\tfolio_next_index(folio)) {\n-\t\tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode-\u003ei_sb);\n-\t\tstruct shmem_inode_info *info = SHMEM_I(inode);\n-\t\t/*\n-\t\t * Part of the large folio is beyond i_size: subject\n-\t\t * to shrink under memory pressure.\n-\t\t */\n-\t\tspin_lock(\u0026sbinfo-\u003eshrinklist_lock);\n-\t\t/*\n-\t\t * _careful to defend against unlocked access to\n-\t\t * -\u003eshrink_list in shmem_unused_huge_shrink()\n-\t\t */\n-\t\tif (list_empty_careful(\u0026info-\u003eshrinklist)) {\n-\t\t\tlist_add_tail(\u0026info-\u003eshrinklist,\n-\t\t\t\t      \u0026sbinfo-\u003eshrinklist);\n-\t\t\tsbinfo-\u003eshrinklist_len++;\n-\t\t}\n-\t\tspin_unlock(\u0026sbinfo-\u003eshrinklist_lock);\n-\t}\n \n \tif (sgp == SGP_WRITE)\n \t\tfolio_set_referenced(folio);\n@@ -2586,6 +2766,20 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,\n \t\terror = -EINVAL;\n \t\tgoto unlock;\n \t}\n+\n+\t/*\n+\t * Queue the inode on the shrink list only after all checks that might\n+\t * remove the folio have passed. Otherwise the inode could be left on\n+\t * the shrinker list with a stale folio.\n+\t */\n+\tif (alloced \u0026\u0026 folio_test_large(folio) \u0026\u0026\n+\t    DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE) \u003c folio_next_index(folio)) {\n+\t\t/*\n+\t\t * Part of the large folio is beyond i_size: subject\n+\t\t * to shrink under memory pressure.\n+\t\t */\n+\t\tshmem_unused_huge_add(inode, folio, gfp);\n+\t}\n out:\n \t*foliop = folio;\n \treturn 0;\n@@ -3062,6 +3256,10 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,\n \tif (info-\u003efsflags)\n \t\tshmem_set_inode_flags(inode, info-\u003efsflags, NULL);\n \tINIT_LIST_HEAD(\u0026info-\u003eshrinklist);\n+#ifdef CONFIG_TRANSPARENT_HUGEPAGE\n+\tinfo-\u003eshrinklist_objcg = NULL;\n+\tinfo-\u003eshrinklist_nid = -1;\n+#endif\n \tINIT_LIST_HEAD(\u0026info-\u003eswaplist);\n \tcache_no_acl(inode);\n \tif (sbinfo-\u003enoswap)\n@@ -4936,6 +5134,9 @@ static void shmem_put_super(struct super_block *sb)\n #endif\n \tfree_percpu(sbinfo-\u003eino_batch);\n \tpercpu_counter_destroy(\u0026sbinfo-\u003eused_blocks);\n+#ifdef CONFIG_TRANSPARENT_HUGEPAGE\n+\tlist_lru_destroy(\u0026sbinfo-\u003eshrinklist);\n+#endif\n \tmpol_put(sbinfo-\u003empol);\n #ifdef CONFIG_TMPFS_XATTR\n \tsimple_xattr_cache_cleanup(\u0026sbinfo-\u003exa_cache);\n@@ -5029,8 +5230,11 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)\n \traw_spin_lock_init(\u0026sbinfo-\u003estat_lock);\n \tif (percpu_counter_init(\u0026sbinfo-\u003eused_blocks, 0, GFP_KERNEL))\n \t\tgoto failed;\n-\tspin_lock_init(\u0026sbinfo-\u003eshrinklist_lock);\n-\tINIT_LIST_HEAD(\u0026sbinfo-\u003eshrinklist);\n+\n+#ifdef CONFIG_TRANSPARENT_HUGEPAGE\n+\tif (list_lru_init_memcg(\u0026sbinfo-\u003eshrinklist, sb-\u003es_shrink))\n+\t\tgoto failed;\n+#endif\n \n \tsb-\u003es_maxbytes = MAX_LFS_FILESIZE;\n \tsb-\u003es_blocksize = PAGE_SIZE;\ndiff --git a/mm/zswap.c b/mm/zswap.c\nindex 37f34e406c8e3..c1dc60926bad9 100644\n--- a/mm/zswap.c\n+++ b/mm/zswap.c\n@@ -647,19 +647,6 @@ static int zswap_enabled_param_set(const char *val,\n * lru functions\n **********************************/\n \n-/* should be called under RCU */\n-#ifdef CONFIG_MEMCG\n-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)\n-{\n-\treturn entry-\u003eobjcg ? obj_cgroup_memcg(entry-\u003eobjcg) : NULL;\n-}\n-#else\n-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)\n-{\n-\treturn NULL;\n-}\n-#endif\n-\n static inline int entry_to_nid(struct zswap_entry *entry)\n {\n \treturn page_to_nid(virt_to_page(entry));\n@@ -682,7 +669,7 @@ static void zswap_lru_add(struct zswap_entry *entry)\n \t * Similar reasoning holds for list_lru_del().\n \t */\n \trcu_read_lock();\n-\tmemcg = mem_cgroup_from_entry(entry);\n+\tmemcg = obj_cgroup_memcg(entry-\u003eobjcg);\n \t/* will always succeed */\n \tlist_lru_add(\u0026zswap_list_lru, \u0026entry-\u003elru, nid, memcg);\n \trcu_read_unlock();\n@@ -694,7 +681,7 @@ static void zswap_lru_del(struct zswap_entry *entry)\n \tstruct mem_cgroup *memcg;\n \n \trcu_read_lock();\n-\tmemcg = mem_cgroup_from_entry(entry);\n+\tmemcg = obj_cgroup_memcg(entry-\u003eobjcg);\n \t/* will always succeed */\n \tlist_lru_del(\u0026zswap_list_lru, \u0026entry-\u003elru, nid, memcg);\n \trcu_read_unlock();\n"
}

2/1 2026/08/17 10:13 agent patch-evaluator
1m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": [
    "TRANSPARENT_HUGEPAGE",
    "MEMCG",
    "SHMEM",
    "ZSWAP"
  ],
  "FocusSymbols": [
    "shmem_get_folio",
    "shmem_read_folio_gfp",
    "shmem_read_mapping_page_gfp"
  ],
  "Reasoning": "The patch modifies the shmem subsystem to use a per-memcg list_lru for tracking unused huge pages instead of a global shrinklist. This allows the shrinker to reclaim unused huge pages on a per-memcg basis, avoiding duplicate work and respecting memcg boundaries. It also modifies `obj_cgroup_memcg` to handle NULL pointers, which affects zswap as well. The changes involve core memory management and shmem logic, specifically around page allocation, eviction, and memory reclaim (shrinker). This is a significant functional change that should be heavily fuzzed to ensure no memory leaks, use-after-free, or deadlocks occur during memcg reclaim or shmem operations.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
  even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).
- Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed,
  ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU.
- Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove)
  that are executed only during PCI hot-unplug or sysfs driver unbind operations.

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
   Prefer non-static, non-inlined API entrypoint functions over internal static helper functions
   (which are inlined by the compiler and do not have distinct symbol addresses).
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs
   needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs
   output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit b27c75b9e87bfd237638cc76a52d37576e801f9c
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Aug 17 10:13:48 2026 +0000

    syz-cluster: applied patch under review

diff --git a/fs/super.c b/fs/super.c
index 05e4431730387..3ecce24328f67 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -171,19 +171,6 @@ static void super_wake(struct super_block *sb, unsigned int flag)
 	wake_up_var(&sb->s_flags);
 }
 
-/*
- * The s_op->nr_cached_objects hooks (used for example by btrfs and xfs)
- * operate on filesystem-global state and ignore sc->memcg. Driving them
- * from per-memcg shrink_slab_memcg() invocations only burns CPU walking
- * per-cpu counters and queueing duplicate work: the actual reclaim happens on
- * the global path (kswapd or root direct reclaim) regardless. Restrict them
- * to that path.
- */
-static inline bool super_fs_objects_eligible(struct shrink_control *sc)
-{
-	return !sc->memcg || mem_cgroup_is_root(sc->memcg);
-}
-
 /*
  * One thing we have to be careful of with a per-sb shrinker is that we don't
  * drop the last active reference to the superblock from within the shrinker.
@@ -213,7 +200,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
 	if (!super_trylock_shared(sb))
 		return SHRINK_STOP;
 
-	if (sb->s_op->nr_cached_objects && super_fs_objects_eligible(sc))
+	if (sb->s_op->nr_cached_objects)
 		fs_objects = sb->s_op->nr_cached_objects(sb, sc);
 
 	inodes = list_lru_shrink_count(&sb->s_inode_lru, sc);
@@ -274,8 +261,7 @@ static unsigned long super_cache_count(struct shrinker *shrink,
 		return 0;
 	smp_rmb();
 
-	if (sb->s_op && sb->s_op->nr_cached_objects &&
-	    super_fs_objects_eligible(sc))
+	if (sb->s_op && sb->s_op->nr_cached_objects)
 		total_objects = sb->s_op->nr_cached_objects(sb, sc);
 
 	total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc);
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index cba35690c21aa..5107c227ae9b8 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -375,7 +375,7 @@ enum objext_flags {
 static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)
 {
 	lockdep_assert_once(rcu_read_lock_held() || lockdep_is_held(&cgroup_mutex));
-	return READ_ONCE(objcg->memcg);
+	return objcg ? READ_ONCE(objcg->memcg) : NULL;
 }
 
 /*
@@ -428,7 +428,7 @@ static inline struct mem_cgroup *folio_memcg(struct folio *folio)
 {
 	struct obj_cgroup *objcg = folio_objcg(folio);
 
-	return objcg ? obj_cgroup_memcg(objcg) : NULL;
+	return obj_cgroup_memcg(objcg);
 }
 
 /*
@@ -471,7 +471,7 @@ static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)
 
 	objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK);
 
-	return objcg ? obj_cgroup_memcg(objcg) : NULL;
+	return obj_cgroup_memcg(objcg);
 }
 
 static inline struct mem_cgroup *page_memcg_check(struct page *page)
@@ -1045,6 +1045,11 @@ void mem_cgroup_flush_workqueue(void);
 extern int mem_cgroup_init(void);
 #else /* CONFIG_MEMCG */
 
+static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)
+{
+	return NULL;
+}
+
 #define MEM_CGROUP_ID_SHIFT	0
 
 #define root_mem_cgroup		(NULL)
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 5663dff53186e..a7c7a96a7cbf9 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -11,6 +11,7 @@
 #include <linux/fs_parser.h>
 #include <linux/userfaultfd_k.h>
 #include <linux/bits.h>
+#include <linux/list_lru.h>
 
 /* inode in-kernel data */
 
@@ -54,6 +55,11 @@ struct shmem_inode_info {
 	struct dquot __rcu	*i_dquot[MAXQUOTAS];
 #endif
 	struct inode		vfs_inode;
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	struct obj_cgroup	*shrinklist_objcg;
+	int			shrinklist_nid;
+#endif
 };
 
 #define SHMEM_FL_USER_VISIBLE		(FS_FL_USER_VISIBLE | FS_CASEFOLD_FL)
@@ -83,9 +89,9 @@ struct shmem_sb_info {
 	ino_t next_ino;		    /* The next per-sb inode number to use */
 	ino_t __percpu *ino_batch;  /* The next per-cpu inode number to use */
 	struct mempolicy *mpol;     /* default memory policy for mappings */
-	spinlock_t shrinklist_lock;   /* Protects shrinklist */
-	struct list_head shrinklist;  /* List of shinkable inodes */
-	unsigned long shrinklist_len; /* Length of shrinklist */
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	struct list_lru shrinklist; /* List of shrinkable inodes */
+#endif
 	struct shmem_quota_limits qlimits; /* Default quota limits */
 	struct simple_xattr_cache xa_cache;
 };
diff --git a/mm/page_owner.c b/mm/page_owner.c
index fbbda7ba914ba..3fc37d9b908ef 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -575,7 +575,7 @@ static inline int print_page_owner_memcg(char *kbuf, size_t count, int ret,
 	}
 
 	objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK);
-	memcg = objcg ? obj_cgroup_memcg(objcg) : NULL;
+	memcg = obj_cgroup_memcg(objcg);
 	if (!memcg)
 		goto out_unlock;
 
diff --git a/mm/shmem.c b/mm/shmem.c
index 897fa2b61346f..bd5b53ee3a189 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -725,51 +725,258 @@ static const char *shmem_format_huge(int huge)
 }
 #endif
 
-static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
-		struct shrink_control *sc, unsigned long nr_to_free)
+static bool is_shmem_unused_huge_isolated(struct shmem_inode_info *info)
 {
-	LIST_HEAD(list), *pos, *next;
-	struct inode *inode;
+
+	return info->shrinklist_nid == -1;
+}
+
+static void set_shmem_unused_huge_isolated(struct shmem_inode_info *info)
+{
+	info->shrinklist_nid = -1;
+}
+
+static struct obj_cgroup *shmem_get_and_clear_objcg(struct shmem_inode_info *info)
+{
+	struct obj_cgroup *objcg = info->shrinklist_objcg;
+
+	info->shrinklist_objcg = NULL;
+
+	return objcg;
+}
+
+#ifdef CONFIG_MEMCG
+static struct obj_cgroup *
+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,
+			    gfp_t gfp)
+{
+	int ret;
+
+	ret = folio_memcg_list_lru_alloc(folio, &sbinfo->shrinklist, gfp);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return get_obj_cgroup_from_folio(folio);
+}
+#else
+static struct obj_cgroup *
+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,
+			    gfp_t gfp)
+{
+	return NULL;
+}
+#endif
+
+static void shmem_unused_huge_lru_add(struct shmem_sb_info *sbinfo,
+				      struct list_head *item, int nid,
+				      struct obj_cgroup *objcg)
+{
+	struct mem_cgroup *memcg;
+
+	rcu_read_lock();
+	memcg = obj_cgroup_memcg(objcg);
+	list_lru_add(&sbinfo->shrinklist, item, nid, memcg);
+	rcu_read_unlock();
+}
+
+static void shmem_unused_huge_lru_del(struct shmem_sb_info *sbinfo,
+				      struct list_head *item, int nid,
+				      struct obj_cgroup *objcg)
+{
+	struct mem_cgroup *memcg;
+
+	rcu_read_lock();
+	memcg = obj_cgroup_memcg(objcg);
+	list_lru_del(&sbinfo->shrinklist, item, nid, memcg);
+	rcu_read_unlock();
+}
+
+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,
+				  gfp_t gfp)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	int nid = folio_nid(folio);
+	struct obj_cgroup *objcg = NULL, *old_objcg = NULL;
+
+	objcg = shmem_unused_huge_alloc_lru(sbinfo, folio, gfp);
+	if (IS_ERR(objcg))
+		return;
+
+	spin_lock(&info->lock);
+	if (!list_empty(&info->shrinklist)) {
+		/* isolated on scan list, let shrink handle it */
+		if (is_shmem_unused_huge_isolated(info))
+			goto unlock;
+
+		if (info->shrinklist_nid == nid &&
+		    info->shrinklist_objcg == objcg)
+			goto unlock;
+
+		shmem_unused_huge_lru_del(sbinfo, &info->shrinklist,
+					  info->shrinklist_nid,
+					  info->shrinklist_objcg);
+		old_objcg = shmem_get_and_clear_objcg(info);
+	}
+
+	info->shrinklist_objcg = objcg;
+	info->shrinklist_nid = nid;
+	shmem_unused_huge_lru_add(sbinfo, &info->shrinklist, nid, objcg);
+	objcg = NULL;
+unlock:
+	spin_unlock(&info->lock);
+	obj_cgroup_put(old_objcg);
+	obj_cgroup_put(objcg);
+}
+
+static void shmem_unused_huge_del(struct inode *inode)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct obj_cgroup *objcg = NULL;
+
+	spin_lock(&info->lock);
+	if (!list_empty(&info->shrinklist)) {
+		shmem_unused_huge_lru_del(sbinfo, &info->shrinklist,
+					  info->shrinklist_nid,
+					  info->shrinklist_objcg);
+		objcg = shmem_get_and_clear_objcg(info);
+	}
+	spin_unlock(&info->lock);
+
+	obj_cgroup_put(objcg);
+}
+
+struct shmem_unused_huge_scan {
+	struct list_head list;
+	struct shrink_control *sc;
+};
+
+static enum lru_status shmem_unused_huge_isolate(struct list_head *item,
+						 struct list_lru_one *lru,
+						 void *arg)
+{
+	struct shmem_unused_huge_scan *scan = arg;
 	struct shmem_inode_info *info;
-	struct folio *folio;
-	unsigned long batch = sc ? sc->nr_to_scan : 128;
-	unsigned long split = 0, freed = 0;
+	struct inode *inode;
+	struct obj_cgroup *objcg = NULL;
 
-	if (list_empty(&sbinfo->shrinklist))
-		return SHRINK_STOP;
+	info = list_entry(item, struct shmem_inode_info, shrinklist);
 
-	spin_lock(&sbinfo->shrinklist_lock);
-	list_for_each_safe(pos, next, &sbinfo->shrinklist) {
-		info = list_entry(pos, struct shmem_inode_info, shrinklist);
+	/*
+	 * Use trylock to avoid ABBA deadlock: add/del path takes info->lock
+	 * before the list_lru bucket lock, while here the order is reversed.
+	 */
+	if (!spin_trylock(&info->lock))
+		return LRU_SKIP;
+
+	/* pin the inode */
+	inode = igrab(&info->vfs_inode);
+	/* inode is about to be evicted */
+	if (!inode) {
+		list_lru_isolate(lru, item);
+		objcg = shmem_get_and_clear_objcg(info);
+		spin_unlock(&info->lock);
+		obj_cgroup_put(objcg);
+		return LRU_REMOVED;
+	}
 
-		/* pin the inode */
-		inode = igrab(&info->vfs_inode);
+	list_lru_isolate(lru, item);
+	objcg = shmem_get_and_clear_objcg(info);
+	set_shmem_unused_huge_isolated(info);
+	list_add_tail(&info->shrinklist, &scan->list);
+	spin_unlock(&info->lock);
+	obj_cgroup_put(objcg);
 
-		/* inode is about to be evicted */
-		if (!inode) {
-			list_del_init(&info->shrinklist);
-			goto next;
-		}
+	return LRU_REMOVED;
+}
 
-		list_move(&info->shrinklist, &list);
-next:
-		sbinfo->shrinklist_len--;
-		if (!--batch)
-			break;
+static bool is_shmem_unused_huge_match(struct folio *folio,
+				       struct shrink_control *sc)
+{
+	struct mem_cgroup *memcg = NULL;
+	bool match;
+
+	/* shmem quota reclaim has no NUMA node or memcg restriction */
+	if (!sc)
+		return true;
+
+	if (folio_nid(folio) != sc->nid)
+		return false;
+
+	/*
+	 * Only non-root memcg reclaim needs to match the folio charge against
+	 * sc->memcg. Skip the folio memcg check for global shrinker reclaim and
+	 * root memcg reclaim.
+	 */
+	if (!sc->memcg || mem_cgroup_is_root(sc->memcg))
+		return true;
+
+	memcg = get_mem_cgroup_from_folio(folio);
+	match = memcg == sc->memcg;
+	mem_cgroup_put(memcg);
+
+	return match;
+}
+
+static void shmem_unused_huge_drop(struct inode *inode)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+
+	spin_lock(&info->lock);
+	list_del_init(&info->shrinklist);
+	spin_unlock(&info->lock);
+}
+
+static void shmem_unused_huge_requeue(struct inode *inode, struct folio *folio)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct obj_cgroup *objcg;
+	int nid = folio_nid(folio);
+
+	objcg = shmem_unused_huge_alloc_lru(sbinfo, folio, GFP_NOWAIT);
+	if (IS_ERR(objcg)) {
+		shmem_unused_huge_drop(inode);
+		return;
 	}
-	spin_unlock(&sbinfo->shrinklist_lock);
 
-	list_for_each_safe(pos, next, &list) {
-		pgoff_t next, end;
+	spin_lock(&info->lock);
+	/* Requeue the inode to shrinklist */
+	list_del_init(&info->shrinklist);
+	shmem_unused_huge_lru_add(sbinfo, &info->shrinklist, nid, objcg);
+	info->shrinklist_objcg = objcg;
+	info->shrinklist_nid = nid;
+	spin_unlock(&info->lock);
+}
+
+static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
+		struct shrink_control *sc, unsigned long nr_to_free)
+{
+	struct shmem_unused_huge_scan scan;
+	struct inode *inode;
+	struct shmem_inode_info *info;
+	struct folio *folio;
+	struct list_head *pos, *next;
+	unsigned long split = 0, freed = 0;
+
+	INIT_LIST_HEAD(&scan.list);
+	scan.sc = sc;
+	if (sc)
+		list_lru_shrink_walk(&sbinfo->shrinklist, sc,
+				     shmem_unused_huge_isolate, &scan);
+	else
+		list_lru_walk(&sbinfo->shrinklist, shmem_unused_huge_isolate,
+			      &scan, 128);
+
+	list_for_each_safe(pos, next, &scan.list) {
+		pgoff_t folio_end, end;
 		loff_t i_size;
 		int ret;
 
 		info = list_entry(pos, struct shmem_inode_info, shrinklist);
 		inode = &info->vfs_inode;
 
-		if (nr_to_free && freed >= nr_to_free)
-			goto move_back;
-
 		i_size = i_size_read(inode);
 		folio = filemap_get_entry(inode->i_mapping, i_size / PAGE_SIZE);
 		if (!folio || xa_is_value(folio))
@@ -782,13 +989,19 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		}
 
 		/* Check if there is anything to gain from splitting */
-		next = folio_next_index(folio);
+		folio_end = folio_next_index(folio);
 		end = shmem_fallocend(inode, DIV_ROUND_UP(i_size, PAGE_SIZE));
-		if (end <= folio->index || end >= next) {
+		if (end <= folio->index || end >= folio_end) {
 			folio_put(folio);
 			goto drop;
 		}
 
+		if (!is_shmem_unused_huge_match(folio, scan.sc))
+			goto move_back;
+
+		if (nr_to_free && freed >= nr_to_free)
+			goto move_back;
+
 		/*
 		 * Move the inode on the list back to shrinklist if we failed
 		 * to lock the page at this time.
@@ -796,35 +1009,30 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		 * Waiting for the lock may lead to deadlock in the
 		 * reclaim path.
 		 */
-		if (!folio_trylock(folio)) {
-			folio_put(folio);
+		if (!folio_trylock(folio))
+			goto move_back;
+
+		if (!is_shmem_unused_huge_match(folio, scan.sc)) {
+			folio_unlock(folio);
 			goto move_back;
 		}
 
 		ret = split_folio(folio);
 		folio_unlock(folio);
-		folio_put(folio);
 
 		/* If split failed move the inode on the list back to shrinklist */
 		if (ret)
 			goto move_back;
 
-		freed += next - end;
+		freed += folio_end - end;
 		split++;
+		folio_put(folio);
 drop:
-		list_del_init(&info->shrinklist);
+		shmem_unused_huge_drop(inode);
 		goto put;
 move_back:
-		/*
-		 * Make sure the inode is either on the global list or deleted
-		 * from any local list before iput() since it could be deleted
-		 * in another thread once we put the inode (then the local list
-		 * is corrupted).
-		 */
-		spin_lock(&sbinfo->shrinklist_lock);
-		list_move(&info->shrinklist, &sbinfo->shrinklist);
-		sbinfo->shrinklist_len++;
-		spin_unlock(&sbinfo->shrinklist_lock);
+		shmem_unused_huge_requeue(inode, folio);
+		folio_put(folio);
 put:
 		iput(inode);
 	}
@@ -837,7 +1045,7 @@ static long shmem_unused_huge_scan(struct super_block *sb,
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
-	if (!READ_ONCE(sbinfo->shrinklist_len))
+	if (!list_lru_shrink_count(&sbinfo->shrinklist, sc))
 		return SHRINK_STOP;
 
 	return shmem_unused_huge_shrink(sbinfo, sc, 0);
@@ -848,21 +1056,21 @@ static long shmem_unused_huge_count(struct super_block *sb,
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
-	/*
-	 * The per-superblock shrinklist is filesystem-global and does not
-	 * honour sc->memcg, so it is only meaningful on the global (kswapd or
-	 * root direct reclaim) shrink path. Skip the per-memcg iterations of
-	 * shrink_slab_memcg() to avoid queueing duplicate global work.
-	 */
-	if (!mem_cgroup_shrink_is_root(sc))
-		return 0;
-
-	return READ_ONCE(sbinfo->shrinklist_len);
+	return list_lru_shrink_count(&sbinfo->shrinklist, sc);
 }
 #else /* !CONFIG_TRANSPARENT_HUGEPAGE */
 
 #define shmem_huge SHMEM_HUGE_DENY
 
+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,
+				  gfp_t gfp)
+{
+}
+
+static void shmem_unused_huge_del(struct inode *inode)
+{
+}
+
 static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		struct shrink_control *sc, unsigned long nr_to_free)
 {
@@ -1418,14 +1626,7 @@ static void shmem_evict_inode(struct inode *inode)
 		inode->i_size = 0;
 		mapping_set_exiting(inode->i_mapping);
 		shmem_truncate_range(inode, 0, (loff_t)-1);
-		if (!list_empty(&info->shrinklist)) {
-			spin_lock(&sbinfo->shrinklist_lock);
-			if (!list_empty(&info->shrinklist)) {
-				list_del_init(&info->shrinklist);
-				sbinfo->shrinklist_len--;
-			}
-			spin_unlock(&sbinfo->shrinklist_lock);
-		}
+		shmem_unused_huge_del(inode);
 		while (!list_empty(&info->swaplist)) {
 			/* Wait while shmem_unuse() is scanning this inode... */
 			wait_var_event(&info->stop_eviction,
@@ -2536,27 +2737,6 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
 
 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);
@@ -2586,6 +2766,20 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
 		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)) {
+		/*
+		 * Part of the large folio is beyond i_size: subject
+		 * to shrink under memory pressure.
+		 */
+		shmem_unused_huge_add(inode, folio, gfp);
+	}
 out:
 	*foliop = folio;
 	return 0;
@@ -3062,6 +3256,10 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
 	if (info->fsflags)
 		shmem_set_inode_flags(inode, info->fsflags, NULL);
 	INIT_LIST_HEAD(&info->shrinklist);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	info->shrinklist_objcg = NULL;
+	info->shrinklist_nid = -1;
+#endif
 	INIT_LIST_HEAD(&info->swaplist);
 	cache_no_acl(inode);
 	if (sbinfo->noswap)
@@ -4936,6 +5134,9 @@ static void shmem_put_super(struct super_block *sb)
 #endif
 	free_percpu(sbinfo->ino_batch);
 	percpu_counter_destroy(&sbinfo->used_blocks);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	list_lru_destroy(&sbinfo->shrinklist);
+#endif
 	mpol_put(sbinfo->mpol);
 #ifdef CONFIG_TMPFS_XATTR
 	simple_xattr_cache_cleanup(&sbinfo->xa_cache);
@@ -5029,8 +5230,11 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
 	raw_spin_lock_init(&sbinfo->stat_lock);
 	if (percpu_counter_init(&sbinfo->used_blocks, 0, GFP_KERNEL))
 		goto failed;
-	spin_lock_init(&sbinfo->shrinklist_lock);
-	INIT_LIST_HEAD(&sbinfo->shrinklist);
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	if (list_lru_init_memcg(&sbinfo->shrinklist, sb->s_shrink))
+		goto failed;
+#endif
 
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 	sb->s_blocksize = PAGE_SIZE;
diff --git a/mm/zswap.c b/mm/zswap.c
index 37f34e406c8e3..c1dc60926bad9 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -647,19 +647,6 @@ static int zswap_enabled_param_set(const char *val,
 * lru functions
 **********************************/
 
-/* should be called under RCU */
-#ifdef CONFIG_MEMCG
-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)
-{
-	return entry->objcg ? obj_cgroup_memcg(entry->objcg) : NULL;
-}
-#else
-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)
-{
-	return NULL;
-}
-#endif
-
 static inline int entry_to_nid(struct zswap_entry *entry)
 {
 	return page_to_nid(virt_to_page(entry));
@@ -682,7 +669,7 @@ static void zswap_lru_add(struct zswap_entry *entry)
 	 * Similar reasoning holds for list_lru_del().
 	 */
 	rcu_read_lock();
-	memcg = mem_cgroup_from_entry(entry);
+	memcg = obj_cgroup_memcg(entry->objcg);
 	/* will always succeed */
 	list_lru_add(&zswap_list_lru, &entry->lru, nid, memcg);
 	rcu_read_unlock();
@@ -694,7 +681,7 @@ static void zswap_lru_del(struct zswap_entry *entry)
 	struct mem_cgroup *memcg;
 
 	rcu_read_lock();
-	memcg = mem_cgroup_from_entry(entry);
+	memcg = obj_cgroup_memcg(entry->objcg);
 	/* will always succeed */
 	list_lru_del(&zswap_list_lru, &entry->lru, nid, memcg);
 	rcu_read_unlock();

3/2 2026/08/17 10:13 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 10032
							output: 22
							thoughts: 583
						

Thoughts:
**Analyzing the Shmem Huge Page Shrinking Patch**

Okay, so I'm looking at this patch that's fundamentally changing how shared memory (shmem) handles unused huge pages. The core idea is shifting from a global `shrinklist` to a per-memcg `list_lru` for managing those unused pages. This immediately makes me think about potential concurrency issues and the impact on memory accounting.

The patch also seems to be cleaning up the `obj_cgroup_memcg` function to be more robust, handling NULL `objcg` cases, which is a good move for defensive programming. I'm also seeing a fair bit of modification to how unused huge pages are actually shrunk, with `shmem_unused_huge_shrink` now leaning on `list_lru_shrink_walk` and `list_lru_walk`. That's where a lot of the critical work is happening.

Let me break down the specific function changes to get a better handle on the scope:

*   It looks like `super_fs_objects_eligible` has been removed. That's a direct impact to related `super_cache_scan` and `super_cache_count`.
*   A change in `include/linux/memcontrol.h` to the `obj_cgroup_memcg` to make it handle NULL.
*   `shmem_unused_huge_shrink` is heavily modified, which is a major point of interest.
*   `shmem_unused_huge_scan` and `shmem_unused_huge_count` now use `list_lru_shrink_count`.
*   `shmem_get_folio_gfp` is using `shmem_unused_huge_add`.
*   `shmem_evict_inode` is using `shmem_unused_huge_del`.
*   `shmem_fill_super` is initializing the `list_lru` via `list_lru_init_memcg`.

This is definitely a functional change in a core memory management area. It's a high-impact area, warranting a thorough fuzzing campaign.

So, where do I focus the fuzzing efforts? The key functions appear to be:

*   `shmem_unused_huge_shrink`
*   `shmem_unused_huge_scan`
*   `shmem_unused_huge_count`

`shmem_get_folio_gfp` and `shmem_evict_inode` may also be worth exploring, but they might be too hot or too well-tested to yield immediate results.

Hmm, `shmem_unused_huge_shrink` and `shmem_unused_huge_scan` are both static, which might make fuzzing a bit trickier, but they are clearly critical to the core logic. I need to figure out where they're being *called* from. I need to trace how the `shmem_unused_huge_scan` is being used, so I am going to have to check the code in `mm/shmem.c`.



4/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_unused_huge_scan"
}

Results:
{
  "Output": "mm/shmem.c=832=static void shmem_unused_huge_del(struct inode *inode)\n--\nmm/shmem.c-849-\nmm/shmem.c:850:struct shmem_unused_huge_scan {\nmm/shmem.c-851-\tstruct list_head list;\n--\nmm/shmem.c=855=static enum lru_status shmem_unused_huge_isolate(struct list_head *item,\n--\nmm/shmem.c-858-{\nmm/shmem.c:859:\tstruct shmem_unused_huge_scan *scan = arg;\nmm/shmem.c-860-\tstruct shmem_inode_info *info;\n--\nmm/shmem.c=953=static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n--\nmm/shmem.c-955-{\nmm/shmem.c:956:\tstruct shmem_unused_huge_scan scan;\nmm/shmem.c-957-\tstruct inode *inode;\n--\nmm/shmem.c-1042-\nmm/shmem.c:1043:static long shmem_unused_huge_scan(struct super_block *sb,\nmm/shmem.c-1044-\t\tstruct shrink_control *sc)\n--\nmm/shmem.c=5441=static const struct super_operations shmem_ops = {\n--\nmm/shmem.c-5456-\t.nr_cached_objects\t= shmem_unused_huge_count,\nmm/shmem.c:5457:\t.free_cached_objects\t= shmem_unused_huge_scan,\nmm/shmem.c-5458-#endif\n"
}

5/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 11761
							output: 23
							thoughts: 84
						

Thoughts:
**Analyzing Shared Memory Operations**

Okay, so I'm looking at these `shmem` functions – specifically `shmem_unused_huge_scan` and `shmem_unused_huge_count`. I notice they're defined as `static`, but then they're assigned to members of `shmem_ops`, specifically `shmem_ops.free_cached_objects` and `shmem_ops.nr_cached_objects`. That seems a little unusual; a static function usually indicates it's meant to be internal to the file. This makes me wonder if anything else has changed.

Let me just quickly check `mm/shmem.c` for any *other* modifications to non-static functions within that file. I want to see if this is part of a larger, potentially more impactful change to how shared memory objects are managed. It's important to understand the full scope of these adjustments. I need to make sure I don't miss any dependencies or unintended consequences that might result from these particular reassignments.



6/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_get_folio_gfp"
}

Results:
{
  "Output": "mm/shmem.c=2244=static struct folio *shmem_swap_alloc_folio(struct inode *inode,\n--\nmm/shmem.c-2274- * When a page is moved from swapcache to shmem filecache (either by the\nmm/shmem.c:2275: * usual swapin of shmem_get_folio_gfp(), or by the less common swapoff of\nmm/shmem.c-2276- * shmem_unuse_inode()), it may have been read in earlier from swap, in\n--\nmm/shmem.c=2455=static int shmem_swapin_folio(struct inode *inode, pgoff_t index,\n--\nmm/shmem.c-2620-/*\nmm/shmem.c:2621: * shmem_get_folio_gfp - find page in cache, or get from swap, or allocate\nmm/shmem.c-2622- *\n--\nmm/shmem.c-2628- */\nmm/shmem.c:2629:static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,\nmm/shmem.c-2630-\t\tloff_t write_end, struct folio **foliop, enum sgp_type sgp,\n--\nmm/shmem.c=2825=int shmem_get_folio(struct inode *inode, pgoff_t index, loff_t write_end,\n--\nmm/shmem.c-2827-{\nmm/shmem.c:2828:\treturn shmem_get_folio_gfp(inode, index, write_end, foliop, sgp,\nmm/shmem.c-2829-\t\t\tmapping_gfp_mask(inode-\u003ei_mapping), NULL, NULL);\n--\nmm/shmem.c=2904=static vm_fault_t shmem_fault(struct vm_fault *vmf)\n--\nmm/shmem.c-2922-\tWARN_ON_ONCE(vmf-\u003epage != NULL);\nmm/shmem.c:2923:\terr = shmem_get_folio_gfp(inode, vmf-\u003epgoff, 0, \u0026folio, SGP_CACHE,\nmm/shmem.c-2924-\t\t\t\t  gfp, vmf, \u0026ret);\n--\nmm/shmem.c=6161=struct folio *shmem_read_folio_gfp(struct address_space *mapping,\n--\nmm/shmem.c-6168-\nmm/shmem.c:6169:\terror = shmem_get_folio_gfp(inode, index, i_size_read(inode),\nmm/shmem.c-6170-\t\t\t\t    \u0026folio, SGP_CACHE, gfp, NULL, NULL);\n"
}

7/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 12802
							output: 21
							thoughts: 26
						

Thoughts:
Here's my summary, as though I'm thinking these thoughts:

**Considering the Scope of Shared Memory Operations**

Okay, so I'm looking at the `shmem` code, and I see `shmem_get_folio` isn't declared `static`. That immediately piques my interest. It implies it's potentially exposed outside of the core `shmem` module. I need to understand *why* this design decision was made. Is it intended for other parts of the kernel to directly interact with `folio` retrieval in the shared memory context? If so, what are the implications in terms of locking, concurrency, and error handling? I need to track down all the call sites to be sure.

Then, my mind jumps to another function, the one dealing with eviction: `shmem_evict_inode`. Is *that* also non-static? If it is, what's the rationale there? It's related, of course, because eviction is intrinsically tied to freeing up memory. If both are non-static, it strongly suggests a broader architecture, and I need to figure out the intended interactions between these core `shmem` functions and other kernel components. I need to evaluate the design with performance and security in mind. I need to know why and *how* these functions are expected to be used outside the `shmem` context. There's a deeper design principle at play here, and I'm keen to understand it fully.



8/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_evict_inode"
}

Results:
{
  "Output": "mm/shmem.c=1537=static int shmem_setattr(struct mnt_idmap *idmap,\n--\nmm/shmem.c-1617-\nmm/shmem.c:1618:static void shmem_evict_inode(struct inode *inode)\nmm/shmem.c-1619-{\n--\nmm/shmem.c=1757=int shmem_unuse(unsigned int type)\n--\nmm/shmem.c-1773-\t\t * Drop the swaplist mutex while searching the inode for swap;\nmm/shmem.c:1774:\t\t * but before doing so, make sure shmem_evict_inode() will not\nmm/shmem.c-1775-\t\t * remove placeholder inode from swaplist, nor let it be freed\n--\nmm/shmem.c=2350=static void shmem_set_folio_swapin_error(struct inode *inode, pgoff_t index,\n--\nmm/shmem.c-2371-\t * won't be 0 when inode is released and thus trigger WARN_ON(i_blocks)\nmm/shmem.c:2372:\t * in shmem_evict_inode().\nmm/shmem.c-2373-\t */\n--\nmm/shmem.c=5441=static const struct super_operations shmem_ops = {\n--\nmm/shmem.c-5451-#endif\nmm/shmem.c:5452:\t.evict_inode\t= shmem_evict_inode,\nmm/shmem.c-5453-\t.drop_inode\t= inode_just_drop,\n"
}

9/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13587
							output: 22
							thoughts: 27
						

Thoughts:
Here's a summary of my immediate thought process:

**Internal Code Audit - Static vs. Dynamic Allocation**

Okay, I'm digging into this code and immediately see that `shmem_evict_inode` is defined as `static`. That's the first thing that jumps out at me. Now, the context is what matters, so I need to understand why this is static. Is this a deliberate design choice for scoping, or is there a potential for future problems because of this?

My next step is to quickly check the `zswap_enabled_param_set` function. I want to see how that function interacts with the general memory management scheme to see if I can understand more of this specific context. Understanding the connection will give me a better understanding of the wider architecture, and allow me to determine if the `static` declaration is benign or potentially limiting.



10/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "zswap_enabled_param_set"
}

Results:
{
  "Output": "mm/zswap.c=90=static bool zswap_enabled = IS_ENABLED(CONFIG_ZSWAP_DEFAULT_ON);\nmm/zswap.c:91:static int zswap_enabled_param_set(const char *,\nmm/zswap.c-92-\t\t\t\t   const struct kernel_param *);\nmm/zswap.c=93=static const struct kernel_param_ops zswap_enabled_param_ops = {\nmm/zswap.c:94:\t.set =\t\tzswap_enabled_param_set,\nmm/zswap.c-95-\t.get =\t\tparam_get_bool,\n--\nmm/zswap.c=528=static int zswap_compressor_param_set(const char *val, const struct kernel_param *kp)\n--\nmm/zswap.c-616-\nmm/zswap.c:617:static int zswap_enabled_param_set(const char *val,\nmm/zswap.c-618-\t\t\t\t   const struct kernel_param *kp)\n"
}

11/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 14085
							output: 20
							thoughts: 58
						

Thoughts:
Okay, let's see...

**Analyzing Potential Memory Management Bottlenecks**

Hold on a second, that `zswap_enabled_param_set` variable is declared as `static`. Right, that explains its scoping. Okay, moving on... What about `obj_cgroup_memcg`? Ah, that's an inline function, isn't it? It's defined right in `include/linux/memcontrol.h`. I need to understand how *that* factors in. Let's see... I think a good next step would be to trace the execution path and look at `shmem_get_folio`, to see how all these pieces fit together from that perspective.



12/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_get_folio"
}

Results:
{
  "Output": "fs/xfs/scrub/xfile.c=108=xfile_load(\n--\nfs/xfs/scrub/xfile.c-129-\nfs/xfs/scrub/xfile.c:130:\t\tif (shmem_get_folio(inode, pos \u003e\u003e PAGE_SHIFT, 0, \u0026folio,\nfs/xfs/scrub/xfile.c-131-\t\t\t\tSGP_READ) \u003c 0)\n--\nfs/xfs/scrub/xfile.c=171=xfile_store(\n--\nfs/xfs/scrub/xfile.c-187-\t/*\nfs/xfs/scrub/xfile.c:188:\t * Increase the file size first so that shmem_get_folio(..., SGP_CACHE),\nfs/xfs/scrub/xfile.c-189-\t * actually allocates a folio instead of erroring out.\n--\nfs/xfs/scrub/xfile.c-199-\nfs/xfs/scrub/xfile.c:200:\t\tif (shmem_get_folio(inode, pos \u003e\u003e PAGE_SHIFT, 0, \u0026folio,\nfs/xfs/scrub/xfile.c-201-\t\t\t\tSGP_CACHE) \u003c 0)\n--\nfs/xfs/scrub/xfile.c=247=xfile_get_folio(\n--\nfs/xfs/scrub/xfile.c-263-\t/*\nfs/xfs/scrub/xfile.c:264:\t * Increase the file size first so that shmem_get_folio(..., SGP_CACHE),\nfs/xfs/scrub/xfile.c-265-\t * actually allocates a folio instead of erroring out.\n--\nfs/xfs/scrub/xfile.c-270-\tpflags = memalloc_nofs_save();\nfs/xfs/scrub/xfile.c:271:\terror = shmem_get_folio(inode, pos \u003e\u003e PAGE_SHIFT, 0, \u0026folio,\nfs/xfs/scrub/xfile.c-272-\t\t\t(flags \u0026 XFILE_ALLOC) ? SGP_CACHE : SGP_READ);\n--\nfs/xfs/xfs_buf_mem.c=125=xmbuf_map_backing_mem(\n--\nfs/xfs/xfs_buf_mem.c-143-\nfs/xfs/xfs_buf_mem.c:144:\terror = shmem_get_folio(inode, pos \u003e\u003e PAGE_SHIFT, 0, \u0026folio, SGP_CACHE);\nfs/xfs/xfs_buf_mem.c-145-\tif (error)\n--\ninclude/linux/shmem_fs.h=166=extern unsigned long shmem_partial_swap_usage(struct address_space *mapping,\n--\ninclude/linux/shmem_fs.h-168-\ninclude/linux/shmem_fs.h:169:/* Flag allocation requirements to shmem_get_folio */\ninclude/linux/shmem_fs.h-170-enum sgp_type {\n--\ninclude/linux/shmem_fs.h-177-\ninclude/linux/shmem_fs.h:178:int shmem_get_folio(struct inode *inode, pgoff_t index, loff_t write_end,\ninclude/linux/shmem_fs.h-179-\t\tstruct folio **foliop, enum sgp_type sgp);\n--\nmm/khugepaged.c=2254=static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr,\n--\nmm/khugepaged.c-2329-\t\t\t\t/* swap in or instantiate fallocated page */\nmm/khugepaged.c:2330:\t\t\t\tif (shmem_get_folio(mapping-\u003ehost, index, 0,\nmm/khugepaged.c-2331-\t\t\t\t\t\t\u0026folio, SGP_NOALLOC)) {\n--\nmm/shmem.c=188=static inline int shmem_reacct_size(unsigned long flags,\n--\nmm/shmem.c-203- * pages are allocated, in order to allow large sparse files.\nmm/shmem.c:204: * shmem_get_folio reports shmem_acct_blocks failure as -ENOSPC not -ENOMEM,\nmm/shmem.c-205- * so that a failure on a sparse tmpfs mapping will give SIGBUS not OOM.\n--\nmm/shmem.c=1296=static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index)\n--\nmm/shmem.c-1300-\t/*\nmm/shmem.c:1301:\t * At first avoid shmem_get_folio(,,,SGP_READ): that fails\nmm/shmem.c-1302-\t * beyond i_size, and reports fallocated folios as holes.\n--\nmm/shmem.c-1319-\tfolio = NULL;\nmm/shmem.c:1320:\tshmem_get_folio(inode, index, 0, \u0026folio, SGP_READ);\nmm/shmem.c-1321-\treturn folio;\n--\nmm/shmem.c=2244=static struct folio *shmem_swap_alloc_folio(struct inode *inode,\n--\nmm/shmem.c-2274- * When a page is moved from swapcache to shmem filecache (either by the\nmm/shmem.c:2275: * usual swapin of shmem_get_folio_gfp(), or by the less common swapoff of\nmm/shmem.c-2276- * shmem_unuse_inode()), it may have been read in earlier from swap, in\n--\nmm/shmem.c=2455=static int shmem_swapin_folio(struct inode *inode, pgoff_t index,\n--\nmm/shmem.c-2620-/*\nmm/shmem.c:2621: * shmem_get_folio_gfp - find page in cache, or get from swap, or allocate\nmm/shmem.c-2622- *\n--\nmm/shmem.c-2628- */\nmm/shmem.c:2629:static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,\nmm/shmem.c-2630-\t\tloff_t write_end, struct folio **foliop, enum sgp_type sgp,\n--\nmm/shmem.c-2801-/**\nmm/shmem.c:2802: * shmem_get_folio - find, and lock a shmem folio.\nmm/shmem.c-2803- * @inode:\tinode to search\n--\nmm/shmem.c-2824- */\nmm/shmem.c:2825:int shmem_get_folio(struct inode *inode, pgoff_t index, loff_t write_end,\nmm/shmem.c-2826-\t\t    struct folio **foliop, enum sgp_type sgp)\nmm/shmem.c-2827-{\nmm/shmem.c:2828:\treturn shmem_get_folio_gfp(inode, index, write_end, foliop, sgp,\nmm/shmem.c-2829-\t\t\tmapping_gfp_mask(inode-\u003ei_mapping), NULL, NULL);\nmm/shmem.c-2830-}\nmm/shmem.c:2831:EXPORT_SYMBOL_GPL(shmem_get_folio);\nmm/shmem.c-2832-\n--\nmm/shmem.c=2904=static vm_fault_t shmem_fault(struct vm_fault *vmf)\n--\nmm/shmem.c-2922-\tWARN_ON_ONCE(vmf-\u003epage != NULL);\nmm/shmem.c:2923:\terr = shmem_get_folio_gfp(inode, vmf-\u003epgoff, 0, \u0026folio, SGP_CACHE,\nmm/shmem.c-2924-\t\t\t\t  gfp, vmf, \u0026ret);\n--\nmm/shmem.c=3399=static void shmem_mfill_filemap_remove(struct folio *folio,\n--\nmm/shmem.c-3408-\nmm/shmem.c:3409:static struct folio *shmem_get_folio_noalloc(struct inode *inode, pgoff_t pgoff)\nmm/shmem.c-3410-{\n--\nmm/shmem.c-3413-\nmm/shmem.c:3414:\terr = shmem_get_folio(inode, pgoff, 0, \u0026folio, SGP_NOALLOC);\nmm/shmem.c-3415-\tif (err)\n--\nmm/shmem.c=3426=static const struct vm_uffd_ops shmem_uffd_ops = {\nmm/shmem.c-3427-\t.can_userfault\t\t= shmem_can_userfault,\nmm/shmem.c:3428:\t.get_folio_noalloc\t= shmem_get_folio_noalloc,\nmm/shmem.c-3429-\t.alloc_folio\t\t= shmem_mfill_folio_alloc,\n--\nmm/shmem.c=3440=shmem_write_begin(const struct kiocb *iocb, struct address_space *mapping,\n--\nmm/shmem.c-3462-\nmm/shmem.c:3463:\tret = shmem_get_folio(inode, index, pos + len, \u0026folio, SGP_WRITE);\nmm/shmem.c-3464-\tif (ret)\n--\nmm/shmem.c=3502=static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)\n--\nmm/shmem.c-3523-\t\tindex = iocb-\u003eki_pos \u003e\u003e PAGE_SHIFT;\nmm/shmem.c:3524:\t\terror = shmem_get_folio(inode, index, 0, \u0026folio, SGP_READ);\nmm/shmem.c-3525-\t\tif (error) {\n--\nmm/shmem.c=3689=static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,\n--\nmm/shmem.c-3714-\t\tindex = *ppos \u003e\u003e PAGE_SHIFT;\nmm/shmem.c:3715:\t\terror = shmem_get_folio(inode, index, 0, \u0026folio, SGP_READ);\nmm/shmem.c-3716-\t\tif (error) {\n--\nmm/shmem.c=3821=static long shmem_fallocate(struct file *file, int mode, loff_t offset,\n--\nmm/shmem.c-3933-\t\telse\nmm/shmem.c:3934:\t\t\terror = shmem_get_folio(inode, index, offset + len,\nmm/shmem.c-3935-\t\t\t\t\t\t\u0026folio, SGP_FALLOC);\n--\nmm/shmem.c=4248=static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,\n--\nmm/shmem.c-4286-\t\tinode-\u003ei_mapping-\u003ea_ops = \u0026shmem_aops;\nmm/shmem.c:4287:\t\terror = shmem_get_folio(inode, 0, 0, \u0026folio, SGP_WRITE);\nmm/shmem.c-4288-\t\tif (error)\n--\nmm/shmem.c=4317=static const char *shmem_get_link(struct dentry *dentry, struct inode *inode,\n--\nmm/shmem.c-4332-\t} else {\nmm/shmem.c:4333:\t\terror = shmem_get_folio(inode, 0, 0, \u0026folio, SGP_READ);\nmm/shmem.c-4334-\t\tif (error)\n--\nmm/shmem.c=6161=struct folio *shmem_read_folio_gfp(struct address_space *mapping,\n--\nmm/shmem.c-6168-\nmm/shmem.c:6169:\terror = shmem_get_folio_gfp(inode, index, i_size_read(inode),\nmm/shmem.c-6170-\t\t\t\t    \u0026folio, SGP_CACHE, gfp, NULL, NULL);\n"
}

13/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 17524
							output: 19
							thoughts: 147
						

Thoughts:
**Analyzing the Huge Page Eviction Patch**

Okay, so this patch is clearly digging into how we handle huge pages within shared memory, specifically around the eviction process. My immediate thought is to trace the changes. It looks like `shmem_get_folio_gfp` is now using `shmem_unused_huge_add`, which means something's changing in the way we allocate unused huge pages. Then, on the other end, `shmem_evict_inode` is linked to `shmem_unused_huge_del`. That makes sense - we're adding huge pages when we acquire them and deleting them during eviction.

The core of the matter seems to be around `shmem_unused_huge_shrink`, which gets called by `shmem_unused_huge_scan`. And aha, `shmem_unused_huge_scan` is itself triggered via `sb->s_op->free_cached_objects`, which in turn is called by `super_cache_scan`. This chain points to a mechanism for periodically cleaning up or freeing cached objects, which is critical for preventing memory leaks and maintaining performance. My expertise tells me that `super_cache_scan` is likely part of the generic Linux slab cache management, or something similar, and is called from `shrink_slab` or related functions. Given that context, it's worth checking `super_cache_scan` to get a clearer picture of how this all fits together. I need to understand the larger context of this call chain to fully grasp the impact of these changes.



14/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "super_cache_scan"
}

Results:
{
  "Output": "fs/super.c=154=static void super_wake(struct super_block *sb, unsigned int flag)\n--\nfs/super.c-180- */\nfs/super.c:181:static unsigned long super_cache_scan(struct shrinker *shrink,\nfs/super.c-182-\t\t\t\t      struct shrink_control *sc)\n--\nfs/super.c=238=static unsigned long super_cache_count(struct shrinker *shrink,\n--\nfs/super.c-250-\t * list_lru_shrink_count() or s_op-\u003enr_cached_objects(). Counts can\nfs/super.c:251:\t * change between super_cache_count and super_cache_scan, so we really\nfs/super.c-252-\t * don't need locks here.\n--\nfs/super.c=323=static struct super_block *alloc_super(struct file_system_type *type, int flags,\n--\nfs/super.c-391-\nfs/super.c:392:\ts-\u003es_shrink-\u003escan_objects = super_cache_scan;\nfs/super.c-393-\ts-\u003es_shrink-\u003ecount_objects = super_cache_count;\n"
}

15/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 18335
							output: 22
							thoughts: 134
						

Thoughts:
**My Analysis of `super_cache_scan` in the Shmem Filesystem**

Okay, so `super_cache_scan` is a shrinker callback, that much is clear. It's registered for the super block, which makes perfect sense in the context of memory management. When the system's under memory pressure, this callback gets triggered. Then, `super_cache_scan` dives into `sb->s_op->free_cached_objects`, and for `shmem`, that resolves to `shmem_unused_huge_scan`. So, it's definitely in the execution path, functionally reachable. We know it's there and can work, that's good.

Now, let's look for configuration dependencies. The implementation of `shmem_unused_huge_shrink` in `mm/shmem.c` is guarded by an `#ifdef CONFIG_TRANSPARENT_HUGEPAGE`. That's the key. I need to verify that this configuration option is enabled for this code to be actively utilized. That's the next step; I have to check this configuration to ensure `shmem_unused_huge_scan` is actually available in the current kernel build.



16/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_unused_huge_shrink"
}

Results:
{
  "Output": "mm/shmem.c=931=static void shmem_unused_huge_requeue(struct inode *inode, struct folio *folio)\n--\nmm/shmem.c-952-\nmm/shmem.c:953:static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\nmm/shmem.c-954-\t\tstruct shrink_control *sc, unsigned long nr_to_free)\n--\nmm/shmem.c=1043=static long shmem_unused_huge_scan(struct super_block *sb,\n--\nmm/shmem.c-1050-\nmm/shmem.c:1051:\treturn shmem_unused_huge_shrink(sbinfo, sc, 0);\nmm/shmem.c-1052-}\n--\nmm/shmem.c=1070=static void shmem_unused_huge_del(struct inode *inode)\n--\nmm/shmem.c-1073-\nmm/shmem.c:1074:static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\nmm/shmem.c-1075-\t\tstruct shrink_control *sc, unsigned long nr_to_free)\n--\nmm/shmem.c=2140=static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf,\n--\nmm/shmem.c-2213-\t\t */\nmm/shmem.c:2214:\t\tshmem_unused_huge_shrink(sbinfo, NULL, pages);\nmm/shmem.c-2215-\t\t/*\n"
}

17/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 19173
							output: 35
							thoughts: 47
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the `shmem_unused_huge_shrink` Definition**

Alright, so I'm seeing that `shmem_unused_huge_shrink` is defined *twice*. That's a bit unusual and immediately raises a flag. We've got one definition tied to `CONFIG_TRANSPARENT_HUGEPAGE`, which is the expected behavior, but then there's a second one acting as a dummy. My initial reaction is to dig into that dummy implementation. I need to understand why it's there. Is it simply a placeholder for when THP isn't enabled, or is there a more nuanced reason? Are there potential implications in the code paths that *use* `shmem_unused_huge_shrink` that are now going to be influenced by the dummy version in place when THP is not configured? Are there any potential subtle performance implications when comparing the THP vs no THP code paths? I need to be sure that the "dummy" isn't introducing a latent issue or causing unexpected behavior in the shared memory management, especially in low-memory situations. Understanding this dummy's purpose is crucial to ensuring consistency and correctness across different kernel configurations.



18/2 2026/08/17 10:14 tool read-file
0m Args:
{
  "File": "mm/shmem.c",
  "FirstLine": 1050,
  "LineCount": 50
}

Results:
{
  "Contents": "1050:\t\n1051:\t\treturn shmem_unused_huge_shrink(sbinfo, sc, 0);\n1052:\t}\n1053:\t\n1054:\tstatic long shmem_unused_huge_count(struct super_block *sb,\n1055:\t\t\tstruct shrink_control *sc)\n1056:\t{\n1057:\t\tstruct shmem_sb_info *sbinfo = SHMEM_SB(sb);\n1058:\t\n1059:\t\treturn list_lru_shrink_count(\u0026sbinfo-\u003eshrinklist, sc);\n1060:\t}\n1061:\t#else /* !CONFIG_TRANSPARENT_HUGEPAGE */\n1062:\t\n1063:\t#define shmem_huge SHMEM_HUGE_DENY\n1064:\t\n1065:\tstatic void shmem_unused_huge_add(struct inode *inode, struct folio *folio,\n1066:\t\t\t\t\t  gfp_t gfp)\n1067:\t{\n1068:\t}\n1069:\t\n1070:\tstatic void shmem_unused_huge_del(struct inode *inode)\n1071:\t{\n1072:\t}\n1073:\t\n1074:\tstatic unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,\n1075:\t\t\tstruct shrink_control *sc, unsigned long nr_to_free)\n1076:\t{\n1077:\t\treturn 0;\n1078:\t}\n1079:\t\n1080:\tstatic unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index,\n1081:\t\t\t\t\t\t      loff_t write_end, bool shmem_huge_force,\n1082:\t\t\t\t\t\t      struct vm_area_struct *vma,\n1083:\t\t\t\t\t\t      vm_flags_t vm_flags)\n1084:\t{\n1085:\t\treturn 0;\n1086:\t}\n1087:\t#endif /* CONFIG_TRANSPARENT_HUGEPAGE */\n1088:\t\n1089:\tstatic void shmem_update_stats(struct folio *folio, int nr_pages)\n1090:\t{\n1091:\t\tif (folio_test_pmd_mappable(folio))\n1092:\t\t\tlruvec_stat_mod_folio(folio, NR_SHMEM_THPS, nr_pages);\n1093:\t\tlruvec_stat_mod_folio(folio, NR_FILE_PAGES, nr_pages);\n1094:\t\tlruvec_stat_mod_folio(folio, NR_SHMEM, nr_pages);\n1095:\t}\n1096:\t\n1097:\t/*\n1098:\t * Somewhat like filemap_add_folio, but error if expected item has gone.\n1099:\t */\n"
}

19/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 20291
							output: 25
							thoughts: 93
						

Thoughts:
Okay, here's my take on those thoughts, framed as my own mental processing:

**Analyzing Kernel Configuration Requirements**

Alright, the first thing that jumps out is the absolute necessity of `CONFIG_TRANSPARENT_HUGEPAGE`. No question about it. It's a key requirement. Beyond that, it's evident that `CONFIG_MEMCG` is intertwined with this patch. The modifications to `obj_cgroup_memcg` clearly point in that direction, and the existence of a `CONFIG_MEMCG`-specific implementation in `shmem_unused_huge_alloc_lru` solidifies this connection. Given that this is a memory management-related change, digging into `shmem_unused_huge_alloc_lru` within `mm/shmem.c` seems like the next logical step. I need to understand its function and how it interfaces with memory cgroups.



20/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem_unused_huge_alloc_lru"
}

Results:
{
  "Output": "mm/shmem.c=749=static struct obj_cgroup *\nmm/shmem.c:750:shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\nmm/shmem.c-751-\t\t\t    gfp_t gfp)\n--\nmm/shmem.c=762=static struct obj_cgroup *\nmm/shmem.c:763:shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\nmm/shmem.c-764-\t\t\t    gfp_t gfp)\n--\nmm/shmem.c=794=static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,\n--\nmm/shmem.c-801-\nmm/shmem.c:802:\tobjcg = shmem_unused_huge_alloc_lru(sbinfo, folio, gfp);\nmm/shmem.c-803-\tif (IS_ERR(objcg))\n--\nmm/shmem.c=931=static void shmem_unused_huge_requeue(struct inode *inode, struct folio *folio)\n--\nmm/shmem.c-937-\nmm/shmem.c:938:\tobjcg = shmem_unused_huge_alloc_lru(sbinfo, folio, GFP_NOWAIT);\nmm/shmem.c-939-\tif (IS_ERR(objcg)) {\n"
}

21/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 20993
							output: 34
							thoughts: 22
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert in the field:

**Examining the Preprocessor Directive**

Alright, time to dig into this. My initial thought is to zero in on that `#ifdef` statement surrounding `shmem_unused_huge_alloc_lru`. The fact that it's behind a preprocessor directive immediately signals that its inclusion or exclusion is conditional, likely tied to some build-time configuration or a feature flag. I need to figure out *why* it's conditionally compiled. Is this a performance optimization that's only enabled under specific circumstances? Perhaps it's a feature that's only relevant for a particular hardware configuration, a specific kernel version, or a certain memory management setup? The goal is to understand the context. Are we handling different configurations? What are they?

I need to quickly ascertain the controlling macro. What condition makes it true or false? Knowing that will clarify *why* this part of the code is potentially enabled or disabled. Knowing the `#ifdef` condition is essential to assessing the overall design and intended behavior. I need to understand whether this is a minor tweak or a significant architectural choice that affects how huge pages are allocated. With this knowledge I can further investigate the code and see what effects it has on the system.



22/2 2026/08/17 10:14 tool read-file
0m Args:
{
  "File": "mm/shmem.c",
  "FirstLine": 740,
  "LineCount": 30
}

Results:
{
  "Contents": " 740:\t{\n 741:\t\tstruct obj_cgroup *objcg = info-\u003eshrinklist_objcg;\n 742:\t\n 743:\t\tinfo-\u003eshrinklist_objcg = NULL;\n 744:\t\n 745:\t\treturn objcg;\n 746:\t}\n 747:\t\n 748:\t#ifdef CONFIG_MEMCG\n 749:\tstatic struct obj_cgroup *\n 750:\tshmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\n 751:\t\t\t\t    gfp_t gfp)\n 752:\t{\n 753:\t\tint ret;\n 754:\t\n 755:\t\tret = folio_memcg_list_lru_alloc(folio, \u0026sbinfo-\u003eshrinklist, gfp);\n 756:\t\tif (ret)\n 757:\t\t\treturn ERR_PTR(ret);\n 758:\t\n 759:\t\treturn get_obj_cgroup_from_folio(folio);\n 760:\t}\n 761:\t#else\n 762:\tstatic struct obj_cgroup *\n 763:\tshmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,\n 764:\t\t\t\t    gfp_t gfp)\n 765:\t{\n 766:\t\treturn NULL;\n 767:\t}\n 768:\t#endif\n 769:\t\n"
}

23/2 2026/08/17 10:14 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 21731
							output: 18
							thoughts: 77
						

Thoughts:
**Investigating Shared Memory and Control Groups**

Okay, so I'm digging into this code, and the memory control group configuration, `CONFIG_MEMCG`, definitely seems like a key factor here. I need to understand its relationship with shared memory. My next thought is to see if `CONFIG_SHMEM` is a requirement. I'll take a look at `mm/shmem.c` to confirm this, as that file should only be compiled when `CONFIG_SHMEM` is enabled. Ah, right, I need to be careful here, because `CONFIG_SHMEM` is usually enabled by default, isn't it? Let me confirm that by quickly checking the `mm/Makefile` to confirm where `shmem.c` is included.



24/2 2026/08/17 10:14 tool grepper
0m Args:
{
  "Expression": "shmem.o"
}

Results:
{
  "Output": "\nFull output is too long, showing 500 out of 1584 lines.\nUse more precise expression if possible.\n\nDocumentation/filesystems/proc.rst=559=For shmem mappings, \"Swap\" includes also the size of the mapped (and not\nDocumentation/filesystems/proc.rst:560:replaced by copy-on-write) part of the underlying shmem object out on swap.\nDocumentation/filesystems/proc.rst-561-\"SwapPss\" shows proportional swap share of this mapping. Unlike \"Swap\", this\nDocumentation/filesystems/proc.rst:562:does not take into account swapped out page of underlying shmem objects.\nDocumentation/filesystems/proc.rst-563-\"Locked\" indicates whether the mapping is locked in memory or not.\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=704=static int amdxdna_gem_obj_vmap(struct drm_gem_object *obj, struct iosys_map *map)\n--\ndrivers/accel/amdxdna/amdxdna_gem.c-715-\telse\ndrivers/accel/amdxdna/amdxdna_gem.c:716:\t\tret = drm_gem_shmem_object_vmap(obj, map);\ndrivers/accel/amdxdna/amdxdna_gem.c-717-\tif (ret)\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=725=static void amdxdna_gem_obj_vunmap(struct drm_gem_object *obj, struct iosys_map *map)\n--\ndrivers/accel/amdxdna/amdxdna_gem.c-733-\telse\ndrivers/accel/amdxdna/amdxdna_gem.c:734:\t\tdrm_gem_shmem_object_vunmap(obj, map);\ndrivers/accel/amdxdna/amdxdna_gem.c-735-}\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=772=static const struct drm_gem_object_funcs amdxdna_gem_shmem_funcs = {\n--\ndrivers/accel/amdxdna/amdxdna_gem.c-775-\t.close = amdxdna_gem_obj_close,\ndrivers/accel/amdxdna/amdxdna_gem.c:776:\t.print_info = drm_gem_shmem_object_print_info,\ndrivers/accel/amdxdna/amdxdna_gem.c:777:\t.pin = drm_gem_shmem_object_pin,\ndrivers/accel/amdxdna/amdxdna_gem.c:778:\t.unpin = drm_gem_shmem_object_unpin,\ndrivers/accel/amdxdna/amdxdna_gem.c:779:\t.get_sg_table = drm_gem_shmem_object_get_sg_table,\ndrivers/accel/amdxdna/amdxdna_gem.c-780-\t.vmap = amdxdna_gem_obj_vmap,\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=788=struct drm_gem_object *\ndrivers/accel/amdxdna/amdxdna_gem.c:789:amdxdna_gem_create_shmem_object_cb(struct drm_device *dev, size_t size)\ndrivers/accel/amdxdna/amdxdna_gem.c-790-{\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=802=static struct amdxdna_gem_obj *\ndrivers/accel/amdxdna/amdxdna_gem.c:803:amdxdna_gem_create_shmem_object(struct drm_device *dev, struct amdxdna_drm_create_bo *args)\ndrivers/accel/amdxdna/amdxdna_gem.c-804-{\ndrivers/accel/amdxdna/amdxdna_gem.c-805-\tsize_t size = args-\u003esize;\ndrivers/accel/amdxdna/amdxdna_gem.c:806:\tstruct drm_gem_shmem_object *shmem = drm_gem_shmem_create(dev, size);\ndrivers/accel/amdxdna/amdxdna_gem.c-807-\n--\ndrivers/accel/amdxdna/amdxdna_gem.c=931=amdxdna_drm_create_share_bo(struct drm_device *dev,\n--\ndrivers/accel/amdxdna/amdxdna_gem.c-940-\telse\ndrivers/accel/amdxdna/amdxdna_gem.c:941:\t\tabo = amdxdna_gem_create_shmem_object(dev, args);\ndrivers/accel/amdxdna/amdxdna_gem.c-942-\tif (IS_ERR(abo))\n--\ndrivers/accel/amdxdna/amdxdna_gem.h=38=struct amdxdna_gem_obj {\ndrivers/accel/amdxdna/amdxdna_gem.h:39:\tstruct drm_gem_shmem_object\tbase;\ndrivers/accel/amdxdna/amdxdna_gem.h-40-\tstruct amdxdna_client\t\t*client;\n--\ndrivers/accel/amdxdna/amdxdna_gem.h=108=struct drm_gem_object *\ndrivers/accel/amdxdna/amdxdna_gem.h:109:amdxdna_gem_create_shmem_object_cb(struct drm_device *dev, size_t size);\ndrivers/accel/amdxdna/amdxdna_gem.h-110-struct drm_gem_object *\n--\ndrivers/accel/amdxdna/amdxdna_pci_drv.c=329=const struct drm_driver amdxdna_drm_drv = {\n--\ndrivers/accel/amdxdna/amdxdna_pci_drv.c-341-\t.show_fdinfo = amdxdna_show_fdinfo,\ndrivers/accel/amdxdna/amdxdna_pci_drv.c:342:\t.gem_create_object = amdxdna_gem_create_shmem_object_cb,\ndrivers/accel/amdxdna/amdxdna_pci_drv.c-343-\t.gem_prime_import = amdxdna_gem_prime_import,\n--\ndrivers/accel/ethosu/ethosu_gem.h=19=struct ethosu_gem_object {\ndrivers/accel/ethosu/ethosu_gem.h:20:\t/** @base: Inherit from drm_gem_shmem_object. */\ndrivers/accel/ethosu/ethosu_gem.h-21-\tstruct drm_gem_dma_object base;\n--\ndrivers/accel/ivpu/ivpu_gem.c=252=static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 flags)\ndrivers/accel/ivpu/ivpu_gem.c-253-{\ndrivers/accel/ivpu/ivpu_gem.c:254:\tstruct drm_gem_shmem_object *shmem;\ndrivers/accel/ivpu/ivpu_gem.c-255-\tstruct ivpu_bo *bo;\n--\ndrivers/accel/ivpu/ivpu_gem.c=347=static const struct drm_gem_object_funcs ivpu_gem_funcs = {\n--\ndrivers/accel/ivpu/ivpu_gem.c-349-\t.open = ivpu_gem_bo_open,\ndrivers/accel/ivpu/ivpu_gem.c:350:\t.print_info = drm_gem_shmem_object_print_info,\ndrivers/accel/ivpu/ivpu_gem.c:351:\t.pin = drm_gem_shmem_object_pin,\ndrivers/accel/ivpu/ivpu_gem.c:352:\t.unpin = drm_gem_shmem_object_unpin,\ndrivers/accel/ivpu/ivpu_gem.c:353:\t.get_sg_table = drm_gem_shmem_object_get_sg_table,\ndrivers/accel/ivpu/ivpu_gem.c:354:\t.vmap = drm_gem_shmem_object_vmap,\ndrivers/accel/ivpu/ivpu_gem.c:355:\t.vunmap = drm_gem_shmem_object_vunmap,\ndrivers/accel/ivpu/ivpu_gem.c:356:\t.mmap = drm_gem_shmem_object_mmap,\ndrivers/accel/ivpu/ivpu_gem.c-357-\t.status = ivpu_gem_status,\n--\ndrivers/accel/ivpu/ivpu_gem.h=14=struct ivpu_bo {\ndrivers/accel/ivpu/ivpu_gem.h:15:\tstruct drm_gem_shmem_object base;\ndrivers/accel/ivpu/ivpu_gem.h-16-\tstruct ivpu_mmu_context *ctx;\n--\ndrivers/accel/rocket/rocket_gem.c=35=static const struct drm_gem_object_funcs rocket_gem_funcs = {\ndrivers/accel/rocket/rocket_gem.c-36-\t.free = rocket_gem_bo_free,\ndrivers/accel/rocket/rocket_gem.c:37:\t.print_info = drm_gem_shmem_object_print_info,\ndrivers/accel/rocket/rocket_gem.c:38:\t.pin = drm_gem_shmem_object_pin,\ndrivers/accel/rocket/rocket_gem.c:39:\t.unpin = drm_gem_shmem_object_unpin,\ndrivers/accel/rocket/rocket_gem.c:40:\t.get_sg_table = drm_gem_shmem_object_get_sg_table,\ndrivers/accel/rocket/rocket_gem.c:41:\t.vmap = drm_gem_shmem_object_vmap,\ndrivers/accel/rocket/rocket_gem.c:42:\t.vunmap = drm_gem_shmem_object_vunmap,\ndrivers/accel/rocket/rocket_gem.c:43:\t.mmap = drm_gem_shmem_object_mmap,\ndrivers/accel/rocket/rocket_gem.c-44-\t.vm_ops = \u0026drm_gem_shmem_vm_ops,\n--\ndrivers/accel/rocket/rocket_gem.c=60=int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *file)\n--\ndrivers/accel/rocket/rocket_gem.c-63-\tstruct drm_rocket_create_bo *args = data;\ndrivers/accel/rocket/rocket_gem.c:64:\tstruct drm_gem_shmem_object *shmem_obj;\ndrivers/accel/rocket/rocket_gem.c-65-\tstruct rocket_gem_object *rkt_obj;\n--\ndrivers/accel/rocket/rocket_gem.c-69-\ndrivers/accel/rocket/rocket_gem.c:70:\tshmem_obj = drm_gem_shmem_create(dev, args-\u003esize);\ndrivers/accel/rocket/rocket_gem.c:71:\tif (IS_ERR(shmem_obj))\ndrivers/accel/rocket/rocket_gem.c:72:\t\treturn PTR_ERR(shmem_obj);\ndrivers/accel/rocket/rocket_gem.c-73-\ndrivers/accel/rocket/rocket_gem.c:74:\tgem_obj = \u0026shmem_obj-\u003ebase;\ndrivers/accel/rocket/rocket_gem.c-75-\trkt_obj = to_rocket_bo(gem_obj);\n--\ndrivers/accel/rocket/rocket_gem.c-81-\ndrivers/accel/rocket/rocket_gem.c:82:\tsgt = drm_gem_shmem_get_pages_sgt(shmem_obj);\ndrivers/accel/rocket/rocket_gem.c-83-\tif (IS_ERR(sgt)) {\n--\ndrivers/accel/rocket/rocket_gem.c-97-\t\t\t\trkt_obj-\u003emm.start,\ndrivers/accel/rocket/rocket_gem.c:98:\t\t\t\tshmem_obj-\u003esgt,\ndrivers/accel/rocket/rocket_gem.c-99-\t\t\t\tIOMMU_READ | IOMMU_WRITE);\n--\ndrivers/accel/rocket/rocket_gem.c-129-err:\ndrivers/accel/rocket/rocket_gem.c:130:\tdrm_gem_shmem_object_free(gem_obj);\ndrivers/accel/rocket/rocket_gem.c-131-\n--\ndrivers/accel/rocket/rocket_gem.c=135=int rocket_ioctl_prep_bo(struct drm_device *dev, void *data, struct drm_file *file)\n--\ndrivers/accel/rocket/rocket_gem.c-139-\tstruct drm_gem_object *gem_obj;\ndrivers/accel/rocket/rocket_gem.c:140:\tstruct drm_gem_shmem_object *shmem_obj;\ndrivers/accel/rocket/rocket_gem.c-141-\tlong ret = 0;\n--\ndrivers/accel/rocket/rocket_gem.c-157-\ndrivers/accel/rocket/rocket_gem.c:158:\tshmem_obj = \u0026to_rocket_bo(gem_obj)-\u003ebase;\ndrivers/accel/rocket/rocket_gem.c-159-\ndrivers/accel/rocket/rocket_gem.c:160:\tdma_sync_sgtable_for_cpu(dev-\u003edev, shmem_obj-\u003esgt, DMA_BIDIRECTIONAL);\ndrivers/accel/rocket/rocket_gem.c-161-\n--\ndrivers/accel/rocket/rocket_gem.c=167=int rocket_ioctl_fini_bo(struct drm_device *dev, void *data, struct drm_file *file)\n--\ndrivers/accel/rocket/rocket_gem.c-169-\tstruct drm_rocket_fini_bo *args = data;\ndrivers/accel/rocket/rocket_gem.c:170:\tstruct drm_gem_shmem_object *shmem_obj;\ndrivers/accel/rocket/rocket_gem.c-171-\tstruct rocket_gem_object *rkt_obj;\n--\ndrivers/accel/rocket/rocket_gem.c-183-\trkt_obj = to_rocket_bo(gem_obj);\ndrivers/accel/rocket/rocket_gem.c:184:\tshmem_obj = \u0026rkt_obj-\u003ebase;\ndrivers/accel/rocket/rocket_gem.c-185-\ndrivers/accel/rocket/rocket_gem.c:186:\tdma_sync_sgtable_for_device(dev-\u003edev, shmem_obj-\u003esgt, DMA_BIDIRECTIONAL);\ndrivers/accel/rocket/rocket_gem.c-187-\n--\ndrivers/accel/rocket/rocket_gem.h=9=struct rocket_gem_object {\ndrivers/accel/rocket/rocket_gem.h:10:\tstruct drm_gem_shmem_object base;\ndrivers/accel/rocket/rocket_gem.h-11-\n--\ndrivers/accel/rocket/rocket_gem.h=29=struct  rocket_gem_object *to_rocket_bo(struct drm_gem_object *obj)\ndrivers/accel/rocket/rocket_gem.h-30-{\ndrivers/accel/rocket/rocket_gem.h:31:\treturn container_of(to_drm_gem_shmem_obj(obj), struct rocket_gem_object, base);\ndrivers/accel/rocket/rocket_gem.h-32-}\n--\ndrivers/base/devtmpfs.c=76=static int devtmpfs_get_tree(struct fs_context *fc)\n--\ndrivers/base/devtmpfs.c-85-\ndrivers/base/devtmpfs.c:86:/* Ops are filled in during init depending on underlying shmem or ramfs type */\ndrivers/base/devtmpfs.c-87-static struct fs_context_operations devtmpfs_context_ops = {};\n--\ndrivers/char/mem.c=525=static unsigned long get_unmapped_area_zero(struct file *file,\n--\ndrivers/char/mem.c-540-\t/*\ndrivers/char/mem.c:541:\t * Otherwise flags \u0026 MAP_PRIVATE: with no shmem object beneath it,\ndrivers/char/mem.c-542-\t * attempt to map aligned to huge page size if possible, otherwise we\n--\ndrivers/firmware/arm_scmi/Makefile=7=scmi-driver-$(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT) += raw_mode.o\ndrivers/firmware/arm_scmi/Makefile:8:scmi-transport-$(CONFIG_ARM_SCMI_HAVE_SHMEM) = shmem.o\ndrivers/firmware/arm_scmi/Makefile-9-scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o\n--\ndrivers/firmware/arm_scmi/shmem.c=194=static void __iomem *shmem_setup_iomap(struct scmi_chan_info *cinfo,\n--\ndrivers/firmware/arm_scmi/shmem.c-250-\ndrivers/firmware/arm_scmi/shmem.c:251:static const struct scmi_shared_mem_operations scmi_shmem_ops = {\ndrivers/firmware/arm_scmi/shmem.c-252-\t.tx_prepare = shmem_tx_prepare,\n--\ndrivers/firmware/arm_scmi/shmem.c=263=const struct scmi_shared_mem_operations *scmi_shared_mem_operations_get(void)\ndrivers/firmware/arm_scmi/shmem.c-264-{\ndrivers/firmware/arm_scmi/shmem.c:265:\treturn \u0026scmi_shmem_ops;\ndrivers/firmware/arm_scmi/shmem.c-266-}\n--\ndrivers/firmware/arm_scpi.c=884=static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch)\n--\ndrivers/firmware/arm_scpi.c-901-\ndrivers/firmware/arm_scpi.c:902:static const struct of_device_id shmem_of_match[] __maybe_unused = {\ndrivers/firmware/arm_scpi.c-903-\t{ .compatible = \"amlogic,meson-gxbb-scp-shmem\", },\n--\ndrivers/firmware/arm_scpi.c=910=static int scpi_probe(struct platform_device *pdev)\n--\ndrivers/firmware/arm_scpi.c-946-\ndrivers/firmware/arm_scpi.c:947:\t\tif (!of_match_node(shmem_of_match, shmem))\ndrivers/firmware/arm_scpi.c-948-\t\t\treturn -ENXIO;\n--\ndrivers/firmware/meson/meson_sm.c=32=struct meson_sm_chip {\n--\ndrivers/firmware/meson/meson_sm.c-34-\tu32 cmd_shmem_in_base;\ndrivers/firmware/meson/meson_sm.c:35:\tu32 cmd_shmem_out_base;\ndrivers/firmware/meson/meson_sm.c-36-\tstruct meson_sm_cmd cmd[];\n--\ndrivers/firmware/meson/meson_sm.c=39=static const struct meson_sm_chip gxbb_chip = {\n--\ndrivers/firmware/meson/meson_sm.c-41-\t.cmd_shmem_in_base\t= 0x82000020,\ndrivers/firmware/meson/meson_sm.c:42:\t.cmd_shmem_out_base\t= 0x82000021,\ndrivers/firmware/meson/meson_sm.c-43-\t.cmd = {\n--\ndrivers/firmware/meson/meson_sm.c=55=struct meson_sm_firmware {\n--\ndrivers/firmware/meson/meson_sm.c-57-\tvoid __iomem *sm_shmem_in_base;\ndrivers/firmware/meson/meson_sm.c:58:\tvoid __iomem *sm_shmem_out_base;\ndrivers/firmware/meson/meson_sm.c-59-};\n--\ndrivers/firmware/meson/meson_sm.c=145=int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer,\n--\ndrivers/firmware/meson/meson_sm.c-154-\ndrivers/firmware/meson/meson_sm.c:155:\tif (!fw-\u003echip-\u003ecmd_shmem_out_base)\ndrivers/firmware/meson/meson_sm.c-156-\t\treturn -EINVAL;\n--\ndrivers/firmware/meson/meson_sm.c-170-\t * SMC doesn't return the number of bytes read, even\ndrivers/firmware/meson/meson_sm.c:171:\t * though the bytes were actually read into sm_shmem_out.\ndrivers/firmware/meson/meson_sm.c-172-\t * So this check is needed.\n--\ndrivers/firmware/meson/meson_sm.c-177-\tif (buffer)\ndrivers/firmware/meson/meson_sm.c:178:\t\tmemcpy(buffer, fw-\u003esm_shmem_out_base, size);\ndrivers/firmware/meson/meson_sm.c-179-\n--\ndrivers/firmware/meson/meson_sm.c=311=static int __init meson_sm_probe(struct platform_device *pdev)\n--\ndrivers/firmware/meson/meson_sm.c-331-\ndrivers/firmware/meson/meson_sm.c:332:\tif (chip-\u003ecmd_shmem_out_base) {\ndrivers/firmware/meson/meson_sm.c:333:\t\tfw-\u003esm_shmem_out_base = meson_sm_map_shmem(chip-\u003ecmd_shmem_out_base,\ndrivers/firmware/meson/meson_sm.c-334-\t\t\t\t\t\t\t   chip-\u003eshmem_size);\ndrivers/firmware/meson/meson_sm.c:335:\t\tif (WARN_ON(!fw-\u003esm_shmem_out_base))\ndrivers/firmware/meson/meson_sm.c-336-\t\t\tgoto unmap_in_base;\n--\ndrivers/firmware/meson/meson_sm.c-350-unmap_out_base:\ndrivers/firmware/meson/meson_sm.c:351:\tiounmap(fw-\u003esm_shmem_out_base);\ndrivers/firmware/meson/meson_sm.c-352-unmap_in_base:\n--\ndrivers/gpu/drm/Makefile=124=drm_shmem_helper-y := drm_gem_shmem_helper.o\ndrivers/gpu/drm/Makefile:125:drm_shmem_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_shmem.o\ndrivers/gpu/drm/Makefile-126-obj-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_shmem_helper.o\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c=43=static int drm_fbdev_shmem_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c-47-\tstruct drm_gem_object *obj = drm_gem_fb_get_obj(fb, 0);\ndrivers/gpu/drm/drm_fbdev_shmem.c:48:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_fbdev_shmem.c-49-\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c=82=static struct page *drm_fbdev_shmem_get_page(struct fb_info *info, unsigned long offset)\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c-86-\tstruct drm_gem_object *obj = drm_gem_fb_get_obj(fb, 0);\ndrivers/gpu/drm/drm_fbdev_shmem.c:87:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_fbdev_shmem.c-88-\tunsigned int i = offset \u003e\u003e PAGE_SHIFT;\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c=133=int drm_fbdev_shmem_driver_fbdev_probe(struct drm_fb_helper *fb_helper,\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c-139-\tstruct drm_client_buffer *buffer;\ndrivers/gpu/drm/drm_fbdev_shmem.c:140:\tstruct drm_gem_shmem_object *shmem;\ndrivers/gpu/drm/drm_fbdev_shmem.c-141-\tstruct drm_framebuffer *fb;\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c-154-\t\treturn PTR_ERR(buffer);\ndrivers/gpu/drm/drm_fbdev_shmem.c:155:\tshmem = to_drm_gem_shmem_obj(buffer-\u003egem);\ndrivers/gpu/drm/drm_fbdev_shmem.c-156-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=28=MODULE_IMPORT_NS(\"DMA_BUF\");\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-35- *\ndrivers/gpu/drm/drm_gem_shmem_helper.c:36: * Functions that operate on the GEM object receive struct \u0026drm_gem_shmem_object.\ndrivers/gpu/drm/drm_gem_shmem_helper.c-37- * For GEM callback helpers in struct \u0026drm_gem_object functions, see likewise\ndrivers/gpu/drm/drm_gem_shmem_helper.c:38: * named functions with an _object_ infix (e.g., drm_gem_shmem_object_vmap() wraps\ndrivers/gpu/drm/drm_gem_shmem_helper.c-39- * drm_gem_shmem_vmap()). These helpers perform the necessary type conversion.\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=42=static const struct drm_gem_object_funcs drm_gem_shmem_funcs = {\ndrivers/gpu/drm/drm_gem_shmem_helper.c:43:\t.free = drm_gem_shmem_object_free,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:44:\t.print_info = drm_gem_shmem_object_print_info,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:45:\t.pin = drm_gem_shmem_object_pin,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:46:\t.unpin = drm_gem_shmem_object_unpin,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:47:\t.get_sg_table = drm_gem_shmem_object_get_sg_table,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:48:\t.vmap = drm_gem_shmem_object_vmap,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:49:\t.vunmap = drm_gem_shmem_object_vunmap,\ndrivers/gpu/drm/drm_gem_shmem_helper.c:50:\t.mmap = drm_gem_shmem_object_mmap,\ndrivers/gpu/drm/drm_gem_shmem_helper.c-51-\t.vm_ops = \u0026drm_gem_shmem_vm_ops,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-53-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:54:static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem,\ndrivers/gpu/drm/drm_gem_shmem_helper.c-55-\t\t\t\tsize_t size, bool private)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-108- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:109:int drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem, size_t size)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-110-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=113=EXPORT_SYMBOL_GPL(drm_gem_shmem_init);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-114-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:115:static struct drm_gem_shmem_object *\ndrivers/gpu/drm/drm_gem_shmem_helper.c-116-__drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-117-{\ndrivers/gpu/drm/drm_gem_shmem_helper.c:118:\tstruct drm_gem_shmem_object *shmem;\ndrivers/gpu/drm/drm_gem_shmem_helper.c-119-\tstruct drm_gem_object *obj;\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-127-\t\t\treturn ERR_CAST(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c:128:\t\tshmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-129-\t} else {\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-151- * Returns:\ndrivers/gpu/drm/drm_gem_shmem_helper.c:152: * A struct drm_gem_shmem_object * on success or an ERR_PTR()-encoded negative\ndrivers/gpu/drm/drm_gem_shmem_helper.c-153- * error code on failure.\ndrivers/gpu/drm/drm_gem_shmem_helper.c-154- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:155:struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-156-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=159=EXPORT_SYMBOL_GPL(drm_gem_shmem_create);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-165- *\ndrivers/gpu/drm/drm_gem_shmem_helper.c:166: * If the passed shmem object has an active scatter/gather table for driver\ndrivers/gpu/drm/drm_gem_shmem_helper.c-167- * usage, this function will unmap it and release the memory associated with it.\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-173- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:174:void __drm_gem_shmem_free_sgt_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-175-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=183=EXPORT_SYMBOL_GPL(__drm_gem_shmem_free_sgt_locked);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-191- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:192:void drm_gem_shmem_release(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-193-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=216=EXPORT_SYMBOL_GPL(drm_gem_shmem_release);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-224- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:225:void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-226-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=230=EXPORT_SYMBOL_GPL(drm_gem_shmem_free);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-231-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:232:static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-233-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-271- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:272:void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-273-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=292=EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-293-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:294:int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-295-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=311=EXPORT_SYMBOL(drm_gem_shmem_pin_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-312-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:313:void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-314-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=320=EXPORT_SYMBOL(drm_gem_shmem_unpin_locked);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-331- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:332:int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-333-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=350=EXPORT_SYMBOL_GPL(drm_gem_shmem_pin);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-358- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:359:void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-360-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=372=EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-388- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:389:int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,\ndrivers/gpu/drm/drm_gem_shmem_helper.c-390-\t\t\t      struct iosys_map *map)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=440=EXPORT_SYMBOL_GPL(drm_gem_shmem_vmap_locked);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-453- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:454:void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,\ndrivers/gpu/drm/drm_gem_shmem_helper.c-455-\t\t\t\t struct iosys_map *map)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=490=int drm_gem_shmem_create_with_handle(struct drm_file *file_priv,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-493-{\ndrivers/gpu/drm/drm_gem_shmem_helper.c:494:\tstruct drm_gem_shmem_object *shmem;\ndrivers/gpu/drm/drm_gem_shmem_helper.c-495-\tint ret;\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=511=EXPORT_SYMBOL_GPL(drm_gem_shmem_create_with_handle);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-515- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:516:int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-517-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=527=EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-528-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:529:void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-530-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=591=static void drm_gem_shmem_record_mkwrite(struct vm_fault *vmf)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-594-\tstruct drm_gem_object *obj = vma-\u003evm_private_data;\ndrivers/gpu/drm/drm_gem_shmem_helper.c:595:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-596-\tloff_t num_pages = obj-\u003esize \u003e\u003e PAGE_SHIFT;\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=645=static vm_fault_t drm_gem_shmem_any_fault(struct vm_fault *vmf, unsigned int order)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-649-\tstruct drm_device *dev = obj-\u003edev;\ndrivers/gpu/drm/drm_gem_shmem_helper.c:650:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-651-\tloff_t num_pages = obj-\u003esize \u003e\u003e PAGE_SHIFT;\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=690=static void drm_gem_shmem_vm_open(struct vm_area_struct *vma)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-692-\tstruct drm_gem_object *obj = vma-\u003evm_private_data;\ndrivers/gpu/drm/drm_gem_shmem_helper.c:693:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-694-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=712=static void drm_gem_shmem_vm_close(struct vm_area_struct *vma)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-714-\tstruct drm_gem_object *obj = vma-\u003evm_private_data;\ndrivers/gpu/drm/drm_gem_shmem_helper.c:715:\tstruct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-716-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=739=EXPORT_SYMBOL_GPL(drm_gem_shmem_vm_ops);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-746- * This function implements an augmented version of the GEM DRM file mmap\ndrivers/gpu/drm/drm_gem_shmem_helper.c:747: * operation for shmem objects.\ndrivers/gpu/drm/drm_gem_shmem_helper.c-748- *\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-751- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:752:int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-753-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=791=EXPORT_SYMBOL_GPL(drm_gem_shmem_mmap);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-793-/**\ndrivers/gpu/drm/drm_gem_shmem_helper.c:794: * drm_gem_shmem_print_info() - Print \u0026drm_gem_shmem_object info for debugfs\ndrivers/gpu/drm/drm_gem_shmem_helper.c-795- * @shmem: shmem GEM object\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-798- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:799:void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem,\ndrivers/gpu/drm/drm_gem_shmem_helper.c-800-\t\t\t      struct drm_printer *p, unsigned int indent)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=810=EXPORT_SYMBOL_GPL(drm_gem_shmem_print_info);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-825- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:826:struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-827-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=834=EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-835-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:836:static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-837-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-888- */\ndrivers/gpu/drm/drm_gem_shmem_helper.c:889:struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-890-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=920=drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-924-\tsize_t size = PAGE_ALIGN(attach-\u003edmabuf-\u003esize);\ndrivers/gpu/drm/drm_gem_shmem_helper.c:925:\tstruct drm_gem_shmem_object *shmem;\ndrivers/gpu/drm/drm_gem_shmem_helper.c-926-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=948=struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-951-\tstruct dma_buf_attachment *attach;\ndrivers/gpu/drm/drm_gem_shmem_helper.c:952:\tstruct drm_gem_shmem_object *shmem;\ndrivers/gpu/drm/drm_gem_shmem_helper.c-953-\tstruct drm_gem_object *obj;\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=994=EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_no_map);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1000-#if IS_ENABLED(CONFIG_KUNIT)\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1001:int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct iosys_map *map)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1002-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1014=EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_vmap);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1015-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1016:void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct iosys_map *map)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1017-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1024=EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_vunmap);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1025-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1026:int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1027-{\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1039=EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_madvise);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1040-\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1041:int drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem)\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1042-{\n--\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c=489=static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj)\n--\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c-494-\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c:495:static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = {\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c-496-\t.get_pages = etnaviv_gem_shmem_get_pages,\n--\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c=614=int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,\n--\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c-620-\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c:621:\tret = etnaviv_gem_new_impl(dev, size, flags, \u0026etnaviv_gem_shmem_ops, \u0026obj);\ndrivers/gpu/drm/etnaviv/etnaviv_gem.c-622-\tif (ret)\n--\ndrivers/gpu/drm/i915/Makefile=155=gem-y += \\\n--\ndrivers/gpu/drm/i915/Makefile-172-\tgem/i915_gem_region.o \\\ndrivers/gpu/drm/i915/Makefile:173:\tgem/i915_gem_shmem.o \\\ndrivers/gpu/drm/i915/Makefile-174-\tgem/i915_gem_shrinker.o \\\n\n"
}

25/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 34726
							output: 34
							thoughts: 74
						

Thoughts:
**Initial Assessment of the Kernel Patch**

Okay, so this patch is touching `shmem`, which, naturally, is a fundamental part of the kernel – `CONFIG_SHMEM` is enabled by default, so it's a critical component. The fact that the changes target `mm/shmem.c` is expected, I'd assume the changes involve performance tweaks or bug fixes in that area. But the surprise here is that it also modifies `mm/zswap.c`. That's unexpected, so I really need to understand the relationship between these changes. I need to dig into the `mm/zswap.c` modifications to see the connection. Time to review those changes.



26/2 2026/08/17 10:15 tool read-file
0m Args:
{
  "File": "mm/zswap.c",
  "FirstLine": 640,
  "LineCount": 50
}

Results:
{
  "Contents": " 640:\t\t}\n 641:\t\tmutex_unlock(\u0026zswap_init_lock);\n 642:\t\n 643:\t\treturn ret;\n 644:\t}\n 645:\t\n 646:\t/*********************************\n 647:\t* lru functions\n 648:\t**********************************/\n 649:\t\n 650:\tstatic inline int entry_to_nid(struct zswap_entry *entry)\n 651:\t{\n 652:\t\treturn page_to_nid(virt_to_page(entry));\n 653:\t}\n 654:\t\n 655:\tstatic void zswap_lru_add(struct zswap_entry *entry)\n 656:\t{\n 657:\t\tint nid = entry_to_nid(entry);\n 658:\t\tstruct mem_cgroup *memcg;\n 659:\t\n 660:\t\t/*\n 661:\t\t * Note that it is safe to use rcu_read_lock() here, even in the face of\n 662:\t\t * concurrent memcg offlining:\n 663:\t\t *\n 664:\t\t * 1. list_lru_add() is called before list_lru_one is dead. The\n 665:\t\t *    new entry will be reparented to memcg's parent's list_lru.\n 666:\t\t * 2. list_lru_add() is called after list_lru_one is dead. The\n 667:\t\t *    new entry will be added directly to memcg's parent's list_lru.\n 668:\t\t *\n 669:\t\t * Similar reasoning holds for list_lru_del().\n 670:\t\t */\n 671:\t\trcu_read_lock();\n 672:\t\tmemcg = obj_cgroup_memcg(entry-\u003eobjcg);\n 673:\t\t/* will always succeed */\n 674:\t\tlist_lru_add(\u0026zswap_list_lru, \u0026entry-\u003elru, nid, memcg);\n 675:\t\trcu_read_unlock();\n 676:\t}\n 677:\t\n 678:\tstatic void zswap_lru_del(struct zswap_entry *entry)\n 679:\t{\n 680:\t\tint nid = entry_to_nid(entry);\n 681:\t\tstruct mem_cgroup *memcg;\n 682:\t\n 683:\t\trcu_read_lock();\n 684:\t\tmemcg = obj_cgroup_memcg(entry-\u003eobjcg);\n 685:\t\t/* will always succeed */\n 686:\t\tlist_lru_del(\u0026zswap_list_lru, \u0026entry-\u003elru, nid, memcg);\n 687:\t\trcu_read_unlock();\n 688:\t}\n 689:\t\n"
}

27/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 35741
							output: 17
							thoughts: 575
						

Thoughts:
**My Analysis of the Zswap and Shmem Changes**

Okay, so looking at the modifications in `mm/zswap.c`, it's primarily about streamlining the memory cgroup handling. The change boils down to directly using `obj_cgroup_memcg` instead of going through `mem_cgroup_from_entry`. This is possible now because `obj_cgroup_memcg` has been updated to gracefully handle NULL values. So, while `CONFIG_ZSWAP` is relevant here, the core logic shift really centers around how shmem interacts with memory cgroups.

Let's quickly recap the key configurations involved:

*   `CONFIG_TRANSPARENT_HUGEPAGE`
*   `CONFIG_MEMCG`
*   `CONFIG_SHMEM` (This is usually on, but always good to note.)
*   `CONFIG_ZSWAP` (This is optional, but it's the target of the modification).

Now, let's nail down the critical symbols. We need to identify good entrypoints for further analysis. Based on a quick skim, here's what stands out:

*   `shmem_get_folio`: This is a non-static entry point, calling `shmem_get_folio_gfp` (which in turn calls `shmem_unused_huge_add`). This looks important.
*   `shmem_read_folio_gfp`: Another non-static entry point.
*   `shmem_fallocate`: This calls `shmem_get_folio`.
*   `shmem_fault`: This calls `shmem_get_folio_gfp`.
*   `shmem_unuse`: (Calls `shmem_evict_inode` indirectly? No, `shmem_evict_inode` is called by VFS).
*   `super_cache_scan` and `super_cache_count`: These are interesting, they are in `fs/super.c`. They trigger the shrinker because they call `shmem_unused_huge_scan` and `shmem_unused_huge_count` via `s_op->free_cached_objects` and `s_op->nr_cached_objects`. I had better check the exact relationship.

Wait a second, `super_cache_scan` and `super_cache_count` are in `fs/super.c`. That's smart. Those are good targets because they directly activate the shrinker! And, yes, `shmem_get_folio` also looks very promising as a focus point. It's a non-static entry point. I just need to verify that. Yes, `shmem_get_folio` is exported - `EXPORT_SYMBOL_GPL(shmem_get_folio)`. But `super_cache_scan` isn't exported... it's static in `fs/super.c`. Okay, so, I need to focus on non-static, non-inlined API entrypoints. So, that means for `fs/super.c`, `super_cache_scan` is out, the entry points for the shrinker are really going to be `shrink_slab` or `shrink_node`. Let me double-check `mm/vmscan.c` and `mm/shrinker.c`.



28/2 2026/08/17 10:15 tool grepper
0m Args:
{
  "Expression": "shrink_slab"
}

Results:
{
  "Output": "fs/btrfs/super.c=2426=static long btrfs_nr_cached_objects(struct super_block *sb, struct shrink_control *sc)\n--\nfs/btrfs/super.c-2434-\t * root direct reclaim) shrink path. Skip the per-memcg iterations of\nfs/btrfs/super.c:2435:\t * shrink_slab_memcg() to avoid queueing duplicate global work.\nfs/btrfs/super.c-2436-\t */\n--\ninclude/linux/memcontrol.h=518=static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)\n--\ninclude/linux/memcontrol.h-528- * or a root-memcg shrink, i.e. not a per-memcg iteration of\ninclude/linux/memcontrol.h:529: * shrink_slab_memcg(). Filesystems whose -\u003enr_cached_objects()/\ninclude/linux/memcontrol.h-530- * -\u003efree_cached_objects() implementations operate on filesystem-global state\n--\ninclude/trace/events/vmscan.h=264=DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,\n--\ninclude/trace/events/vmscan.h-271-\ninclude/trace/events/vmscan.h:272:TRACE_EVENT(mm_shrink_slab_start,\ninclude/trace/events/vmscan.h-273-\tTP_PROTO(struct shrinker *shr, struct shrink_control *sc,\n--\ninclude/trace/events/vmscan.h-321-\ninclude/trace/events/vmscan.h:322:TRACE_EVENT(mm_shrink_slab_end,\ninclude/trace/events/vmscan.h-323-\tTP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,\n--\nmm/internal.h=1425=static inline bool pte_needs_soft_dirty_wp(struct vm_area_struct *vma, pte_t pte)\n--\nmm/internal.h-1430-/* shrinker related functions */\nmm/internal.h:1431:unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg,\nmm/internal.h-1432-\t\t\t  int priority);\n--\nmm/page_isolation.c=173=static int set_migratetype_isolate(struct page *page, enum pb_isolate_mode mode,\n--\nmm/page_isolation.c-192-\t\t/*\nmm/page_isolation.c:193:\t\t * FIXME: Now, memory hotplug doesn't call shrink_slab() by\nmm/page_isolation.c-194-\t\t * itself. We just check MOVABLE pages.\n--\nmm/shrinker.c=205=void set_shrinker_bit(struct mem_cgroup *memcg, int nid, int shrinker_id)\n--\nmm/shrinker.c-215-\t\t\tunit = info-\u003eunit[shrinker_id_to_index(shrinker_id)];\nmm/shrinker.c:216:\t\t\t/* Pairs with smp mb in shrink_slab() */\nmm/shrinker.c-217-\t\t\tsmp_mb__before_atomic();\n--\nmm/shrinker.c=358=static long add_nr_deferred(long nr, struct shrinker *shrinker,\n--\nmm/shrinker.c-375-\nmm/shrinker.c:376:static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,\nmm/shrinker.c-377-\t\t\t\t    struct shrinker *shrinker, int priority)\n--\nmm/shrinker.c-416-\nmm/shrinker.c:417:\ttrace_mm_shrink_slab_start(shrinker, shrinkctl, nr,\nmm/shrinker.c-418-\t\t\t\t   freeable, delta, total_scan, priority,\n--\nmm/shrinker.c-469-\nmm/shrinker.c:470:\ttrace_mm_shrink_slab_end(shrinker, shrinkctl-\u003enid, freed, nr, new_nr, total_scan,\nmm/shrinker.c-471-\t\t\t\t shrinkctl-\u003ememcg);\n--\nmm/shrinker.c-475-#ifdef CONFIG_MEMCG\nmm/shrinker.c:476:static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,\nmm/shrinker.c-477-\t\t\tstruct mem_cgroup *memcg, int priority)\n--\nmm/shrinker.c-506-\t *          shrinker_try_get() to guarantee existence of the shrinker,\nmm/shrinker.c:507:\t *          then we can release the RCU lock to do do_shrink_slab() that\nmm/shrinker.c-508-\t *          may sleep.\n--\nmm/shrinker.c-516-\t *  step 7: we have already exited the read-side of rcu critical section\nmm/shrinker.c:517:\t *          before calling do_shrink_slab(), the shrinker_info may be\nmm/shrinker.c-518-\t *          released in expand_one_shrinker_info(), so go back to step 1\n--\nmm/shrinker.c-559-\nmm/shrinker.c:560:\t\t\tret = do_shrink_slab(\u0026sc, shrinker, priority);\nmm/shrinker.c-561-\t\t\tif (ret == SHRINK_EMPTY) {\n--\nmm/shrinker.c-572-\t\t\t\t *\nmm/shrinker.c:573:\t\t\t\t * list_lru_add()     shrink_slab_memcg()\nmm/shrinker.c-574-\t\t\t\t *   list_add_tail()    clear_bit()\nmm/shrinker.c-575-\t\t\t\t *   \u003cMB\u003e               \u003cMB\u003e\nmm/shrinker.c:576:\t\t\t\t *   set_bit()          do_shrink_slab()\nmm/shrinker.c-577-\t\t\t\t */\nmm/shrinker.c-578-\t\t\t\tsmp_mb__after_atomic();\nmm/shrinker.c:579:\t\t\t\tret = do_shrink_slab(\u0026sc, shrinker, priority);\nmm/shrinker.c-580-\t\t\t\tif (ret == SHRINK_EMPTY)\n--\nmm/shrinker.c-596-#else /* !CONFIG_MEMCG */\nmm/shrinker.c:597:static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,\nmm/shrinker.c-598-\t\t\tstruct mem_cgroup *memcg, int priority)\n--\nmm/shrinker.c-604-/**\nmm/shrinker.c:605: * shrink_slab - shrink slab caches\nmm/shrinker.c-606- * @gfp_mask: allocation context\n--\nmm/shrinker.c-623- */\nmm/shrinker.c:624:unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg,\nmm/shrinker.c-625-\t\t\t  int priority)\n--\nmm/shrinker.c-637-\tif (!mem_cgroup_disabled() \u0026\u0026 !mem_cgroup_is_root(memcg))\nmm/shrinker.c:638:\t\treturn shrink_slab_memcg(gfp_mask, nid, memcg, priority);\nmm/shrinker.c-639-\n--\nmm/shrinker.c-651-\t *          then the existence of the shrinker can also be guaranteed,\nmm/shrinker.c:652:\t *          so we can release the RCU lock to do do_shrink_slab() that\nmm/shrinker.c-653-\t *          may sleep.\n--\nmm/shrinker.c-673-\nmm/shrinker.c:674:\t\tret = do_shrink_slab(\u0026sc, shrinker, priority);\nmm/shrinker.c-675-\t\tif (ret == SHRINK_EMPTY)\n--\nmm/vmscan.c=409=static unsigned long drop_slab_node(int nid)\n--\nmm/vmscan.c-415-\tdo {\nmm/vmscan.c:416:\t\tfreed += shrink_slab(GFP_KERNEL, nid, memcg, 0);\nmm/vmscan.c-417-\t} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);\n--\nmm/vmscan.c=5092=static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)\n--\nmm/vmscan.c-5113-\nmm/vmscan.c:5114:\tshrink_slab(sc-\u003egfp_mask, pgdat-\u003enode_id, memcg, sc-\u003epriority);\nmm/vmscan.c-5115-\n--\nmm/vmscan.c=6155=static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc)\n--\nmm/vmscan.c-6216-\nmm/vmscan.c:6217:\t\tshrink_slab(sc-\u003egfp_mask, pgdat-\u003enode_id, memcg,\nmm/vmscan.c-6218-\t\t\t    sc-\u003epriority);\n"
}

29/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 39421
							output: 19
							thoughts: 145
						

Thoughts:
**My Line of Inquiry**

Okay, so I'm trying to trace the path to `shrink_slab`. I need to figure out how it's actually *called*. Hmm, `shrink_slab` isn't directly exported, it's hidden away in `mm/internal.h`.  Right, that narrows down the direct external access. But I recall that the `drop_caches` sysctl command indirectly hits it through `drop_slab_node`, which then calls `shrink_slab`. So, `drop_caches` provides a trigger point, essentially.

Now, let's switch gears and consider what *else* is potentially interesting. I noticed that `shmem_get_folio` is defined, which means I can directly invoke it. Let's make a note of it, and also the related function `shmem_read_folio_gfp`.

Wait, `shmem_get_folio` seems like a particularly good candidate to focus on. It presents a clear point of entry.

Okay, let's keep going. What about `shmem_fallocate`? Oh, it's also non-static, so, it's exported too. Let's quickly investigate `shmem_fallocate`.



30/2 2026/08/17 10:15 tool grepper
0m Args:
{
  "Expression": "shmem_fallocate"
}

Results:
{
  "Output": "mm/shmem.c=47=static struct vfsmount *shm_mnt __ro_after_init;\n--\nmm/shmem.c-101-/*\nmm/shmem.c:102: * shmem_fallocate communicates with shmem_fault or shmem_writeout via\nmm/shmem.c-103- * inode-\u003ei_private (with i_rwsem making sure that it has only one user at\n--\nmm/shmem.c=1808=int shmem_writeout(struct swap_io_ctx *ctx, struct folio *folio,\n--\nmm/shmem.c-1873-\t * good idea to continue anyway, once we're pushing into swap.  So\nmm/shmem.c:1874:\t * reactivate the folio, and let shmem_fallocate() quit when too many.\nmm/shmem.c-1875-\t */\n--\nmm/shmem.c=2863=static vm_fault_t shmem_falloc_wait(struct vm_fault *vmf, struct inode *inode)\n--\nmm/shmem.c-2886-\t\t/*\nmm/shmem.c:2887:\t\t * shmem_falloc_waitq points into the shmem_fallocate()\nmm/shmem.c-2888-\t\t * stack of the hole-punching task: shmem_falloc_waitq\n--\nmm/shmem.c=3801=static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)\n--\nmm/shmem.c-3820-\nmm/shmem.c:3821:static long shmem_fallocate(struct file *file, int mode, loff_t offset,\nmm/shmem.c-3822-\t\t\t\t\t\t\t loff_t len)\n--\nmm/shmem.c=5377=static const struct file_operations shmem_file_operations = {\n--\nmm/shmem.c-5387-\t.splice_write\t= iter_file_splice_write,\nmm/shmem.c:5388:\t.fallocate\t= shmem_fallocate,\nmm/shmem.c-5389-\t.setlease\t= generic_setlease,\n"
}

31/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 40428
							output: 23
							thoughts: 53
						

Thoughts:
Okay, here's my take on those thoughts, framed as my own mental processing:

**Examining the Shmem Allocation Functions**

Alright, let's see, `shmem_fallocate`... yeah, that one's static. That means it's internal to the shmem implementation and not directly available for external use, which makes sense. So, if I need to work with shmem and allocate some memory, I'm going to be using something else. Okay, let's think... that means `shmem_get_folio` and `shmem_read_folio_gfp` are probably the entry points, the ones exposed as the "public" API for this. Seems logical. Let me focus in on `shmem_read_folio_gfp`. I want to investigate how this thing is used. Need to see what happens there.



32/2 2026/08/17 10:15 tool grepper
0m Args:
{
  "Expression": "shmem_read_folio_gfp"
}

Results:
{
  "Output": "drivers/gpu/drm/drm_gem.c=664=struct page **drm_gem_get_pages(struct drm_gem_object *obj)\n--\ndrivers/gpu/drm/drm_gem.c-694-\t\tunsigned long nr;\ndrivers/gpu/drm/drm_gem.c:695:\t\tfolio = shmem_read_folio_gfp(mapping, i,\ndrivers/gpu/drm/drm_gem.c-696-\t\t\t\tmapping_gfp_mask(mapping));\n--\ndrivers/gpu/drm/i915/gem/i915_gem_shmem.c=65=int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,\n--\ndrivers/gpu/drm/i915/gem/i915_gem_shmem.c-113-\t\t\tcond_resched();\ndrivers/gpu/drm/i915/gem/i915_gem_shmem.c:114:\t\t\tfolio = shmem_read_folio_gfp(mapping, i, gfp);\ndrivers/gpu/drm/i915/gem/i915_gem_shmem.c-115-\t\t\tif (!IS_ERR(folio))\n--\ndrivers/gpu/drm/ttm/ttm_backup.c=53=int ttm_backup_copy_page(struct file *backup, struct page *dst,\n--\ndrivers/gpu/drm/ttm/ttm_backup.c-59-\ndrivers/gpu/drm/ttm/ttm_backup.c:60:\tfrom_folio = shmem_read_folio_gfp(mapping, idx, mapping_gfp_mask(mapping)\ndrivers/gpu/drm/ttm/ttm_backup.c-61-\t\t\t\t\t  | additional_gfp);\n--\ndrivers/gpu/drm/ttm/ttm_backup.c=103=ttm_backup_backup_folio(struct file *backup, struct folio *folio,\n--\ndrivers/gpu/drm/ttm/ttm_backup.c-127-\t\telse\ndrivers/gpu/drm/ttm/ttm_backup.c:128:\t\t\tto_folio = shmem_read_folio_gfp(mapping, idx + i, alloc_gfp);\ndrivers/gpu/drm/ttm/ttm_backup.c-129-\t\tif (IS_ERR(to_folio)) {\n--\ninclude/linux/shmem_fs.h=178=int shmem_get_folio(struct inode *inode, pgoff_t index, loff_t write_end,\ninclude/linux/shmem_fs.h-179-\t\tstruct folio **foliop, enum sgp_type sgp);\ninclude/linux/shmem_fs.h:180:struct folio *shmem_read_folio_gfp(struct address_space *mapping,\ninclude/linux/shmem_fs.h-181-\t\tpgoff_t index, gfp_t gfp);\n--\ninclude/linux/shmem_fs.h=183=static inline struct folio *shmem_read_folio(struct address_space *mapping,\n--\ninclude/linux/shmem_fs.h-185-{\ninclude/linux/shmem_fs.h:186:\treturn shmem_read_folio_gfp(mapping, index, mapping_gfp_mask(mapping));\ninclude/linux/shmem_fs.h-187-}\n--\nmm/shmem.c=6133=int shmem_zero_setup_desc(struct vm_area_desc *desc)\n--\nmm/shmem.c-6146-/**\nmm/shmem.c:6147: * shmem_read_folio_gfp - read into page cache, using specified page allocation flags.\nmm/shmem.c-6148- * @mapping:\tthe folio's address_space\n--\nmm/shmem.c-6160- */\nmm/shmem.c:6161:struct folio *shmem_read_folio_gfp(struct address_space *mapping,\nmm/shmem.c-6162-\t\tpgoff_t index, gfp_t gfp)\n--\nmm/shmem.c-6182-}\nmm/shmem.c:6183:EXPORT_SYMBOL_GPL(shmem_read_folio_gfp);\nmm/shmem.c-6184-\nmm/shmem.c=6185=struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,\n--\nmm/shmem.c-6187-{\nmm/shmem.c:6188:\tstruct folio *folio = shmem_read_folio_gfp(mapping, index, gfp);\nmm/shmem.c-6189-\tstruct page *page;\n"
}

33/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 41905
							output: 20
							thoughts: 174
						

Thoughts:
**My Current Thinking on Shmem Code**

Okay, so I'm homing in on the right symbols for this. I'm focusing on `shmem_get_folio` and `shmem_read_folio_gfp`. Those are solid starting points for digging into this area of shared memory. I'm trying to figure out which functions are most important. Now, what about `shmem_unused_huge_shrink`? Even though it's static, it seems to be the primary function that's been modified recently, so it’s worth noting.

I'll list `shmem_get_folio`, `shmem_read_folio_gfp`, and `shmem_read_mapping_page_gfp` as key functions for examination.

The shrinker is triggered by `shrink_slab`, but that isn't exported. `drop_caches` sysctl, however, can trigger it, which is useful to know.

Ultimately, I'm confident that listing `shmem_get_folio` and `shmem_read_folio_gfp` is going to be my best bet for now. I'm also going to see if there are any other non-static functions in `mm/shmem.c` that might be relevant to the issues I'm examining. It's time to refine this list.



34/2 2026/08/17 10:15 tool grepper
0m Args:
{
  "Expression": "EXPORT_SYMBOL.*shmem"
}

Results:
{
  "Output": "drivers/gpu/drm/drm_fbdev_shmem.c=133=int drm_fbdev_shmem_driver_fbdev_probe(struct drm_fb_helper *fb_helper,\n--\ndrivers/gpu/drm/drm_fbdev_shmem.c-202-}\ndrivers/gpu/drm/drm_fbdev_shmem.c:203:EXPORT_SYMBOL(drm_fbdev_shmem_driver_fbdev_probe);\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=109=int drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem, size_t size)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-112-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:113:EXPORT_SYMBOL_GPL(drm_gem_shmem_init);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-114-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=155=struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-158-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:159:EXPORT_SYMBOL_GPL(drm_gem_shmem_create);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-160-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=174=void __drm_gem_shmem_free_sgt_locked(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-182-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:183:EXPORT_SYMBOL_GPL(__drm_gem_shmem_free_sgt_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-184-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=192=void drm_gem_shmem_release(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-215-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:216:EXPORT_SYMBOL_GPL(drm_gem_shmem_release);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-217-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=225=void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-229-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:230:EXPORT_SYMBOL_GPL(drm_gem_shmem_free);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-231-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=272=void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-291-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:292:EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-293-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=294=int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-310-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:311:EXPORT_SYMBOL(drm_gem_shmem_pin_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-312-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=313=void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-319-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:320:EXPORT_SYMBOL(drm_gem_shmem_unpin_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-321-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=332=int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-349-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:350:EXPORT_SYMBOL_GPL(drm_gem_shmem_pin);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-351-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=359=void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-371-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:372:EXPORT_SYMBOL_GPL(drm_gem_shmem_unpin);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-373-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=389=int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-439-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:440:EXPORT_SYMBOL_GPL(drm_gem_shmem_vmap_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-441-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=454=void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-473-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:474:EXPORT_SYMBOL_GPL(drm_gem_shmem_vunmap_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-475-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=490=int drm_gem_shmem_create_with_handle(struct drm_file *file_priv,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-510-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:511:EXPORT_SYMBOL_GPL(drm_gem_shmem_create_with_handle);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-512-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=516=int drm_gem_shmem_madvise_locked(struct drm_gem_shmem_object *shmem, int madv)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-526-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:527:EXPORT_SYMBOL_GPL(drm_gem_shmem_madvise_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-528-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=529=void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-558-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:559:EXPORT_SYMBOL_GPL(drm_gem_shmem_purge_locked);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-560-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=578=int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-588-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:589:EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-590-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=730=const struct vm_operations_struct drm_gem_shmem_vm_ops = {\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-738-};\ndrivers/gpu/drm/drm_gem_shmem_helper.c:739:EXPORT_SYMBOL_GPL(drm_gem_shmem_vm_ops);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-740-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=752=int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-790-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:791:EXPORT_SYMBOL_GPL(drm_gem_shmem_mmap);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-792-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=799=void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-809-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:810:EXPORT_SYMBOL_GPL(drm_gem_shmem_print_info);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-811-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=826=struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-833-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:834:EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-835-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=889=struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-901-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:902:EXPORT_SYMBOL_GPL(drm_gem_shmem_get_pages_sgt);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-903-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=920=drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-936-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:937:EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-938-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=948=struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-993-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:994:EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_no_map);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-995-\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1001=int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct iosys_map *map)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1013-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1014:EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_vmap);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1015-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1016=void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct iosys_map *map)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1023-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1024:EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_vunmap);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1025-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1026=int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1038-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1039:EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_madvise);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1040-\ndrivers/gpu/drm/drm_gem_shmem_helper.c=1041=int drm_gem_shmem_purge(struct drm_gem_shmem_object *shmem)\n--\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1053-}\ndrivers/gpu/drm/drm_gem_shmem_helper.c:1054:EXPORT_SYMBOL_IF_KUNIT(drm_gem_shmem_purge);\ndrivers/gpu/drm/drm_gem_shmem_helper.c-1055-#endif\n--\ndrivers/gpu/drm/i915/intel_gvt.c=289=EXPORT_SYMBOL_NS_GPL(i915_gem_object_alloc, \"I915_GVT\");\ndrivers/gpu/drm/i915/intel_gvt.c:290:EXPORT_SYMBOL_NS_GPL(i915_gem_object_create_shmem, \"I915_GVT\");\ndrivers/gpu/drm/i915/intel_gvt.c-291-EXPORT_SYMBOL_NS_GPL(i915_gem_object_init, \"I915_GVT\");\n--\ndrivers/gpu/drm/i915/intel_gvt.c=321=EXPORT_SYMBOL_NS_GPL(intel_uncore_forcewake_put, \"I915_GVT\");\ndrivers/gpu/drm/i915/intel_gvt.c:322:EXPORT_SYMBOL_NS_GPL(shmem_pin_map, \"I915_GVT\");\ndrivers/gpu/drm/i915/intel_gvt.c:323:EXPORT_SYMBOL_NS_GPL(shmem_unpin_map, \"I915_GVT\");\ndrivers/gpu/drm/i915/intel_gvt.c-324-EXPORT_SYMBOL_NS_GPL(__px_dma, \"I915_GVT\");\n--\nmm/shmem.c=278=bool shmem_mapping(const struct address_space *mapping)\n--\nmm/shmem.c-281-}\nmm/shmem.c:282:EXPORT_SYMBOL_GPL(shmem_mapping);\nmm/shmem.c-283-\n--\nmm/shmem.c=1495=void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend)\n--\nmm/shmem.c-1500-}\nmm/shmem.c:1501:EXPORT_SYMBOL_GPL(shmem_truncate_range);\nmm/shmem.c-1502-\n--\nmm/shmem.c=1957=int shmem_write_folio(struct folio *folio)\n--\nmm/shmem.c-1965-}\nmm/shmem.c:1966:EXPORT_SYMBOL_GPL(shmem_write_folio);\nmm/shmem.c-1967-\n--\nmm/shmem.c=2825=int shmem_get_folio(struct inode *inode, pgoff_t index, loff_t write_end,\n--\nmm/shmem.c-2830-}\nmm/shmem.c:2831:EXPORT_SYMBOL_GPL(shmem_get_folio);\nmm/shmem.c-2832-\n--\nmm/shmem.c=5980=void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend)\n--\nmm/shmem.c-5983-}\nmm/shmem.c:5984:EXPORT_SYMBOL_GPL(shmem_truncate_range);\nmm/shmem.c-5985-\n--\nmm/shmem.c=6060=struct file *shmem_kernel_file_setup(const char *name, loff_t size,\n--\nmm/shmem.c-6064-}\nmm/shmem.c:6065:EXPORT_SYMBOL_GPL(shmem_kernel_file_setup);\nmm/shmem.c-6066-\n--\nmm/shmem.c=6073=struct file *shmem_file_setup(const char *name, loff_t size, vma_flags_t flags)\n--\nmm/shmem.c-6076-}\nmm/shmem.c:6077:EXPORT_SYMBOL_GPL(shmem_file_setup);\nmm/shmem.c-6078-\n--\nmm/shmem.c=6086=struct file *shmem_file_setup_with_mnt(struct vfsmount *mnt, const char *name,\n--\nmm/shmem.c-6090-}\nmm/shmem.c:6091:EXPORT_SYMBOL_GPL(shmem_file_setup_with_mnt);\nmm/shmem.c-6092-\n--\nmm/shmem.c=6161=struct folio *shmem_read_folio_gfp(struct address_space *mapping,\n--\nmm/shmem.c-6182-}\nmm/shmem.c:6183:EXPORT_SYMBOL_GPL(shmem_read_folio_gfp);\nmm/shmem.c-6184-\nmm/shmem.c=6185=struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,\n--\nmm/shmem.c-6201-}\nmm/shmem.c:6202:EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);\n--\nsound/soc/qcom/qdsp6/audioreach.c=1226=int audioreach_shmem_register_event(struct q6apm_graph *graph, int bytes, int num_levels)\n--\nsound/soc/qcom/qdsp6/audioreach.c-1259-}\nsound/soc/qcom/qdsp6/audioreach.c:1260:EXPORT_SYMBOL_GPL(audioreach_shmem_register_event);\nsound/soc/qcom/qdsp6/audioreach.c-1261-\n--\nsound/soc/qcom/qdsp6/q6apm.c=184=int q6apm_graph_media_format_shmem(struct q6apm_graph *graph,\n--\nsound/soc/qcom/qdsp6/q6apm.c-205-}\nsound/soc/qcom/qdsp6/q6apm.c:206:EXPORT_SYMBOL_GPL(q6apm_graph_media_format_shmem);\nsound/soc/qcom/qdsp6/q6apm.c-207-\n"
}

35/2 2026/08/17 10:15 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 47790
							output: 235
							thoughts: 587
						

Thoughts:
**My Assessment of the Shmem Subsystem Changes**

Okay, so I've been looking over this patch and here's my take. It's touching some pretty critical areas, specifically the shmem subsystem and how it interacts with memcg, and that's got my attention. My initial thought is that this has a high potential for impacting system stability if not handled with care.

Specifically, it's modifying shmem to use a per-memcg `list_lru` to track unused huge pages instead of the previous global `shrinklist`. That's a significant shift, enabling the shrinker to reclaim huge pages on a per-memcg basis. This should avoid redundant work and adhere to memcg boundaries, which is a good thing for resource management. There's also that pointer handling change in `obj_cgroup_memcg`, which, as noted, ripples out to affect zswap too.

The core of the patch is deeply intertwined with memory management principles and shmem's internal logic, particularly around page allocation, eviction, and the shrinker mechanism. Given these changes, I'm marking `shmem_get_folio` and `shmem_read_folio_gfp` as key focus symbols to watch closely. While `shmem_read_mapping_page_gfp` is also modified, I want to make sure I focus on the others first as the main calls. `drop_caches` is also related, but not worth a focus symbol.

My immediate conclusion? This warrants intensive fuzzing. We need to be absolutely certain there are no memory leaks, use-after-free conditions, or deadlocks, especially during memcg reclaim or shmem operations. This is where I'd need to make sure I account for various stress tests, and edge cases.

I've also double-checked the relevant configurations. The patch interacts with `TRANSPARENT_HUGEPAGE`, `MEMCG`, `SHMEM`, and `ZSWAP`. I'm confident in the naming of these.

Okay, I've got a handle on the key functions to watch. Let's make sure I list these when reviewing the relevant sections of the codebase.



36/2 2026/08/17 10:15 tool set-results
0m Args:
{
  "EnableConfigs": [
    "TRANSPARENT_HUGEPAGE",
    "MEMCG",
    "SHMEM",
    "ZSWAP"
  ],
  "FocusSymbols": [
    "shmem_get_folio",
    "shmem_read_folio_gfp",
    "shmem_read_mapping_page_gfp"
  ],
  "Reasoning": "The patch modifies the shmem subsystem to use a per-memcg list_lru for tracking unused huge pages instead of a global shrinklist. This allows the shrinker to reclaim unused huge pages on a per-memcg basis, avoiding duplicate work and respecting memcg boundaries. It also modifies `obj_cgroup_memcg` to handle NULL pointers, which affects zswap as well. The changes involve core memory management and shmem logic, specifically around page allocation, eviction, and memory reclaim (shrinker). This is a significant functional change that should be heavily fuzzed to ensure no memory leaks, use-after-free, or deadlocks occur during memcg reclaim or shmem operations.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "TRANSPARENT_HUGEPAGE",
    "MEMCG",
    "SHMEM",
    "ZSWAP"
  ],
  "FocusSymbols": [
    "shmem_get_folio",
    "shmem_read_folio_gfp",
    "shmem_read_mapping_page_gfp"
  ],
  "Reasoning": "The patch modifies the shmem subsystem to use a per-memcg list_lru for tracking unused huge pages instead of a global shrinklist. This allows the shrinker to reclaim unused huge pages on a per-memcg basis, avoiding duplicate work and respecting memcg boundaries. It also modifies `obj_cgroup_memcg` to handle NULL pointers, which affects zswap as well. The changes involve core memory management and shmem logic, specifically around page allocation, eviction, and memory reclaim (shrinker). This is a significant functional change that should be heavily fuzzed to ensure no memory leaks, use-after-free, or deadlocks occur during memcg reclaim or shmem operations.",
  "WorthFuzzing": true
}

37/1 2026/08/17 10:15 action If
0m Args:
{
  "WorthFuzzing": true
}

Results:
null

38/2 2026/08/17 10:15 agent kmsan-evaluator
0m Model:
best-expensive

Args:
null

Results:
{
  "KMSANReasoning": "The patch series refactors the shmem unused huge page shrinker to use `list_lru` and `obj_cgroup` for memcg-aware shrinking. It modifies `struct shmem_inode_info` and `struct shmem_sb_info` to support this, and updates `fs/super.c` and `mm/zswap.c` to simplify memcg checks. The new fields in `struct shmem_inode_info` are properly initialized in `__shmem_get_inode`. The changes primarily involve list management, locking, and memcg accounting. Any bugs introduced by these changes would likely be use-after-free, NULL pointer dereferences, list corruption, or locking deadlocks, which are effectively caught by KASAN, LOCKDEP, and standard kernel debugging tools. There is no introduction of uninitialized memory being exposed to userspace or used in control flow, so a dedicated KMSAN fuzzing session is not required.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit b27c75b9e87bfd237638cc76a52d37576e801f9c
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Aug 17 10:13:48 2026 +0000

    syz-cluster: applied patch under review

diff --git a/fs/super.c b/fs/super.c
index 05e4431730387..3ecce24328f67 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -171,19 +171,6 @@ static void super_wake(struct super_block *sb, unsigned int flag)
 	wake_up_var(&sb->s_flags);
 }
 
-/*
- * The s_op->nr_cached_objects hooks (used for example by btrfs and xfs)
- * operate on filesystem-global state and ignore sc->memcg. Driving them
- * from per-memcg shrink_slab_memcg() invocations only burns CPU walking
- * per-cpu counters and queueing duplicate work: the actual reclaim happens on
- * the global path (kswapd or root direct reclaim) regardless. Restrict them
- * to that path.
- */
-static inline bool super_fs_objects_eligible(struct shrink_control *sc)
-{
-	return !sc->memcg || mem_cgroup_is_root(sc->memcg);
-}
-
 /*
  * One thing we have to be careful of with a per-sb shrinker is that we don't
  * drop the last active reference to the superblock from within the shrinker.
@@ -213,7 +200,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
 	if (!super_trylock_shared(sb))
 		return SHRINK_STOP;
 
-	if (sb->s_op->nr_cached_objects && super_fs_objects_eligible(sc))
+	if (sb->s_op->nr_cached_objects)
 		fs_objects = sb->s_op->nr_cached_objects(sb, sc);
 
 	inodes = list_lru_shrink_count(&sb->s_inode_lru, sc);
@@ -274,8 +261,7 @@ static unsigned long super_cache_count(struct shrinker *shrink,
 		return 0;
 	smp_rmb();
 
-	if (sb->s_op && sb->s_op->nr_cached_objects &&
-	    super_fs_objects_eligible(sc))
+	if (sb->s_op && sb->s_op->nr_cached_objects)
 		total_objects = sb->s_op->nr_cached_objects(sb, sc);
 
 	total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc);
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index cba35690c21aa..5107c227ae9b8 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -375,7 +375,7 @@ enum objext_flags {
 static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)
 {
 	lockdep_assert_once(rcu_read_lock_held() || lockdep_is_held(&cgroup_mutex));
-	return READ_ONCE(objcg->memcg);
+	return objcg ? READ_ONCE(objcg->memcg) : NULL;
 }
 
 /*
@@ -428,7 +428,7 @@ static inline struct mem_cgroup *folio_memcg(struct folio *folio)
 {
 	struct obj_cgroup *objcg = folio_objcg(folio);
 
-	return objcg ? obj_cgroup_memcg(objcg) : NULL;
+	return obj_cgroup_memcg(objcg);
 }
 
 /*
@@ -471,7 +471,7 @@ static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)
 
 	objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK);
 
-	return objcg ? obj_cgroup_memcg(objcg) : NULL;
+	return obj_cgroup_memcg(objcg);
 }
 
 static inline struct mem_cgroup *page_memcg_check(struct page *page)
@@ -1045,6 +1045,11 @@ void mem_cgroup_flush_workqueue(void);
 extern int mem_cgroup_init(void);
 #else /* CONFIG_MEMCG */
 
+static inline struct mem_cgroup *obj_cgroup_memcg(struct obj_cgroup *objcg)
+{
+	return NULL;
+}
+
 #define MEM_CGROUP_ID_SHIFT	0
 
 #define root_mem_cgroup		(NULL)
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 5663dff53186e..a7c7a96a7cbf9 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -11,6 +11,7 @@
 #include <linux/fs_parser.h>
 #include <linux/userfaultfd_k.h>
 #include <linux/bits.h>
+#include <linux/list_lru.h>
 
 /* inode in-kernel data */
 
@@ -54,6 +55,11 @@ struct shmem_inode_info {
 	struct dquot __rcu	*i_dquot[MAXQUOTAS];
 #endif
 	struct inode		vfs_inode;
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	struct obj_cgroup	*shrinklist_objcg;
+	int			shrinklist_nid;
+#endif
 };
 
 #define SHMEM_FL_USER_VISIBLE		(FS_FL_USER_VISIBLE | FS_CASEFOLD_FL)
@@ -83,9 +89,9 @@ struct shmem_sb_info {
 	ino_t next_ino;		    /* The next per-sb inode number to use */
 	ino_t __percpu *ino_batch;  /* The next per-cpu inode number to use */
 	struct mempolicy *mpol;     /* default memory policy for mappings */
-	spinlock_t shrinklist_lock;   /* Protects shrinklist */
-	struct list_head shrinklist;  /* List of shinkable inodes */
-	unsigned long shrinklist_len; /* Length of shrinklist */
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	struct list_lru shrinklist; /* List of shrinkable inodes */
+#endif
 	struct shmem_quota_limits qlimits; /* Default quota limits */
 	struct simple_xattr_cache xa_cache;
 };
diff --git a/mm/page_owner.c b/mm/page_owner.c
index fbbda7ba914ba..3fc37d9b908ef 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -575,7 +575,7 @@ static inline int print_page_owner_memcg(char *kbuf, size_t count, int ret,
 	}
 
 	objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK);
-	memcg = objcg ? obj_cgroup_memcg(objcg) : NULL;
+	memcg = obj_cgroup_memcg(objcg);
 	if (!memcg)
 		goto out_unlock;
 
diff --git a/mm/shmem.c b/mm/shmem.c
index 897fa2b61346f..bd5b53ee3a189 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -725,51 +725,258 @@ static const char *shmem_format_huge(int huge)
 }
 #endif
 
-static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
-		struct shrink_control *sc, unsigned long nr_to_free)
+static bool is_shmem_unused_huge_isolated(struct shmem_inode_info *info)
 {
-	LIST_HEAD(list), *pos, *next;
-	struct inode *inode;
+
+	return info->shrinklist_nid == -1;
+}
+
+static void set_shmem_unused_huge_isolated(struct shmem_inode_info *info)
+{
+	info->shrinklist_nid = -1;
+}
+
+static struct obj_cgroup *shmem_get_and_clear_objcg(struct shmem_inode_info *info)
+{
+	struct obj_cgroup *objcg = info->shrinklist_objcg;
+
+	info->shrinklist_objcg = NULL;
+
+	return objcg;
+}
+
+#ifdef CONFIG_MEMCG
+static struct obj_cgroup *
+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,
+			    gfp_t gfp)
+{
+	int ret;
+
+	ret = folio_memcg_list_lru_alloc(folio, &sbinfo->shrinklist, gfp);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return get_obj_cgroup_from_folio(folio);
+}
+#else
+static struct obj_cgroup *
+shmem_unused_huge_alloc_lru(struct shmem_sb_info *sbinfo, struct folio *folio,
+			    gfp_t gfp)
+{
+	return NULL;
+}
+#endif
+
+static void shmem_unused_huge_lru_add(struct shmem_sb_info *sbinfo,
+				      struct list_head *item, int nid,
+				      struct obj_cgroup *objcg)
+{
+	struct mem_cgroup *memcg;
+
+	rcu_read_lock();
+	memcg = obj_cgroup_memcg(objcg);
+	list_lru_add(&sbinfo->shrinklist, item, nid, memcg);
+	rcu_read_unlock();
+}
+
+static void shmem_unused_huge_lru_del(struct shmem_sb_info *sbinfo,
+				      struct list_head *item, int nid,
+				      struct obj_cgroup *objcg)
+{
+	struct mem_cgroup *memcg;
+
+	rcu_read_lock();
+	memcg = obj_cgroup_memcg(objcg);
+	list_lru_del(&sbinfo->shrinklist, item, nid, memcg);
+	rcu_read_unlock();
+}
+
+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,
+				  gfp_t gfp)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	int nid = folio_nid(folio);
+	struct obj_cgroup *objcg = NULL, *old_objcg = NULL;
+
+	objcg = shmem_unused_huge_alloc_lru(sbinfo, folio, gfp);
+	if (IS_ERR(objcg))
+		return;
+
+	spin_lock(&info->lock);
+	if (!list_empty(&info->shrinklist)) {
+		/* isolated on scan list, let shrink handle it */
+		if (is_shmem_unused_huge_isolated(info))
+			goto unlock;
+
+		if (info->shrinklist_nid == nid &&
+		    info->shrinklist_objcg == objcg)
+			goto unlock;
+
+		shmem_unused_huge_lru_del(sbinfo, &info->shrinklist,
+					  info->shrinklist_nid,
+					  info->shrinklist_objcg);
+		old_objcg = shmem_get_and_clear_objcg(info);
+	}
+
+	info->shrinklist_objcg = objcg;
+	info->shrinklist_nid = nid;
+	shmem_unused_huge_lru_add(sbinfo, &info->shrinklist, nid, objcg);
+	objcg = NULL;
+unlock:
+	spin_unlock(&info->lock);
+	obj_cgroup_put(old_objcg);
+	obj_cgroup_put(objcg);
+}
+
+static void shmem_unused_huge_del(struct inode *inode)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct obj_cgroup *objcg = NULL;
+
+	spin_lock(&info->lock);
+	if (!list_empty(&info->shrinklist)) {
+		shmem_unused_huge_lru_del(sbinfo, &info->shrinklist,
+					  info->shrinklist_nid,
+					  info->shrinklist_objcg);
+		objcg = shmem_get_and_clear_objcg(info);
+	}
+	spin_unlock(&info->lock);
+
+	obj_cgroup_put(objcg);
+}
+
+struct shmem_unused_huge_scan {
+	struct list_head list;
+	struct shrink_control *sc;
+};
+
+static enum lru_status shmem_unused_huge_isolate(struct list_head *item,
+						 struct list_lru_one *lru,
+						 void *arg)
+{
+	struct shmem_unused_huge_scan *scan = arg;
 	struct shmem_inode_info *info;
-	struct folio *folio;
-	unsigned long batch = sc ? sc->nr_to_scan : 128;
-	unsigned long split = 0, freed = 0;
+	struct inode *inode;
+	struct obj_cgroup *objcg = NULL;
 
-	if (list_empty(&sbinfo->shrinklist))
-		return SHRINK_STOP;
+	info = list_entry(item, struct shmem_inode_info, shrinklist);
 
-	spin_lock(&sbinfo->shrinklist_lock);
-	list_for_each_safe(pos, next, &sbinfo->shrinklist) {
-		info = list_entry(pos, struct shmem_inode_info, shrinklist);
+	/*
+	 * Use trylock to avoid ABBA deadlock: add/del path takes info->lock
+	 * before the list_lru bucket lock, while here the order is reversed.
+	 */
+	if (!spin_trylock(&info->lock))
+		return LRU_SKIP;
+
+	/* pin the inode */
+	inode = igrab(&info->vfs_inode);
+	/* inode is about to be evicted */
+	if (!inode) {
+		list_lru_isolate(lru, item);
+		objcg = shmem_get_and_clear_objcg(info);
+		spin_unlock(&info->lock);
+		obj_cgroup_put(objcg);
+		return LRU_REMOVED;
+	}
 
-		/* pin the inode */
-		inode = igrab(&info->vfs_inode);
+	list_lru_isolate(lru, item);
+	objcg = shmem_get_and_clear_objcg(info);
+	set_shmem_unused_huge_isolated(info);
+	list_add_tail(&info->shrinklist, &scan->list);
+	spin_unlock(&info->lock);
+	obj_cgroup_put(objcg);
 
-		/* inode is about to be evicted */
-		if (!inode) {
-			list_del_init(&info->shrinklist);
-			goto next;
-		}
+	return LRU_REMOVED;
+}
 
-		list_move(&info->shrinklist, &list);
-next:
-		sbinfo->shrinklist_len--;
-		if (!--batch)
-			break;
+static bool is_shmem_unused_huge_match(struct folio *folio,
+				       struct shrink_control *sc)
+{
+	struct mem_cgroup *memcg = NULL;
+	bool match;
+
+	/* shmem quota reclaim has no NUMA node or memcg restriction */
+	if (!sc)
+		return true;
+
+	if (folio_nid(folio) != sc->nid)
+		return false;
+
+	/*
+	 * Only non-root memcg reclaim needs to match the folio charge against
+	 * sc->memcg. Skip the folio memcg check for global shrinker reclaim and
+	 * root memcg reclaim.
+	 */
+	if (!sc->memcg || mem_cgroup_is_root(sc->memcg))
+		return true;
+
+	memcg = get_mem_cgroup_from_folio(folio);
+	match = memcg == sc->memcg;
+	mem_cgroup_put(memcg);
+
+	return match;
+}
+
+static void shmem_unused_huge_drop(struct inode *inode)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+
+	spin_lock(&info->lock);
+	list_del_init(&info->shrinklist);
+	spin_unlock(&info->lock);
+}
+
+static void shmem_unused_huge_requeue(struct inode *inode, struct folio *folio)
+{
+	struct shmem_inode_info *info = SHMEM_I(inode);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct obj_cgroup *objcg;
+	int nid = folio_nid(folio);
+
+	objcg = shmem_unused_huge_alloc_lru(sbinfo, folio, GFP_NOWAIT);
+	if (IS_ERR(objcg)) {
+		shmem_unused_huge_drop(inode);
+		return;
 	}
-	spin_unlock(&sbinfo->shrinklist_lock);
 
-	list_for_each_safe(pos, next, &list) {
-		pgoff_t next, end;
+	spin_lock(&info->lock);
+	/* Requeue the inode to shrinklist */
+	list_del_init(&info->shrinklist);
+	shmem_unused_huge_lru_add(sbinfo, &info->shrinklist, nid, objcg);
+	info->shrinklist_objcg = objcg;
+	info->shrinklist_nid = nid;
+	spin_unlock(&info->lock);
+}
+
+static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
+		struct shrink_control *sc, unsigned long nr_to_free)
+{
+	struct shmem_unused_huge_scan scan;
+	struct inode *inode;
+	struct shmem_inode_info *info;
+	struct folio *folio;
+	struct list_head *pos, *next;
+	unsigned long split = 0, freed = 0;
+
+	INIT_LIST_HEAD(&scan.list);
+	scan.sc = sc;
+	if (sc)
+		list_lru_shrink_walk(&sbinfo->shrinklist, sc,
+				     shmem_unused_huge_isolate, &scan);
+	else
+		list_lru_walk(&sbinfo->shrinklist, shmem_unused_huge_isolate,
+			      &scan, 128);
+
+	list_for_each_safe(pos, next, &scan.list) {
+		pgoff_t folio_end, end;
 		loff_t i_size;
 		int ret;
 
 		info = list_entry(pos, struct shmem_inode_info, shrinklist);
 		inode = &info->vfs_inode;
 
-		if (nr_to_free && freed >= nr_to_free)
-			goto move_back;
-
 		i_size = i_size_read(inode);
 		folio = filemap_get_entry(inode->i_mapping, i_size / PAGE_SIZE);
 		if (!folio || xa_is_value(folio))
@@ -782,13 +989,19 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		}
 
 		/* Check if there is anything to gain from splitting */
-		next = folio_next_index(folio);
+		folio_end = folio_next_index(folio);
 		end = shmem_fallocend(inode, DIV_ROUND_UP(i_size, PAGE_SIZE));
-		if (end <= folio->index || end >= next) {
+		if (end <= folio->index || end >= folio_end) {
 			folio_put(folio);
 			goto drop;
 		}
 
+		if (!is_shmem_unused_huge_match(folio, scan.sc))
+			goto move_back;
+
+		if (nr_to_free && freed >= nr_to_free)
+			goto move_back;
+
 		/*
 		 * Move the inode on the list back to shrinklist if we failed
 		 * to lock the page at this time.
@@ -796,35 +1009,30 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		 * Waiting for the lock may lead to deadlock in the
 		 * reclaim path.
 		 */
-		if (!folio_trylock(folio)) {
-			folio_put(folio);
+		if (!folio_trylock(folio))
+			goto move_back;
+
+		if (!is_shmem_unused_huge_match(folio, scan.sc)) {
+			folio_unlock(folio);
 			goto move_back;
 		}
 
 		ret = split_folio(folio);
 		folio_unlock(folio);
-		folio_put(folio);
 
 		/* If split failed move the inode on the list back to shrinklist */
 		if (ret)
 			goto move_back;
 
-		freed += next - end;
+		freed += folio_end - end;
 		split++;
+		folio_put(folio);
 drop:
-		list_del_init(&info->shrinklist);
+		shmem_unused_huge_drop(inode);
 		goto put;
 move_back:
-		/*
-		 * Make sure the inode is either on the global list or deleted
-		 * from any local list before iput() since it could be deleted
-		 * in another thread once we put the inode (then the local list
-		 * is corrupted).
-		 */
-		spin_lock(&sbinfo->shrinklist_lock);
-		list_move(&info->shrinklist, &sbinfo->shrinklist);
-		sbinfo->shrinklist_len++;
-		spin_unlock(&sbinfo->shrinklist_lock);
+		shmem_unused_huge_requeue(inode, folio);
+		folio_put(folio);
 put:
 		iput(inode);
 	}
@@ -837,7 +1045,7 @@ static long shmem_unused_huge_scan(struct super_block *sb,
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
-	if (!READ_ONCE(sbinfo->shrinklist_len))
+	if (!list_lru_shrink_count(&sbinfo->shrinklist, sc))
 		return SHRINK_STOP;
 
 	return shmem_unused_huge_shrink(sbinfo, sc, 0);
@@ -848,21 +1056,21 @@ static long shmem_unused_huge_count(struct super_block *sb,
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
-	/*
-	 * The per-superblock shrinklist is filesystem-global and does not
-	 * honour sc->memcg, so it is only meaningful on the global (kswapd or
-	 * root direct reclaim) shrink path. Skip the per-memcg iterations of
-	 * shrink_slab_memcg() to avoid queueing duplicate global work.
-	 */
-	if (!mem_cgroup_shrink_is_root(sc))
-		return 0;
-
-	return READ_ONCE(sbinfo->shrinklist_len);
+	return list_lru_shrink_count(&sbinfo->shrinklist, sc);
 }
 #else /* !CONFIG_TRANSPARENT_HUGEPAGE */
 
 #define shmem_huge SHMEM_HUGE_DENY
 
+static void shmem_unused_huge_add(struct inode *inode, struct folio *folio,
+				  gfp_t gfp)
+{
+}
+
+static void shmem_unused_huge_del(struct inode *inode)
+{
+}
+
 static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		struct shrink_control *sc, unsigned long nr_to_free)
 {
@@ -1418,14 +1626,7 @@ static void shmem_evict_inode(struct inode *inode)
 		inode->i_size = 0;
 		mapping_set_exiting(inode->i_mapping);
 		shmem_truncate_range(inode, 0, (loff_t)-1);
-		if (!list_empty(&info->shrinklist)) {
-			spin_lock(&sbinfo->shrinklist_lock);
-			if (!list_empty(&info->shrinklist)) {
-				list_del_init(&info->shrinklist);
-				sbinfo->shrinklist_len--;
-			}
-			spin_unlock(&sbinfo->shrinklist_lock);
-		}
+		shmem_unused_huge_del(inode);
 		while (!list_empty(&info->swaplist)) {
 			/* Wait while shmem_unuse() is scanning this inode... */
 			wait_var_event(&info->stop_eviction,
@@ -2536,27 +2737,6 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
 
 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);
@@ -2586,6 +2766,20 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
 		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)) {
+		/*
+		 * Part of the large folio is beyond i_size: subject
+		 * to shrink under memory pressure.
+		 */
+		shmem_unused_huge_add(inode, folio, gfp);
+	}
 out:
 	*foliop = folio;
 	return 0;
@@ -3062,6 +3256,10 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
 	if (info->fsflags)
 		shmem_set_inode_flags(inode, info->fsflags, NULL);
 	INIT_LIST_HEAD(&info->shrinklist);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	info->shrinklist_objcg = NULL;
+	info->shrinklist_nid = -1;
+#endif
 	INIT_LIST_HEAD(&info->swaplist);
 	cache_no_acl(inode);
 	if (sbinfo->noswap)
@@ -4936,6 +5134,9 @@ static void shmem_put_super(struct super_block *sb)
 #endif
 	free_percpu(sbinfo->ino_batch);
 	percpu_counter_destroy(&sbinfo->used_blocks);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	list_lru_destroy(&sbinfo->shrinklist);
+#endif
 	mpol_put(sbinfo->mpol);
 #ifdef CONFIG_TMPFS_XATTR
 	simple_xattr_cache_cleanup(&sbinfo->xa_cache);
@@ -5029,8 +5230,11 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
 	raw_spin_lock_init(&sbinfo->stat_lock);
 	if (percpu_counter_init(&sbinfo->used_blocks, 0, GFP_KERNEL))
 		goto failed;
-	spin_lock_init(&sbinfo->shrinklist_lock);
-	INIT_LIST_HEAD(&sbinfo->shrinklist);
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	if (list_lru_init_memcg(&sbinfo->shrinklist, sb->s_shrink))
+		goto failed;
+#endif
 
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 	sb->s_blocksize = PAGE_SIZE;
diff --git a/mm/zswap.c b/mm/zswap.c
index 37f34e406c8e3..c1dc60926bad9 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -647,19 +647,6 @@ static int zswap_enabled_param_set(const char *val,
 * lru functions
 **********************************/
 
-/* should be called under RCU */
-#ifdef CONFIG_MEMCG
-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)
-{
-	return entry->objcg ? obj_cgroup_memcg(entry->objcg) : NULL;
-}
-#else
-static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)
-{
-	return NULL;
-}
-#endif
-
 static inline int entry_to_nid(struct zswap_entry *entry)
 {
 	return page_to_nid(virt_to_page(entry));
@@ -682,7 +669,7 @@ static void zswap_lru_add(struct zswap_entry *entry)
 	 * Similar reasoning holds for list_lru_del().
 	 */
 	rcu_read_lock();
-	memcg = mem_cgroup_from_entry(entry);
+	memcg = obj_cgroup_memcg(entry->objcg);
 	/* will always succeed */
 	list_lru_add(&zswap_list_lru, &entry->lru, nid, memcg);
 	rcu_read_unlock();
@@ -694,7 +681,7 @@ static void zswap_lru_del(struct zswap_entry *entry)
 	struct mem_cgroup *memcg;
 
 	rcu_read_lock();
-	memcg = mem_cgroup_from_entry(entry);
+	memcg = obj_cgroup_memcg(entry->objcg);
 	/* will always succeed */
 	list_lru_del(&zswap_list_lru, &entry->lru, nid, memcg);
 	rcu_read_unlock();

39/3 2026/08/17 10:15 llm kmsan-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 10029
							output: 227
							thoughts: 720
						

Thoughts:
**My Assessment of This Memory Management Patch**

Okay, let's break this down. This patch is touching several key areas: `fs/super.c`, `include/linux/memcontrol.h`, `include/linux/shmem_fs.h`, `mm/page_owner.c`, `mm/shmem.c`, and `mm/zswap.c`. From a glance, it's clear the focus is on refining memory management, specifically concerning shrinkers, `list_lru`, `memcg` integration, and optimization of shmem huge page handling.

1.  First, `fs/super.c` sees the removal of that `super_fs_objects_eligible` check, streamlining how the superblock cache is scanned and counted. Not a huge change, but it removes an unneeded check.

2.  Next, `include/linux/memcontrol.h` is tidied up by allowing `obj_cgroup_memcg` to gracefully handle `NULL` `objcg` arguments, simplifying its usage in other parts of the code. Good, this is nice because it reduces the conditional checks in the calling functions.

3.  `include/linux/shmem_fs.h` is getting some love too. This patch introduces `shrinklist_objcg` and `shrinklist_nid` to `struct shmem_inode_info`, and importantly, the `shrinklist` in `struct shmem_sb_info` is being swapped out for a `list_lru`. This is a significant change because `list_lru` is much more efficient.

4.  Now, the core of the work seems to be in `mm/shmem.c`. The refactoring of `shmem_unused_huge_shrink` is substantial, leveraging `list_lru` and `obj_cgroup` for tracking unused shmem huge pages. I'm seeing new functions like `shmem_unused_huge_alloc_lru`, `shmem_unused_huge_lru_add`, etc., which indicates a switch to a more fine-grained and efficient approach. Good.

5.  Finally, `mm/zswap.c` is simplified by directly using `obj_cgroup_memcg` instead of that `mem_cgroup_from_entry` helper.

My initial assessment is that these changes are primarily about optimization and cleanup within the memory management framework. Crucially, there's no evidence of exposing new structures to userspace, which is generally a good sign. There are also no new uninitialized memory risks. But, of course, a careful review is always required.

Let's double-check that last point about uninitialized memory. I'm focusing on those newly added fields in `struct shmem_inode_info`: `shrinklist_objcg` and `shrinklist_nid`. Ah, yes, in `__shmem_get_inode`, they're properly initialized to `NULL` and `-1` respectively. That's reassuring. So, no, there are no uninitialized memory concerns here that would be exposed. The changes are all around list management, locking, and memcg accounting. This means any bugs I would anticipate include the classic problems like use-after-free, null pointer dereferences, locking issues, or list corruption, all of which are well-covered by KASAN, LOCKDEP, and the standard bug detectors.

Therefore, `NeedsKMSAN` should definitely be `false`. This looks like a solid set of improvements.



40/3 2026/08/17 10:15 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series refactors the shmem unused huge page shrinker to use `list_lru` and `obj_cgroup` for memcg-aware shrinking. It modifies `struct shmem_inode_info` and `struct shmem_sb_info` to support this, and updates `fs/super.c` and `mm/zswap.c` to simplify memcg checks. The new fields in `struct shmem_inode_info` are properly initialized in `__shmem_get_inode`. The changes primarily involve list management, locking, and memcg accounting. Any bugs introduced by these changes would likely be use-after-free, NULL pointer dereferences, list corruption, or locking deadlocks, which are effectively caught by KASAN, LOCKDEP, and standard kernel debugging tools. There is no introduction of uninitialized memory being exposed to userspace or used in control flow, so a dedicated KMSAN fuzzing session is not required.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series refactors the shmem unused huge page shrinker to use `list_lru` and `obj_cgroup` for memcg-aware shrinking. It modifies `struct shmem_inode_info` and `struct shmem_sb_info` to support this, and updates `fs/super.c` and `mm/zswap.c` to simplify memcg checks. The new fields in `struct shmem_inode_info` are properly initialized in `__shmem_get_inode`. The changes primarily involve list management, locking, and memcg accounting. Any bugs introduced by these changes would likely be use-after-free, NULL pointer dereferences, list corruption, or locking deadlocks, which are effectively caught by KASAN, LOCKDEP, and standard kernel debugging tools. There is no introduction of uninitialized memory being exposed to userspace or used in control flow, so a dedicated KMSAN fuzzing session is not required.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)