lkml.org 
[lkml]   [2018]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 1/2] memcg: Update the mm->memcg maintenance to work when !CONFIG_MMU

Michal Hocko <mhocko@kernel.org> reported:
> I am getting the following for nommu with MEMCG=y randconfig:
> kernel/fork.o: In function `mm_init':
> fork.c:(.text+0x948): undefined reference to `mm_update_memcg'
> kernel/fork.o: In function `mmput':
> fork.c:(.text+0x119c): undefined reference to `mm_update_memcg'
> make: *** [vmlinux] Error 1

A memory control group that only accounts mm activity on page fault
seems pointless when !MMU. Still I don't intend to break it so
move the mm->memcg changes out of #ifndef MMU.

Reported-by: Michal Hocko <mhocko@kernel.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
mm/memcontrol.c | 109 ++++++++++++++++++++++++++------------------------------
1 file changed, 51 insertions(+), 58 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a3745ccbd8c0..d74aeba7dfed 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4846,59 +4846,6 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
return ret;
}

-/**
- * mm_update_memcg - Update the memory cgroup of a mm_struct
- * @mm: mm struct
- * @new: new memory cgroup value
- *
- * Called whenever mm->memcg needs to change. Consumes a reference
- * to new (unless new is NULL). The reference to the old memory
- * cgroup is decreased.
- */
-void mm_update_memcg(struct mm_struct *mm, struct mem_cgroup *new)
-{
- /* This is the only place where mm->memcg is changed */
- struct mem_cgroup *old;
-
- old = xchg(&mm->memcg, new);
- if (old)
- css_put(&old->css);
-}
-
-static void task_update_memcg(struct task_struct *tsk, struct mem_cgroup *new)
-{
- struct mm_struct *mm;
- task_lock(tsk);
- mm = tsk->mm;
- if (mm && !(tsk->flags & PF_KTHREAD))
- mm_update_memcg(mm, new);
- task_unlock(tsk);
-}
-
-static void mem_cgroup_attach(struct cgroup_taskset *tset)
-{
- struct cgroup_subsys_state *css;
- struct task_struct *tsk;
-
- cgroup_taskset_for_each(tsk, css, tset) {
- struct mem_cgroup *new = mem_cgroup_from_css(css);
- css_get(css);
- task_update_memcg(tsk, new);
- }
-}
-
-static void mem_cgroup_fork(struct task_struct *tsk)
-{
- struct cgroup_subsys_state *css;
-
- rcu_read_lock();
- css = task_css(tsk, memory_cgrp_id);
- if (css && css_tryget(css))
- task_update_memcg(tsk, mem_cgroup_from_css(css));
- rcu_read_unlock();
-}
-
-
static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
{
if (mc.to)
@@ -5067,19 +5014,65 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
{
return 0;
}
-static void mem_cgroup_attach(struct cgroup_taskset *tset)
+static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
{
}
-static void mem_cgroup_fork(struct task_struct *task)
+static void mem_cgroup_move_task(void)
{
}
-static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
+#endif
+
+/**
+ * mm_update_memcg - Update the memory cgroup of a mm_struct
+ * @mm: mm struct
+ * @new: new memory cgroup value
+ *
+ * Called whenever mm->memcg needs to change. Consumes a reference
+ * to new (unless new is NULL). The reference to the old memory
+ * cgroup is decreased.
+ */
+void mm_update_memcg(struct mm_struct *mm, struct mem_cgroup *new)
{
+ /* This is the only place where mm->memcg is changed */
+ struct mem_cgroup *old;
+
+ old = xchg(&mm->memcg, new);
+ if (old)
+ css_put(&old->css);
}
-static void mem_cgroup_move_task(void)
+
+static void task_update_memcg(struct task_struct *tsk, struct mem_cgroup *new)
+{
+ struct mm_struct *mm;
+ task_lock(tsk);
+ mm = tsk->mm;
+ if (mm && !(tsk->flags & PF_KTHREAD))
+ mm_update_memcg(mm, new);
+ task_unlock(tsk);
+}
+
+static void mem_cgroup_attach(struct cgroup_taskset *tset)
{
+ struct cgroup_subsys_state *css;
+ struct task_struct *tsk;
+
+ cgroup_taskset_for_each(tsk, css, tset) {
+ struct mem_cgroup *new = mem_cgroup_from_css(css);
+ css_get(css);
+ task_update_memcg(tsk, new);
+ }
+}
+
+static void mem_cgroup_fork(struct task_struct *tsk)
+{
+ struct cgroup_subsys_state *css;
+
+ rcu_read_lock();
+ css = task_css(tsk, memory_cgrp_id);
+ if (css && css_tryget(css))
+ task_update_memcg(tsk, mem_cgroup_from_css(css));
+ rcu_read_unlock();
}
-#endif

/*
* Cgroup retains root cgroups across [un]mount cycles making it necessary
--
2.14.1
\
 
 \ /
  Last update: 2018-05-04 19:28    [W:0.162 / U:24.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site