From: Rik van Riel <riel@redhat.com>
To: linux-mm@kvack.org
Cc: yinghan@google.com, aquini@redhat.com, hannes@cmpxchg.org,
mhocko@suse.cz, Mel Gorman <mel@csn.ul.ie>
Subject: [RFC][PATCH -mm -v2 2/4] mm,memcontrol: export mem_cgroup_get/put
Date: Thu, 16 Aug 2012 11:36:22 -0400 [thread overview]
Message-ID: <20120816113622.58c1bc85@cuia.bos.redhat.com> (raw)
In-Reply-To: <20120816113450.52f4e633@cuia.bos.redhat.com>
The page reclaim code should keep a reference to a cgroup while
reclaiming from that cgroup. In order to do this when selecting
the highest score cgroup for reclaim, the VM code needs access
to refcounting functions for the memory cgroup code.
Signed-off-by: Rik van Riel <riel@redhat.com>
---
include/linux/memcontrol.h | 11 +++++++++++
mm/memcontrol.c | 6 ++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 65538f9..c4cc64c 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -65,6 +65,9 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
struct lruvec *mem_cgroup_zone_lruvec(struct zone *, struct mem_cgroup *);
struct lruvec *mem_cgroup_page_lruvec(struct page *, struct zone *);
+extern void mem_cgroup_get(struct mem_cgroup *memcg);
+extern void mem_cgroup_put(struct mem_cgroup *memcg);
+
/* For coalescing uncharge for reducing memcg' overhead*/
extern void mem_cgroup_uncharge_start(void);
extern void mem_cgroup_uncharge_end(void);
@@ -298,6 +301,14 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root,
{
}
+static inline void mem_cgroup_get(struct mem_cgroup *memcg)
+{
+}
+
+static inline void mem_cgroup_put(struct mem_cgroup *memcg)
+{
+}
+
static inline bool mem_cgroup_disabled(void)
{
return true;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a18a0d5..376f680 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -368,8 +368,6 @@ enum charge_type {
#define MEM_CGROUP_RECLAIM_SHRINK_BIT 0x1
#define MEM_CGROUP_RECLAIM_SHRINK (1 << MEM_CGROUP_RECLAIM_SHRINK_BIT)
-static void mem_cgroup_get(struct mem_cgroup *memcg);
-static void mem_cgroup_put(struct mem_cgroup *memcg);
static bool mem_cgroup_is_root(struct mem_cgroup *memcg);
/* Writing them here to avoid exposing memcg's inner layout */
@@ -4492,7 +4490,7 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
call_rcu(&memcg->rcu_freeing, free_rcu);
}
-static void mem_cgroup_get(struct mem_cgroup *memcg)
+void mem_cgroup_get(struct mem_cgroup *memcg)
{
atomic_inc(&memcg->refcnt);
}
@@ -4507,7 +4505,7 @@ static void __mem_cgroup_put(struct mem_cgroup *memcg, int count)
}
}
-static void mem_cgroup_put(struct mem_cgroup *memcg)
+void mem_cgroup_put(struct mem_cgroup *memcg)
{
__mem_cgroup_put(memcg, 1);
}
--
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>
next prev parent reply other threads:[~2012-08-16 15:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 15:34 [RFC][PATCH -mm -v2 0/4] mm,vmscan: reclaim from highest score cgroup Rik van Riel
2012-08-16 15:35 ` [RFC][PATCH -mm -v2 1/4] mm,vmscan: track recent pressure on each LRU set Rik van Riel
2012-08-16 15:36 ` Rik van Riel [this message]
2012-08-16 15:37 ` [RFC][PATCH -mm -v2 3/4] mm,vmscan: reclaim from the highest score cgroups Rik van Riel
2012-08-17 23:34 ` Ying Han
2012-08-17 23:41 ` Rik van Riel
2012-08-18 0:26 ` Ying Han
2012-08-18 4:02 ` Rik van Riel
2012-08-16 15:38 ` [RFC][PATCH -mm -v2 4/4] mm,vmscan: evict inactive file pages first Rik van Riel
2012-08-23 23:07 ` Ying Han
2012-08-24 3:00 ` Rik van Riel
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=20120816113622.58c1bc85@cuia.bos.redhat.com \
--to=riel@redhat.com \
--cc=aquini@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=yinghan@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).