The patch titled Subject: memcg: separate mem_cgroup_move_charge_pte_range() has been removed from the -mm tree. Its filename was memcg-separate-mem_cgroup_move_charge_pte_range.patch This patch was dropped because it was nacked ------------------------------------------------------ From: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Subject: memcg: separate mem_cgroup_move_charge_pte_range() mem_cgroup_move_charge_pte_range() handles both pte and pmd, which is not standardized, so let's cleanup it. One tricky part is the retry, which is performed when we detect !mc.precharge. In such case we retry the same entry, so we don't have to go outside the pte loop. With rewriting this retry in the pte loop, we can separate pmd_entry() and pte_entry(), which is what we need. Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx> Cc: Pavel Emelyanov <xemul@xxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 128 +++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 62 deletions(-) diff -puN mm/memcontrol.c~memcg-separate-mem_cgroup_move_charge_pte_range mm/memcontrol.c --- a/mm/memcontrol.c~memcg-separate-mem_cgroup_move_charge_pte_range +++ a/mm/memcontrol.c @@ -6821,14 +6821,72 @@ static void mem_cgroup_cancel_attach(str mem_cgroup_clear_mc(); } -static int mem_cgroup_move_charge_pte_range(pmd_t *pmd, +static int mem_cgroup_move_charge_pte(pte_t *pte, unsigned long addr, unsigned long end, struct mm_walk *walk) { int ret = 0; struct vm_area_struct *vma = walk->vma; - pte_t *pte; - spinlock_t *ptl; + union mc_target target; + struct page *page; + struct page_cgroup *pc; + swp_entry_t ent; + +retry: + if (!mc.precharge) { + pte_t *orig_pte = pte - ((addr & (PMD_SIZE - 1)) >> PAGE_SHIFT); + pte_unmap_unlock(orig_pte, walk->ptl); + cond_resched(); + /* + * We have consumed all precharges we got in can_attach(). + * We try charge one by one, but don't do any additional + * charges to mc.to if we have failed in charge once in attach() + * phase. + */ + ret = mem_cgroup_do_precharge(1); + pte_offset_map(walk->pmd, addr & PMD_MASK); + spin_lock(walk->ptl); + if (!ret) + goto retry; + return ret; + } + + switch (get_mctgt_type(vma, addr, *pte, &target)) { + case MC_TARGET_PAGE: + page = target.page; + if (isolate_lru_page(page)) + goto put; + pc = lookup_page_cgroup(page); + if (!mem_cgroup_move_account(page, 1, pc, + mc.from, mc.to)) { + mc.precharge--; + /* we uncharge from mc.from later. */ + mc.moved_charge++; + } + putback_lru_page(page); +put: /* get_mctgt_type() gets the page */ + put_page(page); + break; + case MC_TARGET_SWAP: + ent = target.ent; + if (!mem_cgroup_move_swap_account(ent, mc.from, mc.to)) { + mc.precharge--; + /* we fixup refcnts and charges later. */ + mc.moved_swap++; + } + break; + default: + break; + } + + return 0; +} + +static int mem_cgroup_move_charge_pmd(pmd_t *pmd, + unsigned long addr, unsigned long end, + struct mm_walk *walk) +{ + struct vm_area_struct *vma = walk->vma; enum mc_target_type target_type; union mc_target target; struct page *page; @@ -6864,71 +6922,17 @@ static int mem_cgroup_move_charge_pte_ra put_page(page); } spin_unlock(ptl); - return 0; - } - - if (pmd_trans_unstable(pmd)) - return 0; -retry: - pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); - for (; addr != end; addr += PAGE_SIZE) { - pte_t ptent = *(pte++); - swp_entry_t ent; - - if (!mc.precharge) - break; - - switch (get_mctgt_type(vma, addr, ptent, &target)) { - case MC_TARGET_PAGE: - page = target.page; - if (isolate_lru_page(page)) - goto put; - pc = lookup_page_cgroup(page); - if (!mem_cgroup_move_account(page, 1, pc, - mc.from, mc.to)) { - mc.precharge--; - /* we uncharge from mc.from later. */ - mc.moved_charge++; - } - putback_lru_page(page); -put: /* get_mctgt_type() gets the page */ - put_page(page); - break; - case MC_TARGET_SWAP: - ent = target.ent; - if (!mem_cgroup_move_swap_account(ent, mc.from, mc.to)) { - mc.precharge--; - /* we fixup refcnts and charges later. */ - mc.moved_swap++; - } - break; - default: - break; - } - } - pte_unmap_unlock(pte - 1, ptl); - cond_resched(); - - if (addr != end) { - /* - * We have consumed all precharges we got in can_attach(). - * We try charge one by one, but don't do any additional - * charges to mc.to if we have failed in charge once in attach() - * phase. - */ - ret = mem_cgroup_do_precharge(1); - if (!ret) - goto retry; - } - - return ret; + } else + walk->control = PTWALK_DOWN; + return 0; } static void mem_cgroup_move_charge(struct mm_struct *mm) { struct vm_area_struct *vma; struct mm_walk mem_cgroup_move_charge_walk = { - .pmd_entry = mem_cgroup_move_charge_pte_range, + .pmd_entry = mem_cgroup_move_charge_pmd, + .pte_entry = mem_cgroup_move_charge_pte, .mm = mm, }; _ Patches currently in -mm which might be from n-horiguchi@xxxxxxxxxxxxx are hwpoison-fix-the-handling-path-of-the-victimized-page-frame-that-belong-to-non-lur.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v2.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3-fix.patch memcg-separate-mem_cgroup_move_charge_pte_range-checkpatch-fixes.patch arch-powerpc-mm-subpage-protc-cleanup-subpage_walk_pmd_entry.patch mm-pagewalk-move-pmd_trans_huge_lock-from-callbacks-to-common-code.patch mm-pagewalk-move-pmd_trans_huge_lock-from-callbacks-to-common-code-checkpatch-fixes.patch mincore-apply-page-table-walker-on-do_mincore.patch mincore-apply-page-table-walker-on-do_mincore-fix.patch mm-introduce-do_shared_fault-and-drop-do_fault-fix-fix.patch do_shared_fault-check-that-mmap_sem-is-held.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html