|
@@ -1499,6 +1499,21 @@ nomem:
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Somemtimes we have to undo a charge we got by try_charge().
|
|
|
|
+ * This function is for that and do uncharge, put css's refcnt.
|
|
|
|
+ * gotten by try_charge().
|
|
|
|
+ */
|
|
|
|
+static void mem_cgroup_cancel_charge(struct mem_cgroup *mem)
|
|
|
|
+{
|
|
|
|
+ if (!mem_cgroup_is_root(mem)) {
|
|
|
|
+ res_counter_uncharge(&mem->res, PAGE_SIZE);
|
|
|
|
+ if (do_swap_account)
|
|
|
|
+ res_counter_uncharge(&mem->memsw, PAGE_SIZE);
|
|
|
|
+ }
|
|
|
|
+ css_put(&mem->css);
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* A helper function to get mem_cgroup from ID. must be called under
|
|
* A helper function to get mem_cgroup from ID. must be called under
|
|
* rcu_read_lock(). The caller must check css_is_removed() or some if
|
|
* rcu_read_lock(). The caller must check css_is_removed() or some if
|
|
@@ -1565,12 +1580,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem,
|
|
lock_page_cgroup(pc);
|
|
lock_page_cgroup(pc);
|
|
if (unlikely(PageCgroupUsed(pc))) {
|
|
if (unlikely(PageCgroupUsed(pc))) {
|
|
unlock_page_cgroup(pc);
|
|
unlock_page_cgroup(pc);
|
|
- if (!mem_cgroup_is_root(mem)) {
|
|
|
|
- res_counter_uncharge(&mem->res, PAGE_SIZE);
|
|
|
|
- if (do_swap_account)
|
|
|
|
- res_counter_uncharge(&mem->memsw, PAGE_SIZE);
|
|
|
|
- }
|
|
|
|
- css_put(&mem->css);
|
|
|
|
|
|
+ mem_cgroup_cancel_charge(mem);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1734,14 +1744,7 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
|
|
cancel:
|
|
cancel:
|
|
put_page(page);
|
|
put_page(page);
|
|
uncharge:
|
|
uncharge:
|
|
- /* drop extra refcnt by try_charge() */
|
|
|
|
- css_put(&parent->css);
|
|
|
|
- /* uncharge if move fails */
|
|
|
|
- if (!mem_cgroup_is_root(parent)) {
|
|
|
|
- res_counter_uncharge(&parent->res, PAGE_SIZE);
|
|
|
|
- if (do_swap_account)
|
|
|
|
- res_counter_uncharge(&parent->memsw, PAGE_SIZE);
|
|
|
|
- }
|
|
|
|
|
|
+ mem_cgroup_cancel_charge(parent);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1958,12 +1961,7 @@ void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *mem)
|
|
return;
|
|
return;
|
|
if (!mem)
|
|
if (!mem)
|
|
return;
|
|
return;
|
|
- if (!mem_cgroup_is_root(mem)) {
|
|
|
|
- res_counter_uncharge(&mem->res, PAGE_SIZE);
|
|
|
|
- if (do_swap_account)
|
|
|
|
- res_counter_uncharge(&mem->memsw, PAGE_SIZE);
|
|
|
|
- }
|
|
|
|
- css_put(&mem->css);
|
|
|
|
|
|
+ mem_cgroup_cancel_charge(mem);
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
static void
|