aboutsummaryrefslogtreecommitdiff
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4c741248198b..197b9ddb20f3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1066,6 +1066,9 @@ EXPORT_SYMBOL(get_mem_cgroup_from_page);
*/
static __always_inline struct mem_cgroup *get_mem_cgroup_from_current(void)
{
+ if (memcg_kmem_bypass())
+ return NULL;
+
if (unlikely(current->active_memcg)) {
struct mem_cgroup *memcg;
@@ -2933,6 +2936,9 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void)
struct obj_cgroup *objcg = NULL;
struct mem_cgroup *memcg;
+ if (memcg_kmem_bypass())
+ return NULL;
+
if (unlikely(!current->mm && !current->active_memcg))
return NULL;
@@ -3059,19 +3065,16 @@ int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order)
struct mem_cgroup *memcg;
int ret = 0;
- if (memcg_kmem_bypass())
- return 0;
-
memcg = get_mem_cgroup_from_current();
- if (!mem_cgroup_is_root(memcg)) {
+ if (memcg && !mem_cgroup_is_root(memcg)) {
ret = __memcg_kmem_charge(memcg, gfp, 1 << order);
if (!ret) {
page->mem_cgroup = memcg;
__SetPageKmemcg(page);
return 0;
}
+ css_put(&memcg->css);
}
- css_put(&memcg->css);
return ret;
}