Skip to content

Commit cb44821

Browse files
shakeelbakpm00
authored andcommitted
memcg: move do_memsw_account() to CONFIG_MEMCG_V1
The do_memsw_account() is used to enable or disable legacy memory+swap accounting in memory cgroup. However with disabled CONFIG_MEMCG_V1, we don't need to keep checking it. So, let's always return false for !CONFIG_MEMCG_V1 configs. Before the patch: $ size mm/memcontrol.o text data bss dec hex filename 49928 10736 4172 64836 fd44 mm/memcontrol.o After the patch: $ size mm/memcontrol.o text data bss dec hex filename 49430 10480 4172 64082 fa52 mm/memcontrol.o Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Shakeel Butt <[email protected]> Acked-by: Johannes Weiner <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 20d6c17 commit cb44821

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mm/memcontrol-v1.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
iter != NULL; \
2323
iter = mem_cgroup_iter(NULL, iter, NULL))
2424

25-
/* Whether legacy memory+swap accounting is active */
26-
static inline bool do_memsw_account(void)
27-
{
28-
return !cgroup_subsys_on_dfl(memory_cgrp_subsys);
29-
}
30-
3125
unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap);
3226

3327
void drain_all_stock(struct mem_cgroup *root_memcg);
@@ -42,6 +36,12 @@ struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg);
4236
/* Cgroup v1-specific declarations */
4337
#ifdef CONFIG_MEMCG_V1
4438

39+
/* Whether legacy memory+swap accounting is active */
40+
static inline bool do_memsw_account(void)
41+
{
42+
return !cgroup_subsys_on_dfl(memory_cgrp_subsys);
43+
}
44+
4545
unsigned long memcg_events_local(struct mem_cgroup *memcg, int event);
4646
unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx);
4747
unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item);
@@ -94,6 +94,7 @@ extern struct cftype mem_cgroup_legacy_files[];
9494

9595
#else /* CONFIG_MEMCG_V1 */
9696

97+
static inline bool do_memsw_account(void) { return false; }
9798
static inline bool memcg1_alloc_events(struct mem_cgroup *memcg) { return true; }
9899
static inline void memcg1_free_events(struct mem_cgroup *memcg) {}
99100

0 commit comments

Comments
 (0)