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

mm: list_lru: rename memcg_drain_all_list_lrus to memcg_reparent_list_lrus

The purpose of the memcg_drain_all_list_lrus() is list_lrus reparenting.
It is very similar to memcg_reparent_objcgs(). Rename it to
memcg_reparent_list_lrus() so that the name can more consistent with
memcg_reparent_objcgs().

Link: https://lkml.kernel.org/r/20220228122126.37293-12-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Alex Shi <alexs@kernel.org>
Cc: Anna Schumaker <Anna.Schumaker@Netapp.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Fam Zheng <fam.zheng@bytedance.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kari Argillander <kari.argillander@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
Cc: Yang Shi <shy828301@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Muchun Song and committed by
Linus Torvalds
1f391eb2 5abc1e37

+16 -16
+1 -1
include/linux/list_lru.h
··· 78 78 int memcg_list_lru_alloc(struct mem_cgroup *memcg, struct list_lru *lru, 79 79 gfp_t gfp); 80 80 int memcg_update_all_list_lrus(int num_memcgs); 81 - void memcg_drain_all_list_lrus(struct mem_cgroup *src, struct mem_cgroup *dst); 81 + void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent); 82 82 83 83 /** 84 84 * list_lru_add: add an element to the lru list's tail
+12 -12
mm/list_lru.c
··· 457 457 return ret; 458 458 } 459 459 460 - static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, 461 - int src_idx, struct mem_cgroup *dst_memcg) 460 + static void memcg_reparent_list_lru_node(struct list_lru *lru, int nid, 461 + int src_idx, struct mem_cgroup *dst_memcg) 462 462 { 463 463 struct list_lru_node *nlru = &lru->node[nid]; 464 464 int dst_idx = dst_memcg->kmemcg_id; ··· 486 486 spin_unlock_irq(&nlru->lock); 487 487 } 488 488 489 - static void memcg_drain_list_lru(struct list_lru *lru, 490 - int src_idx, struct mem_cgroup *dst_memcg) 489 + static void memcg_reparent_list_lru(struct list_lru *lru, 490 + int src_idx, struct mem_cgroup *dst_memcg) 491 491 { 492 492 int i; 493 493 494 494 for_each_node(i) 495 - memcg_drain_list_lru_node(lru, i, src_idx, dst_memcg); 495 + memcg_reparent_list_lru_node(lru, i, src_idx, dst_memcg); 496 496 497 497 memcg_list_lru_free(lru, src_idx); 498 498 } 499 499 500 - void memcg_drain_all_list_lrus(struct mem_cgroup *src, struct mem_cgroup *dst) 500 + void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent) 501 501 { 502 502 struct cgroup_subsys_state *css; 503 503 struct list_lru *lru; 504 - int src_idx = src->kmemcg_id; 504 + int src_idx = memcg->kmemcg_id; 505 505 506 506 /* 507 507 * Change kmemcg_id of this cgroup and all its descendants to the ··· 517 517 * call. 518 518 */ 519 519 rcu_read_lock(); 520 - css_for_each_descendant_pre(css, &src->css) { 521 - struct mem_cgroup *memcg; 520 + css_for_each_descendant_pre(css, &memcg->css) { 521 + struct mem_cgroup *child; 522 522 523 - memcg = mem_cgroup_from_css(css); 524 - memcg->kmemcg_id = dst->kmemcg_id; 523 + child = mem_cgroup_from_css(css); 524 + child->kmemcg_id = parent->kmemcg_id; 525 525 } 526 526 rcu_read_unlock(); 527 527 528 528 mutex_lock(&list_lrus_mutex); 529 529 list_for_each_entry(lru, &memcg_list_lrus, list) 530 - memcg_drain_list_lru(lru, src_idx, dst); 530 + memcg_reparent_list_lru(lru, src_idx, parent); 531 531 mutex_unlock(&list_lrus_mutex); 532 532 } 533 533
+3 -3
mm/memcontrol.c
··· 3710 3710 memcg_reparent_objcgs(memcg, parent); 3711 3711 3712 3712 /* 3713 - * memcg_drain_all_list_lrus() can change memcg->kmemcg_id. 3713 + * memcg_reparent_list_lrus() can change memcg->kmemcg_id. 3714 3714 * Cache it to local @kmemcg_id. 3715 3715 */ 3716 3716 kmemcg_id = memcg->kmemcg_id; ··· 3719 3719 * After we have finished memcg_reparent_objcgs(), all list_lrus 3720 3720 * corresponding to this cgroup are guaranteed to remain empty. 3721 3721 * The ordering is imposed by list_lru_node->lock taken by 3722 - * memcg_drain_all_list_lrus(). 3722 + * memcg_reparent_list_lrus(). 3723 3723 */ 3724 - memcg_drain_all_list_lrus(memcg, parent); 3724 + memcg_reparent_list_lrus(memcg, parent); 3725 3725 3726 3726 memcg_free_cache_id(kmemcg_id); 3727 3727 }