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 mod_memcg_state() and mod_memcg_lruvec_state()

Refactor the memcg_reparent_objcgs() to facilitate subsequent reparenting
non-hierarchical stats.

Link: https://lore.kernel.org/7f8bd3aacec2270b9453428fc8585cca9f10751e.1772711148.git.zhengqi.arch@bytedance.com
Co-developed-by: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: Shakeel Butt <shakeel.butt@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: Harry Yoo <harry.yoo@oracle.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Imran Khan <imran.f.khan@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
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 <muchun.song@linux.dev>
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: 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
5371e350 7404bd37

+31 -19
+31 -19
mm/memcontrol.c
··· 717 717 return max(val * unit / PAGE_SIZE, 1UL); 718 718 } 719 719 720 - /** 721 - * mod_memcg_state - update cgroup memory statistics 722 - * @memcg: the memory cgroup 723 - * @idx: the stat item - can be enum memcg_stat_item or enum node_stat_item 724 - * @val: delta to add to the counter, can be negative 725 - */ 726 - void mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, 727 - int val) 720 + static void __mod_memcg_state(struct mem_cgroup *memcg, 721 + enum memcg_stat_item idx, int val) 728 722 { 729 723 int i = memcg_stats_index(idx); 730 724 int cpu; 731 - 732 - if (mem_cgroup_disabled()) 733 - return; 734 725 735 726 if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, idx)) 736 727 return; ··· 734 743 trace_mod_memcg_state(memcg, idx, val); 735 744 736 745 put_cpu(); 746 + } 747 + 748 + /** 749 + * mod_memcg_state - update cgroup memory statistics 750 + * @memcg: the memory cgroup 751 + * @idx: the stat item - can be enum memcg_stat_item or enum node_stat_item 752 + * @val: delta to add to the counter, can be negative 753 + */ 754 + void mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, 755 + int val) 756 + { 757 + if (mem_cgroup_disabled()) 758 + return; 759 + 760 + __mod_memcg_state(memcg, idx, val); 737 761 } 738 762 739 763 #ifdef CONFIG_MEMCG_V1 ··· 770 764 } 771 765 #endif 772 766 773 - static void mod_memcg_lruvec_state(struct lruvec *lruvec, 774 - enum node_stat_item idx, 775 - int val) 767 + static void __mod_memcg_lruvec_state(struct mem_cgroup_per_node *pn, 768 + enum node_stat_item idx, int val) 776 769 { 777 - struct mem_cgroup_per_node *pn; 778 - struct mem_cgroup *memcg; 770 + struct mem_cgroup *memcg = pn->memcg; 779 771 int i = memcg_stats_index(idx); 780 772 int cpu; 781 773 782 774 if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, idx)) 783 775 return; 784 - 785 - pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); 786 - memcg = pn->memcg; 787 776 788 777 cpu = get_cpu(); 789 778 ··· 793 792 trace_mod_memcg_lruvec_state(memcg, idx, val); 794 793 795 794 put_cpu(); 795 + } 796 + 797 + static void mod_memcg_lruvec_state(struct lruvec *lruvec, 798 + enum node_stat_item idx, 799 + int val) 800 + { 801 + struct mem_cgroup_per_node *pn; 802 + 803 + pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); 804 + 805 + __mod_memcg_lruvec_state(pn, idx, val); 796 806 } 797 807 798 808 /**