diff options
Diffstat (limited to 'mm/memcontrol.c')
| -rw-r--r-- | mm/memcontrol.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7973b5221fb8..f4ede99c8b9b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -1359,16 +1359,19 @@ void mem_cgroup_update_file_mapped(struct page *page, int val) | |||
| 1359 | 1359 | ||
| 1360 | lock_page_cgroup(pc); | 1360 | lock_page_cgroup(pc); |
| 1361 | mem = pc->mem_cgroup; | 1361 | mem = pc->mem_cgroup; |
| 1362 | if (!mem) | 1362 | if (!mem || !PageCgroupUsed(pc)) |
| 1363 | goto done; | ||
| 1364 | |||
| 1365 | if (!PageCgroupUsed(pc)) | ||
| 1366 | goto done; | 1363 | goto done; |
| 1367 | 1364 | ||
| 1368 | /* | 1365 | /* |
| 1369 | * Preemption is already disabled. We can use __this_cpu_xxx | 1366 | * Preemption is already disabled. We can use __this_cpu_xxx |
| 1370 | */ | 1367 | */ |
| 1371 | __this_cpu_add(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED], val); | 1368 | if (val > 0) { |
| 1369 | __this_cpu_inc(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); | ||
| 1370 | SetPageCgroupFileMapped(pc); | ||
| 1371 | } else { | ||
| 1372 | __this_cpu_dec(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); | ||
| 1373 | ClearPageCgroupFileMapped(pc); | ||
| 1374 | } | ||
| 1372 | 1375 | ||
| 1373 | done: | 1376 | done: |
| 1374 | unlock_page_cgroup(pc); | 1377 | unlock_page_cgroup(pc); |
| @@ -1801,16 +1804,13 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem, | |||
| 1801 | static void __mem_cgroup_move_account(struct page_cgroup *pc, | 1804 | static void __mem_cgroup_move_account(struct page_cgroup *pc, |
| 1802 | struct mem_cgroup *from, struct mem_cgroup *to, bool uncharge) | 1805 | struct mem_cgroup *from, struct mem_cgroup *to, bool uncharge) |
| 1803 | { | 1806 | { |
| 1804 | struct page *page; | ||
| 1805 | |||
| 1806 | VM_BUG_ON(from == to); | 1807 | VM_BUG_ON(from == to); |
| 1807 | VM_BUG_ON(PageLRU(pc->page)); | 1808 | VM_BUG_ON(PageLRU(pc->page)); |
| 1808 | VM_BUG_ON(!PageCgroupLocked(pc)); | 1809 | VM_BUG_ON(!PageCgroupLocked(pc)); |
| 1809 | VM_BUG_ON(!PageCgroupUsed(pc)); | 1810 | VM_BUG_ON(!PageCgroupUsed(pc)); |
| 1810 | VM_BUG_ON(pc->mem_cgroup != from); | 1811 | VM_BUG_ON(pc->mem_cgroup != from); |
| 1811 | 1812 | ||
| 1812 | page = pc->page; | 1813 | if (PageCgroupFileMapped(pc)) { |
| 1813 | if (page_mapped(page) && !PageAnon(page)) { | ||
| 1814 | /* Update mapped_file data for mem_cgroup */ | 1814 | /* Update mapped_file data for mem_cgroup */ |
| 1815 | preempt_disable(); | 1815 | preempt_disable(); |
| 1816 | __this_cpu_dec(from->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); | 1816 | __this_cpu_dec(from->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); |
| @@ -3691,8 +3691,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void) | |||
| 3691 | else | 3691 | else |
| 3692 | mem = vmalloc(size); | 3692 | mem = vmalloc(size); |
| 3693 | 3693 | ||
| 3694 | if (mem) | 3694 | if (!mem) |
| 3695 | memset(mem, 0, size); | 3695 | return NULL; |
| 3696 | |||
| 3697 | memset(mem, 0, size); | ||
| 3696 | mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu); | 3698 | mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu); |
| 3697 | if (!mem->stat) { | 3699 | if (!mem->stat) { |
| 3698 | if (size < PAGE_SIZE) | 3700 | if (size < PAGE_SIZE) |
| @@ -3946,28 +3948,6 @@ one_by_one: | |||
| 3946 | } | 3948 | } |
| 3947 | return ret; | 3949 | return ret; |
| 3948 | } | 3950 | } |
| 3949 | #else /* !CONFIG_MMU */ | ||
| 3950 | static int mem_cgroup_can_attach(struct cgroup_subsys *ss, | ||
| 3951 | struct cgroup *cgroup, | ||
| 3952 | struct task_struct *p, | ||
| 3953 | bool threadgroup) | ||
| 3954 | { | ||
| 3955 | return 0; | ||
| 3956 | } | ||
| 3957 | static void mem_cgroup_cancel_attach(struct cgroup_subsys *ss, | ||
| 3958 | struct cgroup *cgroup, | ||
| 3959 | struct task_struct *p, | ||
| 3960 | bool threadgroup) | ||
| 3961 | { | ||
| 3962 | } | ||
| 3963 | static void mem_cgroup_move_task(struct cgroup_subsys *ss, | ||
| 3964 | struct cgroup *cont, | ||
| 3965 | struct cgroup *old_cont, | ||
| 3966 | struct task_struct *p, | ||
| 3967 | bool threadgroup) | ||
| 3968 | { | ||
| 3969 | } | ||
| 3970 | #endif | ||
| 3971 | 3951 | ||
| 3972 | /** | 3952 | /** |
| 3973 | * is_target_pte_for_mc - check a pte whether it is valid for move charge | 3953 | * is_target_pte_for_mc - check a pte whether it is valid for move charge |
| @@ -4330,6 +4310,28 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss, | |||
| 4330 | } | 4310 | } |
| 4331 | mem_cgroup_clear_mc(); | 4311 | mem_cgroup_clear_mc(); |
| 4332 | } | 4312 | } |
| 4313 | #else /* !CONFIG_MMU */ | ||
| 4314 | static int mem_cgroup_can_attach(struct cgroup_subsys *ss, | ||
| 4315 | struct cgroup *cgroup, | ||
| 4316 | struct task_struct *p, | ||
| 4317 | bool threadgroup) | ||
| 4318 | { | ||
| 4319 | return 0; | ||
| 4320 | } | ||
| 4321 | static void mem_cgroup_cancel_attach(struct cgroup_subsys *ss, | ||
| 4322 | struct cgroup *cgroup, | ||
| 4323 | struct task_struct *p, | ||
| 4324 | bool threadgroup) | ||
| 4325 | { | ||
| 4326 | } | ||
| 4327 | static void mem_cgroup_move_task(struct cgroup_subsys *ss, | ||
| 4328 | struct cgroup *cont, | ||
| 4329 | struct cgroup *old_cont, | ||
| 4330 | struct task_struct *p, | ||
| 4331 | bool threadgroup) | ||
| 4332 | { | ||
| 4333 | } | ||
| 4334 | #endif | ||
| 4333 | 4335 | ||
| 4334 | struct cgroup_subsys mem_cgroup_subsys = { | 4336 | struct cgroup_subsys mem_cgroup_subsys = { |
| 4335 | .name = "memory", | 4337 | .name = "memory", |
