memcg: clear pc->mem_cgroup if necessary.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / mm / swap_state.c
index 78cc4d1f6ccefe617698761cf198a7eb8a6db2bc..470038a9187383790751817cda61a07cb50f9512 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/swapops.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
-#include <linux/buffer_head.h>
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/migrate.h>
@@ -301,6 +300,16 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                        new_page = alloc_page_vma(gfp_mask, vma, addr);
                        if (!new_page)
                                break;          /* Out of memory */
+                       /*
+                        * The memcg-specific accounting when moving
+                        * pages around the LRU lists relies on the
+                        * page's owner (memcg) to be valid.  Usually,
+                        * pages are assigned to a new owner before
+                        * being put on the LRU list, but since this
+                        * is not the case here, the stale owner from
+                        * a previous allocation cycle must be reset.
+                        */
+                       mem_cgroup_reset_owner(new_page);
                }
 
                /*