Messages in this thread Patch in this message | | | From | Roman Gushchin <> | Subject | [PATCH rfc 9/9] mm: memcg: put cgroup v1-related members of task_struct under config option | Date | Wed, 8 May 2024 20:41:38 -0700 |
| |
Guard cgroup v1-related members of task_struct under the CONFIG_MEMCG_V1 config option, so that users who adopted cgroup v2 don't have to waste the memory for fields which are never accessed.
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev> --- include/linux/memcontrol.h | 11 ++++++++++- include/linux/sched.h | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 4347d6889fa0..8005d749f8fc 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -944,6 +944,7 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg); +#ifdef CONFIG_MEMCG_V1 static inline void mem_cgroup_enter_user_fault(void) { WARN_ON(current->in_user_fault); @@ -961,9 +962,17 @@ static inline bool task_in_memcg_oom(struct task_struct *p) return p->memcg_in_oom; } -#ifdef CONFIG_MEMCG_V1 bool mem_cgroup_oom_synchronize(bool wait); #else +static inline void mem_cgroup_enter_user_fault(void) {} + +static inline void mem_cgroup_exit_user_fault(void) {} + +static inline bool task_in_memcg_oom(struct task_struct *p) +{ + return false; +} + static inline bool mem_cgroup_oom_synchronize(bool wait) { return false; diff --git a/include/linux/sched.h b/include/linux/sched.h index 4118b3f959c3..2ecdeb7588e3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1446,11 +1446,14 @@ struct task_struct { unsigned int kcov_softirq; #endif -#ifdef CONFIG_MEMCG + +#ifdef CONFIG_MEMCG_V1 struct mem_cgroup *memcg_in_oom; gfp_t memcg_oom_gfp_mask; int memcg_oom_order; +#endif +#ifdef CONFIG_MEMCG /* Number of pages to reclaim on returning to userland: */ unsigned int memcg_nr_pages_over_high; -- 2.43.2
| |