All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Liu <jeff.liu@oracle.com>
To: linux-mm@kvack.org
Cc: cgroups@vger.kernel.org, Glauber Costa <glommer@parallels.com>
Subject: [RFC PATCH 3/3] memcg: allocate pages for swap cgroup until the first child memcg is alive
Date: Tue, 04 Dec 2012 16:36:17 +0800	[thread overview]
Message-ID: <50BDB601.4090205@oracle.com> (raw)

- Call swap_cgroup_init() when the first child memcg was created.
- Free pages from swap cgroup once the latest child memcg was removed.
- Teach swap_cgroup_record()/swap_cgroup_cmpxchg()/swap_cgroup_lookup_id()
  to aware of the new static variable. i.e, swap_cgroup_initialized, so that
  they would not perform further jobs if swap cgroup is not active.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
CC: Glauber Costa <glommer@parallels.com>
CC: Michal Hocko <mhocko@suse.cz>
CC: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
CC: Johannes Weiner <hannes@cmpxchg.org>
CC: Mel Gorman <mgorman@suse.de>
CC: Andrew Morton <akpm@linux-foundation.org>
---
 mm/memcontrol.c  |    3 +++
 mm/page_cgroup.c |    9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index dd39ba0..1f14375 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4982,6 +4982,8 @@ mem_cgroup_create(struct cgroup *cont)
 		}
 		hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
 	} else {
+		if (swap_cgroup_init())
+			goto free_out;
 		parent = mem_cgroup_from_cont(cont->parent);
 		memcg->use_hierarchy = parent->use_hierarchy;
 		memcg->oom_kill_disable = parent->oom_kill_disable;
@@ -5046,6 +5048,7 @@ static void mem_cgroup_destroy(struct cgroup *cont)
 	struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
 
 	kmem_cgroup_destroy(memcg);
+	swap_cgroup_destroy();
 
 	mem_cgroup_put(memcg);
 }
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index f1b257b..63c6789 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -429,6 +429,9 @@ unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
 	unsigned long flags;
 	unsigned short retval;
 
+	if (!atomic_read(&swap_cgroup_initialized))
+		return 0;
+
 	sc = lookup_swap_cgroup(ent, &ctrl);
 
 	spin_lock_irqsave(&ctrl->lock, flags);
@@ -456,6 +459,9 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
 	unsigned short old;
 	unsigned long flags;
 
+	if (!atomic_read(&swap_cgroup_initialized))
+		return 0;
+
 	sc = lookup_swap_cgroup(ent, &ctrl);
 
 	spin_lock_irqsave(&ctrl->lock, flags);
@@ -474,6 +480,9 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
  */
 unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
 {
+	if (!atomic_read(&swap_cgroup_initialized))
+		return 0;
+
 	return lookup_swap_cgroup(ent, NULL)->id;
 }
 
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

         reply	other threads:[~2012-12-04  8:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04  8:35 [RFC PATCH 0/3] Disable swap cgroup allocation at system boot stage Jeff Liu
2012-12-04  8:35 ` [RFC PATCH 1/3] memcg: refactor pages allocation/free for swap_cgroup Jeff Liu
2012-12-04 10:11   ` Michal Hocko
2012-12-04 10:46     ` Jeff Liu
2012-12-04  8:36 ` [RFC PATCH 2/3] memcg: disable pages allocation for swap cgroup on system booting up Jeff Liu
2012-12-04 11:17   ` Michal Hocko
     [not found]     ` <20121204111721.GB1343-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2012-12-04 11:22       ` Michal Hocko
2012-12-04 11:22         ` Michal Hocko
2012-12-04 12:34       ` Michal Hocko
2012-12-04 12:34         ` Michal Hocko
2012-12-04 12:51         ` Jeff Liu
2012-12-04  8:36 ` Jeff Liu [this message]
     [not found]   ` <50BDB601.4090205-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-12-04 12:54     ` [RFC PATCH 3/3] memcg: allocate pages for swap cgroup until the first child memcg is alive Michal Hocko
2012-12-04 12:54       ` Michal Hocko
2012-12-04 13:14       ` Jeff Liu
     [not found] ` <50BDB5E0.7030906-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-12-04 13:18   ` [RFC PATCH 0/3] Disable swap cgroup allocation at system boot stage Michal Hocko
2012-12-04 13:18     ` Michal Hocko
2012-12-04 14:00     ` Jeff Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50BDB601.4090205@oracle.com \
    --to=jeff.liu@oracle.com \
    --cc=cgroups@vger.kernel.org \
    --cc=glommer@parallels.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.