From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C605C433B4 for ; Thu, 20 May 2021 16:57:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B42E06139A for ; Thu, 20 May 2021 16:57:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B42E06139A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 095658E0018; Thu, 20 May 2021 12:57:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0453B8E0012; Thu, 20 May 2021 12:57:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E28D98E0018; Thu, 20 May 2021 12:57:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id ABE088E0012 for ; Thu, 20 May 2021 12:57:52 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4991C181CE284 for ; Thu, 20 May 2021 16:57:52 +0000 (UTC) X-FDA: 78162216384.07.EC10A3B Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf19.hostedemail.com (Postfix) with ESMTP id E1EAC90009E8 for ; Thu, 20 May 2021 16:57:49 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14KGqWoG061182; Thu, 20 May 2021 12:57:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=cfQLE8HF+3AM3vrFgjccyXBBWt/ybBDPFnX9Yd9rGEA=; b=By4/X0opsDhXrJ/HI19SFn3ixf/cxgN+EsJidDuUUZvfh+a8NRZlMrvjF6hk7suuztYX suYSZKywhozEGYYcK5enj8Fm8wsJMvYrDTrKBS3dM8vJtZORKGzxq01HA+SmHFBJpzq2 tXEc8LCqEb4bOjrgYX1gutytV+CZYh/MLRAW1F5mZBciEcsRVZKDYSs9LxKxzpW02kjP HVVS2VfpZHS/fg5fq6/9c47ByuhrdDRRysASJg5C7DWzrSRR8kfNaBk9bOx2K8PZT0u9 /soWLoEe3yv+ORNdkhFgcz2jFXNt1Y2l0p+yIYPZ5bKtPk4SLbB5GOMbl7+mF2GZn9k0 sA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 38nup2g4am-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:57:41 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14KGrP3c064648; Thu, 20 May 2021 12:57:40 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 38nup2g4a6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:57:40 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14KGs5eL019311; Thu, 20 May 2021 16:57:38 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 38j5x8arpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 16:57:38 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14KGvaZw43778376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 16:57:36 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 641E1A4059; Thu, 20 May 2021 16:57:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE761A405B; Thu, 20 May 2021 16:57:34 +0000 (GMT) Received: from [9.85.101.109] (unknown [9.85.101.109]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 May 2021 16:57:34 +0000 (GMT) Subject: Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, Linus Torvalds Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, kaleshsingh@google.com, npiggin@gmail.com, joel@joelfernandes.org, Christophe Leroy References: <20210422054323.150993-1-aneesh.kumar@linux.ibm.com> <20210422054323.150993-8-aneesh.kumar@linux.ibm.com> Message-ID: <2eafd7df-65fd-1e2c-90b6-d143557a1fdc@linux.ibm.com> Date: Thu, 20 May 2021 22:27:34 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ExskthO9l_Z2NfP3RUXFRzYUNUEinfe8 X-Proofpoint-ORIG-GUID: OEyK6RiwlU8sr1wSYV8Ct_-BEhQlxWi7 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-20_04:2021-05-20,2021-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200107 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="By4/X0op"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf19.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E1EAC90009E8 X-Stat-Signature: afo8uh318xoedq5rnxa6rg1bc4rqunga X-HE-Tag: 1621529869-849792 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 5/20/21 8:56 PM, Aneesh Kumar K.V wrote: > On 4/22/21 11:13 AM, Aneesh Kumar K.V wrote: >> Move TLB flush outside page table lock so that kernel does >> less with page table lock held. Releasing the ptl with old >> TLB contents still valid will behave such that such access >> happened before the level3 or level2 entry update. >> >=20 >=20 > Ok this break the page lifetime rule >=20 > commit: eb66ae030829 ("mremap: properly flush TLB before releasing the=20 > page") >=20 > I will respin dropping this change and add a comment around explaining=20 > why we need to do tlb flush before dropping ptl. Wondering whether this is correct considering we are holding mmap_sem in=20 write mode in mremap. Can a parallel free/zap happen? >=20 >> Signed-off-by: Aneesh Kumar K.V >> --- >> =C2=A0 mm/mremap.c | 8 ++++---- >> =C2=A0 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/mremap.c b/mm/mremap.c >> index 109560977944..9effca76bf17 100644 >> --- a/mm/mremap.c >> +++ b/mm/mremap.c >> @@ -258,7 +258,7 @@ static bool move_normal_pmd(struct vm_area_struct=20 >> *vma, unsigned long old_addr, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * We don't have to worry about th= e ordering of src and dst >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * ptlocks because exclusive mmap_= lock prevents deadlock. >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >> -=C2=A0=C2=A0=C2=A0 old_ptl =3D pmd_lock(vma->vm_mm, old_pmd); >> +=C2=A0=C2=A0=C2=A0 old_ptl =3D pmd_lock(mm, old_pmd); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 new_ptl =3D pmd_lockptr(mm, new_pmd); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (new_ptl !=3D old_ptl) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_lock_neste= d(new_ptl, SINGLE_DEPTH_NESTING); >> @@ -270,11 +270,11 @@ static bool move_normal_pmd(struct=20 >> vm_area_struct *vma, unsigned long old_addr, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 VM_BUG_ON(!pmd_none(*new_pmd)); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pmd_populate(mm, new_pmd, (pgtable_t)pm= d_page_vaddr(pmd)); >> -=C2=A0=C2=A0=C2=A0 flush_pte_tlb_pwc_range(vma, old_addr, old_addr + = PMD_SIZE); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (new_ptl !=3D old_ptl) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock(new= _ptl); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock(old_ptl); >> +=C2=A0=C2=A0=C2=A0 flush_pte_tlb_pwc_range(vma, old_addr, old_addr + = PMD_SIZE); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return true; >> =C2=A0 } >> =C2=A0 #else >> @@ -305,7 +305,7 @@ static bool move_normal_pud(struct vm_area_struct=20 >> *vma, unsigned long old_addr, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * We don't have to worry about th= e ordering of src and dst >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * ptlocks because exclusive mmap_= lock prevents deadlock. >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >> -=C2=A0=C2=A0=C2=A0 old_ptl =3D pud_lock(vma->vm_mm, old_pud); >> +=C2=A0=C2=A0=C2=A0 old_ptl =3D pud_lock(mm, old_pud); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 new_ptl =3D pud_lockptr(mm, new_pud); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (new_ptl !=3D old_ptl) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_lock_neste= d(new_ptl, SINGLE_DEPTH_NESTING); >> @@ -317,11 +317,11 @@ static bool move_normal_pud(struct=20 >> vm_area_struct *vma, unsigned long old_addr, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 VM_BUG_ON(!pud_none(*new_pud)); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pud_populate(mm, new_pud, (pmd_t *)pud_= page_vaddr(pud)); >> -=C2=A0=C2=A0=C2=A0 flush_pte_tlb_pwc_range(vma, old_addr, old_addr + = PUD_SIZE); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (new_ptl !=3D old_ptl) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock(new= _ptl); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock(old_ptl); >> +=C2=A0=C2=A0=C2=A0 flush_pte_tlb_pwc_range(vma, old_addr, old_addr + = PUD_SIZE); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return true; >> =C2=A0 } >> =C2=A0 #else >> >=20 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C746C433B4 for ; Thu, 20 May 2021 16:58:26 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A13BD61353 for ; Thu, 20 May 2021 16:58:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A13BD61353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FmGCN0W59z3btD for ; Fri, 21 May 2021 02:58:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=By4/X0op; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=aneesh.kumar@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=By4/X0op; dkim-atps=neutral Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FmGBq38yYz301p for ; Fri, 21 May 2021 02:57:54 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14KGqWoG061182; Thu, 20 May 2021 12:57:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=cfQLE8HF+3AM3vrFgjccyXBBWt/ybBDPFnX9Yd9rGEA=; b=By4/X0opsDhXrJ/HI19SFn3ixf/cxgN+EsJidDuUUZvfh+a8NRZlMrvjF6hk7suuztYX suYSZKywhozEGYYcK5enj8Fm8wsJMvYrDTrKBS3dM8vJtZORKGzxq01HA+SmHFBJpzq2 tXEc8LCqEb4bOjrgYX1gutytV+CZYh/MLRAW1F5mZBciEcsRVZKDYSs9LxKxzpW02kjP HVVS2VfpZHS/fg5fq6/9c47ByuhrdDRRysASJg5C7DWzrSRR8kfNaBk9bOx2K8PZT0u9 /soWLoEe3yv+ORNdkhFgcz2jFXNt1Y2l0p+yIYPZ5bKtPk4SLbB5GOMbl7+mF2GZn9k0 sA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 38nup2g4am-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:57:41 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14KGrP3c064648; Thu, 20 May 2021 12:57:40 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 38nup2g4a6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:57:40 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14KGs5eL019311; Thu, 20 May 2021 16:57:38 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 38j5x8arpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 16:57:38 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14KGvaZw43778376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 16:57:36 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 641E1A4059; Thu, 20 May 2021 16:57:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE761A405B; Thu, 20 May 2021 16:57:34 +0000 (GMT) Received: from [9.85.101.109] (unknown [9.85.101.109]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 May 2021 16:57:34 +0000 (GMT) Subject: Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, Linus Torvalds References: <20210422054323.150993-1-aneesh.kumar@linux.ibm.com> <20210422054323.150993-8-aneesh.kumar@linux.ibm.com> Message-ID: <2eafd7df-65fd-1e2c-90b6-d143557a1fdc@linux.ibm.com> Date: Thu, 20 May 2021 22:27:34 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ExskthO9l_Z2NfP3RUXFRzYUNUEinfe8 X-Proofpoint-ORIG-GUID: OEyK6RiwlU8sr1wSYV8Ct_-BEhQlxWi7 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-20_04:2021-05-20, 2021-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200107 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: npiggin@gmail.com, kaleshsingh@google.com, joel@joelfernandes.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 5/20/21 8:56 PM, Aneesh Kumar K.V wrote: > On 4/22/21 11:13 AM, Aneesh Kumar K.V wrote: >> Move TLB flush outside page table lock so that kernel does >> less with page table lock held. Releasing the ptl with old >> TLB contents still valid will behave such that such access >> happened before the level3 or level2 entry update. >> > > > Ok this break the page lifetime rule > > commit: eb66ae030829 ("mremap: properly flush TLB before releasing the > page") > > I will respin dropping this change and add a comment around explaining > why we need to do tlb flush before dropping ptl. Wondering whether this is correct considering we are holding mmap_sem in write mode in mremap. Can a parallel free/zap happen? > >> Signed-off-by: Aneesh Kumar K.V >> --- >>   mm/mremap.c | 8 ++++---- >>   1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/mremap.c b/mm/mremap.c >> index 109560977944..9effca76bf17 100644 >> --- a/mm/mremap.c >> +++ b/mm/mremap.c >> @@ -258,7 +258,7 @@ static bool move_normal_pmd(struct vm_area_struct >> *vma, unsigned long old_addr, >>        * We don't have to worry about the ordering of src and dst >>        * ptlocks because exclusive mmap_lock prevents deadlock. >>        */ >> -    old_ptl = pmd_lock(vma->vm_mm, old_pmd); >> +    old_ptl = pmd_lock(mm, old_pmd); >>       new_ptl = pmd_lockptr(mm, new_pmd); >>       if (new_ptl != old_ptl) >>           spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING); >> @@ -270,11 +270,11 @@ static bool move_normal_pmd(struct >> vm_area_struct *vma, unsigned long old_addr, >>       VM_BUG_ON(!pmd_none(*new_pmd)); >>       pmd_populate(mm, new_pmd, (pgtable_t)pmd_page_vaddr(pmd)); >> -    flush_pte_tlb_pwc_range(vma, old_addr, old_addr + PMD_SIZE); >>       if (new_ptl != old_ptl) >>           spin_unlock(new_ptl); >>       spin_unlock(old_ptl); >> +    flush_pte_tlb_pwc_range(vma, old_addr, old_addr + PMD_SIZE); >>       return true; >>   } >>   #else >> @@ -305,7 +305,7 @@ static bool move_normal_pud(struct vm_area_struct >> *vma, unsigned long old_addr, >>        * We don't have to worry about the ordering of src and dst >>        * ptlocks because exclusive mmap_lock prevents deadlock. >>        */ >> -    old_ptl = pud_lock(vma->vm_mm, old_pud); >> +    old_ptl = pud_lock(mm, old_pud); >>       new_ptl = pud_lockptr(mm, new_pud); >>       if (new_ptl != old_ptl) >>           spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING); >> @@ -317,11 +317,11 @@ static bool move_normal_pud(struct >> vm_area_struct *vma, unsigned long old_addr, >>       VM_BUG_ON(!pud_none(*new_pud)); >>       pud_populate(mm, new_pud, (pmd_t *)pud_page_vaddr(pud)); >> -    flush_pte_tlb_pwc_range(vma, old_addr, old_addr + PUD_SIZE); >>       if (new_ptl != old_ptl) >>           spin_unlock(new_ptl); >>       spin_unlock(old_ptl); >> +    flush_pte_tlb_pwc_range(vma, old_addr, old_addr + PUD_SIZE); >>       return true; >>   } >>   #else >> >