Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
[linux-2.6-block.git] / mm / memcontrol.c
index 645ede7ad1b244a57a517240f9eb81873a66e7f7..54920cbc46bfdcb87b0a4ae3e6b4538596b6bd58 100644 (file)
@@ -1669,6 +1669,8 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int
        if (order > PAGE_ALLOC_COSTLY_ORDER)
                return OOM_SKIPPED;
 
+       memcg_memory_event(memcg, MEMCG_OOM);
+
        /*
         * We are in the middle of the charge context here, so we
         * don't want to block when potentially sitting on a callstack
@@ -2250,8 +2252,6 @@ retry:
        if (fatal_signal_pending(current))
                goto force;
 
-       memcg_memory_event(mem_over_limit, MEMCG_OOM);
-
        /*
         * keep retrying as long as the memcg oom killer is able to make
         * a forward progress or bypass the charge if the oom killer
@@ -4299,14 +4299,12 @@ static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
 
 static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
 {
-       VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0);
-       atomic_add(n, &memcg->id.ref);
+       refcount_add(n, &memcg->id.ref);
 }
 
 static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
 {
-       VM_BUG_ON(atomic_read(&memcg->id.ref) < n);
-       if (atomic_sub_and_test(n, &memcg->id.ref)) {
+       if (refcount_sub_and_test(n, &memcg->id.ref)) {
                mem_cgroup_id_remove(memcg);
 
                /* Memcg ID pins CSS */
@@ -4523,7 +4521,7 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
        }
 
        /* Online state pins memcg ID, memcg ID pins CSS */
-       atomic_set(&memcg->id.ref, 1);
+       refcount_set(&memcg->id.ref, 1);
        css_get(css);
        return 0;
 }
@@ -4730,7 +4728,7 @@ static struct page *mc_handle_file_pte(struct vm_area_struct *vma,
        /* shmem/tmpfs may report page out on swap: account for that too. */
        if (shmem_mapping(mapping)) {
                page = find_get_entry(mapping, pgoff);
-               if (radix_tree_exceptional_entry(page)) {
+               if (xa_is_value(page)) {
                        swp_entry_t swp = radix_to_swp_entry(page);
                        if (do_memsw_account())
                                *entry = swp;
@@ -6357,7 +6355,7 @@ subsys_initcall(mem_cgroup_init);
 #ifdef CONFIG_MEMCG_SWAP
 static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg)
 {
-       while (!atomic_inc_not_zero(&memcg->id.ref)) {
+       while (!refcount_inc_not_zero(&memcg->id.ref)) {
                /*
                 * The root cgroup cannot be destroyed, so it's refcount must
                 * always be >= 1.