[Devel] [PATCH rh7 1/6] memcg: add mem_cgroup_get/put helpers
Vladimir Davydov
vdavydov at parallels.com
Fri Sep 11 02:54:27 PDT 2015
Equivalent to css_get/put(mem_cgroup_css(memcg)). Currently, only used
by af_packet.c, but will also be used by the following patches.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
include/linux/memcontrol.h | 18 ++++++++++++++++++
net/packet/af_packet.c | 4 ++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index ac3f16f0ee28..548a82cde972 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -139,6 +139,16 @@ static inline bool mem_cgroup_disabled(void)
return false;
}
+static inline void mem_cgroup_get(struct mem_cgroup *memcg)
+{
+ css_get(mem_cgroup_css(memcg));
+}
+
+static inline void mem_cgroup_put(struct mem_cgroup *memcg)
+{
+ css_put(mem_cgroup_css(memcg));
+}
+
void __mem_cgroup_begin_update_page_stat(struct page *page, bool *locked,
unsigned long *flags);
@@ -321,6 +331,14 @@ static inline bool mem_cgroup_disabled(void)
return true;
}
+static inline void mem_cgroup_get(struct mem_cgroup *memcg)
+{
+}
+
+static inline void mem_cgroup_put(struct mem_cgroup *memcg)
+{
+}
+
static inline int
mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec)
{
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ee9d56b48823..0bc235e6a62a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2524,7 +2524,7 @@ static struct cg_proto *packet_sk_charge(void)
goto out;
out_put_cg:
- css_put(mem_cgroup_css(psc->memcg));
+ mem_cgroup_put(psc->memcg);
out_free_psc:
kfree(psc);
psc = NULL;
@@ -2545,7 +2545,7 @@ static void packet_sk_uncharge(struct cg_proto *cg)
if (psc) {
memcg_uncharge_kmem(psc->memcg, psc->amt);
- css_put(mem_cgroup_css(psc->memcg));
+ mem_cgroup_put(psc->memcg);
kfree(psc);
}
}
--
2.1.4
More information about the Devel
mailing list