memcg: page_cgroup array is never stored on reserved pages
authorMichal Hocko <mhocko@suse.cz>
Wed, 23 Mar 2011 23:42:41 +0000 (16:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Mar 2011 02:46:33 +0000 (19:46 -0700)
KAMEZAWA Hiroyuki noted that free_pages_cgroup doesn't have to check for
PageReserved because we never store the array on reserved pages (neither
alloc_pages_exact nor vmalloc use those pages).

So we can replace the check by a BUG_ON.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page_cgroup.c

index 8e7577cdf5e4d6b5f48db6cbcd826fc38d3e8db1..a12cc3fa98594b931c16012dd53a52dbd49fdb6f 100644 (file)
@@ -153,11 +153,11 @@ static void free_page_cgroup(void *addr)
                vfree(addr);
        } else {
                struct page *page = virt_to_page(addr);
-               if (!PageReserved(page)) { /* Is bootmem ? */
-                       size_t table_size =
-                               sizeof(struct page_cgroup) * PAGES_PER_SECTION;
-                       free_pages_exact(addr, table_size);
-               }
+               size_t table_size =
+                       sizeof(struct page_cgroup) * PAGES_PER_SECTION;
+
+               BUG_ON(PageReserved(page));
+               free_pages_exact(addr, table_size);
        }
 }
 #endif