lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 04 May 2018 12:26:51 -0500
From:   ebiederm@...ssion.com (Eric W. Biederman)
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Johannes Weiner <hannes@...xchg.org>,
        Michal Hocko <mhocko@...nel.org>,
        Kirill Tkhai <ktkhai@...tuozzo.com>, peterz@...radead.org,
        viro@...iv.linux.org.uk, mingo@...nel.org,
        paulmck@...ux.vnet.ibm.com, keescook@...omium.org, riel@...hat.com,
        tglx@...utronix.de, kirill.shutemov@...ux.intel.com,
        marcos.souza.org@...il.com, hoeun.ryu@...il.com,
        pasha.tatashin@...cle.com, gs051095@...il.com, dhowells@...hat.com,
        rppt@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
        Balbir Singh <balbir@...ux.vnet.ibm.com>,
        Tejun Heo <tj@...nel.org>, Oleg Nesterov <oleg@...hat.com>
Subject: [PATCH 1/2] memcg: Update the mm->memcg maintenance to work when !CONFIG_MMU


Michal Hocko <mhocko@...nel.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@...nel.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ