Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751103AbdFPP50 (ORCPT ); Fri, 16 Jun 2017 11:57:26 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33822 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750837AbdFPP5Z (ORCPT ); Fri, 16 Jun 2017 11:57:25 -0400 Subject: Re: [PATCHv2 3/3] mm: Use updated pmdp_invalidate() inteface to track dirty/accessed bits To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Andrew Morton , Vlastimil Babka , Vineet Gupta , Russell King , Will Deacon , Catalin Marinas , Ralf Baechle , "David S. Miller" , Martin Schwidefsky , Heiko Carstens , Andrea Arcangeli , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20170615145224.66200-1-kirill.shutemov@linux.intel.com> <20170615145224.66200-4-kirill.shutemov@linux.intel.com> <87bmpob23x.fsf@skywalker.in.ibm.com> <20170616132143.cdr4qt5hzvgxsnek@node.shutemov.name> From: "Aneesh Kumar K.V" Date: Fri, 16 Jun 2017 21:27:04 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170616132143.cdr4qt5hzvgxsnek@node.shutemov.name> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17061615-0040-0000-0000-00000364642F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007243; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00875671; UDB=6.00436011; IPR=6.00655760; BA=6.00005425; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015853; XFM=3.00000015; UTC=2017-06-16 15:57:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17061615-0041-0000-0000-0000075876C9 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-16_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706160263 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2404 Lines: 71 On Friday 16 June 2017 06:51 PM, Kirill A. Shutemov wrote: > On Fri, Jun 16, 2017 at 05:01:30PM +0530, Aneesh Kumar K.V wrote: >> "Kirill A. Shutemov" writes: >> >>> This patch uses modifed pmdp_invalidate(), that return previous value of pmd, >>> to transfer dirty and accessed bits. >>> >>> Signed-off-by: Kirill A. Shutemov >>> --- >>> fs/proc/task_mmu.c | 8 ++++---- >>> mm/huge_memory.c | 29 ++++++++++++----------------- >>> 2 files changed, 16 insertions(+), 21 deletions(-) >>> >>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c >>> index f0c8b33d99b1..f2fc1ef5bba2 100644 >>> --- a/fs/proc/task_mmu.c >>> +++ b/fs/proc/task_mmu.c >> >> ..... >> >>> @@ -1965,7 +1955,6 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, >>> page_ref_add(page, HPAGE_PMD_NR - 1); >>> write = pmd_write(*pmd); >>> young = pmd_young(*pmd); >>> - dirty = pmd_dirty(*pmd); >>> soft_dirty = pmd_soft_dirty(*pmd); >>> >>> pmdp_huge_split_prepare(vma, haddr, pmd); >>> @@ -1995,8 +1984,6 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, >>> if (soft_dirty) >>> entry = pte_mksoft_dirty(entry); >>> } >>> - if (dirty) >>> - SetPageDirty(page + i); >>> pte = pte_offset_map(&_pmd, addr); >>> BUG_ON(!pte_none(*pte)); >>> set_pte_at(mm, addr, pte, entry); >>> @@ -2045,7 +2032,15 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, >>> * and finally we write the non-huge version of the pmd entry with >>> * pmd_populate. >>> */ >>> - pmdp_invalidate(vma, haddr, pmd); >>> + old = pmdp_invalidate(vma, haddr, pmd); >>> + >>> + /* >>> + * Transfer dirty bit using value returned by pmd_invalidate() to be >>> + * sure we don't race with CPU that can set the bit under us. >>> + */ >>> + if (pmd_dirty(old)) >>> + SetPageDirty(page); >>> + >>> pmd_populate(mm, pmd, pgtable); >>> >>> if (freeze) { >> >> >> Can we invalidate the pmd early here ? ie, do pmdp_invalidate instead of >> pmdp_huge_split_prepare() ? > > I think we can. But it means we would block access to the page for longer > than it's necessary on most architectures. I guess it's not a bit deal. > > Maybe as separate patch on top of this patchet? Aneesh, would you take > care of this? > Yes, I cam do that. -aneesh