mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
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>
This commit is contained in:
parent
a488428871
commit
8d32ff8440
1 changed files with 8 additions and 9 deletions
|
@ -5110,7 +5110,7 @@ one_by_one:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is_target_pte_for_mc - check a pte whether it is valid for move charge
|
* get_mctgt_type - get target type of moving charge
|
||||||
* @vma: the vma the pte to be checked belongs
|
* @vma: the vma the pte to be checked belongs
|
||||||
* @addr: the address corresponding to the pte to be checked
|
* @addr: the address corresponding to the pte to be checked
|
||||||
* @ptent: the pte to be checked
|
* @ptent: the pte to be checked
|
||||||
|
@ -5133,7 +5133,7 @@ union mc_target {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mc_target_type {
|
enum mc_target_type {
|
||||||
MC_TARGET_NONE, /* not used */
|
MC_TARGET_NONE = 0,
|
||||||
MC_TARGET_PAGE,
|
MC_TARGET_PAGE,
|
||||||
MC_TARGET_SWAP,
|
MC_TARGET_SWAP,
|
||||||
};
|
};
|
||||||
|
@ -5214,12 +5214,12 @@ static struct page *mc_handle_file_pte(struct vm_area_struct *vma,
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_target_pte_for_mc(struct vm_area_struct *vma,
|
static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
|
||||||
unsigned long addr, pte_t ptent, union mc_target *target)
|
unsigned long addr, pte_t ptent, union mc_target *target)
|
||||||
{
|
{
|
||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
struct page_cgroup *pc;
|
struct page_cgroup *pc;
|
||||||
int ret = 0;
|
enum mc_target_type ret = MC_TARGET_NONE;
|
||||||
swp_entry_t ent = { .val = 0 };
|
swp_entry_t ent = { .val = 0 };
|
||||||
|
|
||||||
if (pte_present(ptent))
|
if (pte_present(ptent))
|
||||||
|
@ -5230,7 +5230,7 @@ static int is_target_pte_for_mc(struct vm_area_struct *vma,
|
||||||
page = mc_handle_file_pte(vma, addr, ptent, &ent);
|
page = mc_handle_file_pte(vma, addr, ptent, &ent);
|
||||||
|
|
||||||
if (!page && !ent.val)
|
if (!page && !ent.val)
|
||||||
return 0;
|
return ret;
|
||||||
if (page) {
|
if (page) {
|
||||||
pc = lookup_page_cgroup(page);
|
pc = lookup_page_cgroup(page);
|
||||||
/*
|
/*
|
||||||
|
@ -5270,7 +5270,7 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
|
||||||
|
|
||||||
pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
|
pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
|
||||||
for (; addr != end; pte++, addr += PAGE_SIZE)
|
for (; addr != end; pte++, addr += PAGE_SIZE)
|
||||||
if (is_target_pte_for_mc(vma, addr, *pte, NULL))
|
if (get_mctgt_type(vma, addr, *pte, NULL))
|
||||||
mc.precharge++; /* increment precharge temporarily */
|
mc.precharge++; /* increment precharge temporarily */
|
||||||
pte_unmap_unlock(pte - 1, ptl);
|
pte_unmap_unlock(pte - 1, ptl);
|
||||||
cond_resched();
|
cond_resched();
|
||||||
|
@ -5442,8 +5442,7 @@ retry:
|
||||||
if (!mc.precharge)
|
if (!mc.precharge)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
type = is_target_pte_for_mc(vma, addr, ptent, &target);
|
switch (get_mctgt_type(vma, addr, ptent, &target)) {
|
||||||
switch (type) {
|
|
||||||
case MC_TARGET_PAGE:
|
case MC_TARGET_PAGE:
|
||||||
page = target.page;
|
page = target.page;
|
||||||
if (isolate_lru_page(page))
|
if (isolate_lru_page(page))
|
||||||
|
@ -5456,7 +5455,7 @@ retry:
|
||||||
mc.moved_charge++;
|
mc.moved_charge++;
|
||||||
}
|
}
|
||||||
putback_lru_page(page);
|
putback_lru_page(page);
|
||||||
put: /* is_target_pte_for_mc() gets the page */
|
put: /* get_mctgt_type() gets the page */
|
||||||
put_page(page);
|
put_page(page);
|
||||||
break;
|
break;
|
||||||
case MC_TARGET_SWAP:
|
case MC_TARGET_SWAP:
|
||||||
|
|
Loading…
Reference in a new issue