From: Chen Ridong <chenridong@huawei.com>
Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in
memcg v1, so that they won't be built for v2.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
mm/memcontrol-v1.h | 6 +++---
mm/memcontrol.c | 6 ++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h
index 144d71b65907..ecff454373e2 100644
--- a/mm/memcontrol-v1.h
+++ b/mm/memcontrol-v1.h
@@ -60,15 +60,15 @@ unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
void drain_all_stock(struct mem_cgroup *root_memcg);
unsigned long memcg_events(struct mem_cgroup *memcg, int event);
-unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
-unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item);
-unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
int memory_stat_show(struct seq_file *m, void *v);
/* Cgroup v1-specific declarations */
#ifdef CONFIG_MEMCG_V1
+unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
+unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
+unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
bool memcg1_alloc_events(struct mem_cgroup *memcg);
void memcg1_free_events(struct mem_cgroup *memcg);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b10e0a8f3375..daa74af15b05 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -706,6 +706,7 @@ void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx,
trace_mod_memcg_state(memcg, idx, val);
}
+#ifdef CONFIG_MEMCG_V1
/* idx can be of type enum memcg_stat_item or node_stat_item. */
unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx)
{
@@ -722,6 +723,7 @@ unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx)
#endif
return x;
}
+#endif
static void __mod_memcg_lruvec_state(struct lruvec *lruvec,
enum node_stat_item idx,
@@ -869,6 +871,7 @@ unsigned long memcg_events(struct mem_cgroup *memcg, int event)
return READ_ONCE(memcg->vmstats->events[i]);
}
+#ifdef CONFIG_MEMCG_V1
unsigned long memcg_events_local(struct mem_cgroup *memcg, int event)
{
int i = memcg_events_index(event);
@@ -878,6 +881,7 @@ unsigned long memcg_events_local(struct mem_cgroup *memcg, int event)
return READ_ONCE(memcg->vmstats->events_local[i]);
}
+#endif
struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
{
@@ -1447,11 +1451,13 @@ unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item)
memcg_page_state_output_unit(item);
}
+#ifdef CONFIG_MEMCG_V1
unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item)
{
return memcg_page_state_local(memcg, item) *
memcg_page_state_output_unit(item);
}
+#endif
#ifdef CONFIG_HUGETLB_PAGE
static bool memcg_accounts_hugetlb(void)
--
2.34.1
On Fri, Jan 24, 2025 at 07:35:14AM +0000, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in > memcg v1, so that they won't be built for v2. > > Signed-off-by: Chen Ridong <chenridong@huawei.com> Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
On Fri, Jan 24, 2025 at 07:35:14AM +0000, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in > memcg v1, so that they won't be built for v2. > > Signed-off-by: Chen Ridong <chenridong@huawei.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
On Fri, Jan 24, 2025 at 07:35:14AM +0000, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in > memcg v1, so that they won't be built for v2. > > Signed-off-by: Chen Ridong <chenridong@huawei.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Thanks!
© 2016 - 2025 Red Hat, Inc.