From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yk0-f176.google.com (mail-yk0-f176.google.com [209.85.160.176]) by kanga.kvack.org (Postfix) with ESMTP id 28665800CA for ; Fri, 7 Nov 2014 02:05:41 -0500 (EST) Received: by mail-yk0-f176.google.com with SMTP id 9so323898ykp.7 for ; Thu, 06 Nov 2014 23:05:40 -0800 (PST) Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp. [210.143.35.52]) by mx.google.com with ESMTPS id o85si8482572yke.1.2014.11.06.23.05.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 06 Nov 2014 23:05:39 -0800 (PST) From: Naoya Horiguchi Subject: [PATCH -mm v7 12/13] mm: /proc/pid/clear_refs: avoid split_huge_page() Date: Fri, 7 Nov 2014 07:02:05 +0000 Message-ID: <1415343692-6314-13-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1415343692-6314-1-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1415343692-6314-1-git-send-email-n-horiguchi@ah.jp.nec.com> Content-Language: ja-JP Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Dave Hansen , Hugh Dickins , "Kirill A. Shutemov" , Peter Feiner , Jerome Marchand , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Naoya Horiguchi , "Kirill A. Shutemov" , Pavel Emelyanov , Andrea Arcangeli From: "Kirill A. Shutemov" Currently pagewalker splits all THP pages on any clear_refs request. It's not necessary. We can handle this on PMD level. One side effect is that soft dirty will potentially see more dirty memory, since we will mark whole THP page dirty at once. Sanity checked with CRIU test suite. More testing is required. Signed-off-by: Kirill A. Shutemov Cc: Pavel Emelyanov Cc: Andrea Arcangeli Cc: Dave Hansen Signed-off-by: Naoya Horiguchi Reviewed-by: Cyrill Gorcunov --- ChangeLog: - move code for thp to clear_refs_pte_range() --- fs/proc/task_mmu.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c mmotm-2014-11-05-= 16-01/fs/proc/task_mmu.c index e7d86b97598b..a6c1b75ed3c2 100644 --- mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c +++ mmotm-2014-11-05-16-01/fs/proc/task_mmu.c @@ -744,10 +744,10 @@ struct clear_refs_private { enum clear_refs_types type; }; =20 +#ifdef CONFIG_MEM_SOFT_DIRTY static inline void clear_soft_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *pte) { -#ifdef CONFIG_MEM_SOFT_DIRTY /* * The soft-dirty tracker uses #PF-s to catch writes * to pages, so write-protect the pte as well. See the @@ -766,9 +766,35 @@ static inline void clear_soft_dirty(struct vm_area_str= uct *vma, } =20 set_pte_at(vma->vm_mm, addr, pte, ptent); -#endif } =20 +static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, + unsigned long addr, pmd_t *pmdp) +{ + pmd_t pmd =3D *pmdp; + + pmd =3D pmd_wrprotect(pmd); + pmd =3D pmd_clear_flags(pmd, _PAGE_SOFT_DIRTY); + + if (vma->vm_flags & VM_SOFTDIRTY) + vma->vm_flags &=3D ~VM_SOFTDIRTY; + + set_pmd_at(vma->vm_mm, addr, pmdp, pmd); +} + +#else + +static inline void clear_soft_dirty(struct vm_area_struct *vma, + unsigned long addr, pte_t *pte) +{ +} + +static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, + unsigned long addr, pmd_t *pmdp) +{ +} +#endif + static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { @@ -778,7 +804,22 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned l= ong addr, spinlock_t *ptl; struct page *page; =20 - split_huge_page_pmd(vma, addr, pmd); + if (pmd_trans_huge_lock(pmd, vma, &ptl) =3D=3D 1) { + if (cp->type =3D=3D CLEAR_REFS_SOFT_DIRTY) { + clear_soft_dirty_pmd(vma, addr, pmd); + goto out; + } + + page =3D pmd_page(*pmd); + + /* Clear accessed and referenced bits. */ + pmdp_test_and_clear_young(vma, addr, pmd); + ClearPageReferenced(page); +out: + spin_unlock(ptl); + return 0; + } + if (pmd_trans_unstable(pmd)) return 0; =20 --=20 2.2.0.rc0.2.gf745acb -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org