@@ -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;
@@ -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;
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(-)