aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2012-03-21 19:34:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 20:55:02 -0400
commit8d32ff84401f1addb961c7af2c8d9baceb0ab9ba (patch)
treebf62513b239dce072f0105c0b06ed694634a77d4
parenta488428871265979bcf2c46298a04c1d5826e6cb (diff)
memcg: clean up existing move charge code
- Replace lengthy function name is_target_pte_for_mc() with a shorter one in order to avoid ugly line breaks. - explicitly use MC_TARGET_* instead of simply using integers. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Hillf Danton <dhillf@gmail.com> Cc: David Rientjes <rientjes@google.com> Acked-by: Hillf Danton <dhillf@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memcontrol.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 61102938f119..c8d00a9780bc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5110,7 +5110,7 @@ one_by_one:
5110} 5110}
5111 5111
5112/** 5112/**
5113 * is_target_pte_for_mc - check a pte whether it is valid for move charge 5113 * get_mctgt_type - get target type of moving charge
5114 * @vma: the vma the pte to be checked belongs 5114 * @vma: the vma the pte to be checked belongs
5115 * @addr: the address corresponding to the pte to be checked 5115 * @addr: the address corresponding to the pte to be checked
5116 * @ptent: the pte to be checked 5116 * @ptent: the pte to be checked
@@ -5133,7 +5133,7 @@ union mc_target {
5133}; 5133};
5134 5134
5135enum mc_target_type { 5135enum mc_target_type {
5136 MC_TARGET_NONE, /* not used */ 5136 MC_TARGET_NONE = 0,
5137 MC_TARGET_PAGE, 5137 MC_TARGET_PAGE,
5138 MC_TARGET_SWAP, 5138 MC_TARGET_SWAP,
5139}; 5139};
@@ -5214,12 +5214,12 @@ static struct page *mc_handle_file_pte(struct vm_area_struct *vma,
5214 return page; 5214 return page;
5215} 5215}
5216 5216
5217static int is_target_pte_for_mc(struct vm_area_struct *vma, 5217static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
5218 unsigned long addr, pte_t ptent, union mc_target *target) 5218 unsigned long addr, pte_t ptent, union mc_target *target)
5219{ 5219{
5220 struct page *page = NULL; 5220 struct page *page = NULL;
5221 struct page_cgroup *pc; 5221 struct page_cgroup *pc;
5222 int ret = 0; 5222 enum mc_target_type ret = MC_TARGET_NONE;
5223 swp_entry_t ent = { .val = 0 }; 5223 swp_entry_t ent = { .val = 0 };
5224 5224
5225 if (pte_present(ptent)) 5225 if (pte_present(ptent))
@@ -5230,7 +5230,7 @@ static int is_target_pte_for_mc(struct vm_area_struct *vma,
5230 page = mc_handle_file_pte(vma, addr, ptent, &ent); 5230 page = mc_handle_file_pte(vma, addr, ptent, &ent);
5231 5231
5232 if (!page && !ent.val) 5232 if (!page && !ent.val)
5233 return 0; 5233 return ret;
5234 if (page) { 5234 if (page) {
5235 pc = lookup_page_cgroup(page); 5235 pc = lookup_page_cgroup(page);
5236 /* 5236 /*
@@ -5270,7 +5270,7 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
5270 5270
5271 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 5271 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
5272 for (; addr != end; pte++, addr += PAGE_SIZE) 5272 for (; addr != end; pte++, addr += PAGE_SIZE)
5273 if (is_target_pte_for_mc(vma, addr, *pte, NULL)) 5273 if (get_mctgt_type(vma, addr, *pte, NULL))
5274 mc.precharge++; /* increment precharge temporarily */ 5274 mc.precharge++; /* increment precharge temporarily */
5275 pte_unmap_unlock(pte - 1, ptl); 5275 pte_unmap_unlock(pte - 1, ptl);
5276 cond_resched(); 5276 cond_resched();
@@ -5442,8 +5442,7 @@ retry:
5442 if (!mc.precharge) 5442 if (!mc.precharge)
5443 break; 5443 break;
5444 5444
5445 type = is_target_pte_for_mc(vma, addr, ptent, &target); 5445 switch (get_mctgt_type(vma, addr, ptent, &target)) {
5446 switch (type) {
5447 case MC_TARGET_PAGE: 5446 case MC_TARGET_PAGE:
5448 page = target.page; 5447 page = target.page;
5449 if (isolate_lru_page(page)) 5448 if (isolate_lru_page(page))
@@ -5456,7 +5455,7 @@ retry:
5456 mc.moved_charge++; 5455 mc.moved_charge++;
5457 } 5456 }
5458 putback_lru_page(page); 5457 putback_lru_page(page);
5459put: /* is_target_pte_for_mc() gets the page */ 5458put: /* get_mctgt_type() gets the page */
5460 put_page(page); 5459 put_page(page);
5461 break; 5460 break;
5462 case MC_TARGET_SWAP: 5461 case MC_TARGET_SWAP: