[RFC][PATCH -mm -v2 2/4] mm,memcontrol: export mem_cgroup_get/put

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]