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]
Message-ID: <87muwewoav.fsf_-_@xmission.com>
Date:   Fri, 01 Jun 2018 09:53:44 -0500
From:   ebiederm@...ssion.com (Eric W. Biederman)
To:     Michal Hocko <mhocko@...nel.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Johannes Weiner <hannes@...xchg.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: [RFC][PATCH 2/2] memcgl: Remove dead code now that all tasks of an mm share a memcg


get_mem_cgroup_from_mm no longer needs to deal with offline memory cgroups.

mem_cgroup_can_attach no longer needs to worry about cgroup leaders
as all tasks of an mm will migrate together.

Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
 mm/memcontrol.c | 43 +++++++++----------------------------------
 1 file changed, 9 insertions(+), 34 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 078ef562bb90..a05c1253ad87 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -666,7 +666,7 @@ static void memcg_check_events(struct mem_cgroup *memcg, struct page *page)
 
 static struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
 {
-	struct mem_cgroup *memcg, *omemcg;
+	struct mem_cgroup *memcg;
 
 	rcu_read_lock();
 	/*
@@ -677,37 +677,18 @@ static struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
 	if (unlikely(!mm))
 		goto root_memcg;
 
-	/* Loop trying to get a reference while mm->memcg is changing */
-	for (omemcg = NULL;; omemcg = memcg) {
+	do {
 		memcg = rcu_dereference(mm->memcg);
 		if (unlikely(!memcg))
 			goto root_memcg;
-		if (likely(css_tryget_online(&memcg->css)))
-			goto found;
-		if ((memcg == omemcg) && css_tryget(&omemcg->css))
-			break;
-	}
+	} while (!css_tryget_online(&memcg->css));
+	rcu_read_unlock();
+	return memcg;
 
-	/* Walk up and find a live memory cgroup */
-	while (memcg != root_mem_cgroup) {
-		memcg = mem_cgroup_from_css(memcg->css.parent);
-		if (css_tryget_online(&memcg->css))
-			goto found_parent;
-	}
-	css_put(&omemcg->css);
 root_memcg:
 	css_get(&root_mem_cgroup->css);
 	rcu_read_unlock();
 	return root_mem_cgroup;
-
-found_parent:
-	css_get(&memcg->css);
-	mm_update_memcg(mm, memcg);
-	css_put(&omemcg->css);
-found:
-	rcu_read_unlock();
-	return memcg;
-
 }
 
 /**
@@ -4847,7 +4828,7 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
 	struct cgroup_subsys_state *css;
 	struct mem_cgroup *memcg = NULL; /* unneeded init to make gcc happy */
 	struct mem_cgroup *from;
-	struct task_struct *leader, *p;
+	struct task_struct *p;
 	struct mm_struct *mm;
 	unsigned long move_flags;
 	int ret;
@@ -4863,18 +4844,12 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
 
 	/*
 	 * Multi-process migrations only happen on the default hierarchy
-	 * where charge immigration is not used.  Perform charge
-	 * immigration if @tset contains a leader and whine if there are
-	 * multiple.
+	 * where charge immigration is not used.
 	 */
-	p = NULL;
-	cgroup_taskset_for_each_leader(leader, css, tset) {
-		WARN_ON_ONCE(p);
-		p = leader;
-		memcg = mem_cgroup_from_css(css);
-	}
+	p = cgroup_taskset_first(tset, &css);
 	if (!p)
 		return 0;
+	memcg = mem_cgroup_from_css(css);
 
 	/*
 	 * We are now commited to this value whatever it is. Changes in this
-- 
2.14.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ