aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/memcontrol.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 350a14da6525..f4079692cbf5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -26,6 +26,7 @@
26#include <linux/backing-dev.h> 26#include <linux/backing-dev.h>
27#include <linux/bit_spinlock.h> 27#include <linux/bit_spinlock.h>
28#include <linux/rcupdate.h> 28#include <linux/rcupdate.h>
29#include <linux/slab.h>
29#include <linux/swap.h> 30#include <linux/swap.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
31#include <linux/fs.h> 32#include <linux/fs.h>
@@ -35,6 +36,7 @@
35 36
36struct cgroup_subsys mem_cgroup_subsys; 37struct cgroup_subsys mem_cgroup_subsys;
37static const int MEM_CGROUP_RECLAIM_RETRIES = 5; 38static const int MEM_CGROUP_RECLAIM_RETRIES = 5;
39static struct kmem_cache *page_cgroup_cache;
38 40
39/* 41/*
40 * Statistics for memory cgroup. 42 * Statistics for memory cgroup.
@@ -547,7 +549,7 @@ retry:
547 } 549 }
548 unlock_page_cgroup(page); 550 unlock_page_cgroup(page);
549 551
550 pc = kzalloc(sizeof(struct page_cgroup), gfp_mask); 552 pc = kmem_cache_zalloc(page_cgroup_cache, gfp_mask);
551 if (pc == NULL) 553 if (pc == NULL)
552 goto err; 554 goto err;
553 555
@@ -609,7 +611,7 @@ retry:
609 */ 611 */
610 res_counter_uncharge(&mem->res, PAGE_SIZE); 612 res_counter_uncharge(&mem->res, PAGE_SIZE);
611 css_put(&mem->css); 613 css_put(&mem->css);
612 kfree(pc); 614 kmem_cache_free(page_cgroup_cache, pc);
613 goto retry; 615 goto retry;
614 } 616 }
615 page_assign_page_cgroup(page, pc); 617 page_assign_page_cgroup(page, pc);
@@ -624,7 +626,7 @@ done:
624 return 0; 626 return 0;
625out: 627out:
626 css_put(&mem->css); 628 css_put(&mem->css);
627 kfree(pc); 629 kmem_cache_free(page_cgroup_cache, pc);
628err: 630err:
629 return -ENOMEM; 631 return -ENOMEM;
630} 632}
@@ -682,7 +684,7 @@ void mem_cgroup_uncharge_page(struct page *page)
682 res_counter_uncharge(&mem->res, PAGE_SIZE); 684 res_counter_uncharge(&mem->res, PAGE_SIZE);
683 css_put(&mem->css); 685 css_put(&mem->css);
684 686
685 kfree(pc); 687 kmem_cache_free(page_cgroup_cache, pc);
686 return; 688 return;
687 } 689 }
688 690
@@ -989,10 +991,12 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
989 struct mem_cgroup *mem; 991 struct mem_cgroup *mem;
990 int node; 992 int node;
991 993
992 if (unlikely((cont->parent) == NULL)) 994 if (unlikely((cont->parent) == NULL)) {
993 mem = &init_mem_cgroup; 995 mem = &init_mem_cgroup;
994 else 996 page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC);
997 } else {
995 mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); 998 mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL);
999 }
996 1000
997 if (mem == NULL) 1001 if (mem == NULL)
998 return ERR_PTR(-ENOMEM); 1002 return ERR_PTR(-ENOMEM);