Skip to content

Commit 610dc18

Browse files
Chen Ridongakpm00
authored andcommitted
memcg: add CONFIG_MEMCG_V1 for 'local' functions
Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in memcg v1, so that they won't be built for v2. Link: https://lkml.kernel.org/r/20250124073514.2375622-5-chenridong@huaweicloud.com Signed-off-by: Chen Ridong <chenridong@huawei.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Acked-by: Roman Gushchin <roman.gushchin@linux.dev> Cc: David Finkel <davidf@vimeo.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Wang Weiyang <wangweiyang2@huawei.com> Cc: Yosry Ahmed <yosryahmed@google.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Michal Koutný <mkoutny@suse.com> Cc: Muchun Song <songmuchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent bc812d1 commit 610dc18

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

mm/memcontrol-v1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
6060
void drain_all_stock(struct mem_cgroup *root_memcg);
6161

6262
unsigned long memcg_events(struct mem_cgroup *memcg, int event);
63-
unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
64-
unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
6563
unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item);
66-
unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
6764
int memory_stat_show(struct seq_file *m, void *v);
6865

6966
/* Cgroup v1-specific declarations */
7067
#ifdef CONFIG_MEMCG_V1
7168

69+
unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
70+
unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
71+
unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
7272
bool memcg1_alloc_events(struct mem_cgroup *memcg);
7373
void memcg1_free_events(struct mem_cgroup *memcg);
7474

mm/memcontrol.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx,
706706
trace_mod_memcg_state(memcg, idx, val);
707707
}
708708

709+
#ifdef CONFIG_MEMCG_V1
709710
/* idx can be of type enum memcg_stat_item or node_stat_item. */
710711
unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx)
711712
{
@@ -722,6 +723,7 @@ unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx)
722723
#endif
723724
return x;
724725
}
726+
#endif
725727

726728
static void __mod_memcg_lruvec_state(struct lruvec *lruvec,
727729
enum node_stat_item idx,
@@ -869,6 +871,7 @@ unsigned long memcg_events(struct mem_cgroup *memcg, int event)
869871
return READ_ONCE(memcg->vmstats->events[i]);
870872
}
871873

874+
#ifdef CONFIG_MEMCG_V1
872875
unsigned long memcg_events_local(struct mem_cgroup *memcg, int event)
873876
{
874877
int i = memcg_events_index(event);
@@ -878,6 +881,7 @@ unsigned long memcg_events_local(struct mem_cgroup *memcg, int event)
878881

879882
return READ_ONCE(memcg->vmstats->events_local[i]);
880883
}
884+
#endif
881885

882886
struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
883887
{
@@ -1447,11 +1451,13 @@ unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item)
14471451
memcg_page_state_output_unit(item);
14481452
}
14491453

1454+
#ifdef CONFIG_MEMCG_V1
14501455
unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item)
14511456
{
14521457
return memcg_page_state_local(memcg, item) *
14531458
memcg_page_state_output_unit(item);
14541459
}
1460+
#endif
14551461

14561462
#ifdef CONFIG_HUGETLB_PAGE
14571463
static bool memcg_accounts_hugetlb(void)

0 commit comments

Comments
 (0)