Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: memcontrol: refactor memcg_reparent_objcgs()

Refactor the memcg_reparent_objcgs() to facilitate subsequent reparenting
LRU folios here.

Link: https://lore.kernel.org/2e5696db1993e593a51004c1dacedbc261689629.1772711148.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Allen Pais <apais@linux.microsoft.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Chen Ridong <chenridong@huawei.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Imran Khan <imran.f.khan@oracle.com>
Cc: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Liam Howlett <Liam.Howlett@oracle.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Wei Xu <weixugc@google.com>
Cc: Yosry Ahmed <yosry@kernel.org>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Qi Zheng and committed by
Andrew Morton
131adcc7 f3046526

+24 -5
+24 -5
mm/memcontrol.c
··· 208 208 return objcg; 209 209 } 210 210 211 - static void memcg_reparent_objcgs(struct mem_cgroup *memcg) 211 + static inline struct obj_cgroup *__memcg_reparent_objcgs(struct mem_cgroup *memcg, 212 + struct mem_cgroup *parent) 212 213 { 213 214 struct obj_cgroup *objcg, *iter; 214 - struct mem_cgroup *parent = parent_mem_cgroup(memcg); 215 215 216 216 objcg = rcu_replace_pointer(memcg->objcg, NULL, true); 217 - 218 - spin_lock_irq(&objcg_lock); 219 - 220 217 /* 1) Ready to reparent active objcg. */ 221 218 list_add(&objcg->list, &memcg->objcg_list); 222 219 /* 2) Reparent active objcg and already reparented objcgs to parent. */ ··· 222 225 /* 3) Move already reparented objcgs to the parent's list */ 223 226 list_splice(&memcg->objcg_list, &parent->objcg_list); 224 227 228 + return objcg; 229 + } 230 + 231 + static inline void reparent_locks(struct mem_cgroup *memcg, struct mem_cgroup *parent) 232 + { 233 + spin_lock_irq(&objcg_lock); 234 + } 235 + 236 + static inline void reparent_unlocks(struct mem_cgroup *memcg, struct mem_cgroup *parent) 237 + { 225 238 spin_unlock_irq(&objcg_lock); 239 + } 240 + 241 + static void memcg_reparent_objcgs(struct mem_cgroup *memcg) 242 + { 243 + struct obj_cgroup *objcg; 244 + struct mem_cgroup *parent = parent_mem_cgroup(memcg); 245 + 246 + reparent_locks(memcg, parent); 247 + 248 + objcg = __memcg_reparent_objcgs(memcg, parent); 249 + 250 + reparent_unlocks(memcg, parent); 226 251 227 252 percpu_ref_kill(&objcg->refcnt); 228 253 }