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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 CC4DDC04FF3 for ; Mon, 24 May 2021 14:24:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E4B061370 for ; Mon, 24 May 2021 14:24:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E4B061370 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 7D64994007F; Mon, 24 May 2021 10:24:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78586940076; Mon, 24 May 2021 10:24:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FF2A94007F; Mon, 24 May 2021 10:24:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 3008B940076 for ; Mon, 24 May 2021 10:24:27 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BCF84181AEF2A for ; Mon, 24 May 2021 14:24:26 +0000 (UTC) X-FDA: 78176344932.15.D832B98 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf28.hostedemail.com (Postfix) with ESMTP id 27D0A20007FD for ; Mon, 24 May 2021 14:24:20 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14OE3OYH134623; Mon, 24 May 2021 10:24:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=pxIaAJ92mI5tFdFim0kxWU+IPTOkELCdDbjv3/nxmg4=; b=GRkEB4xLNhjbhOdT1tLqqERerN85FwNnZigVm+hu271kQQVSwMyIuscV5pdXtIy7sLNC AQ/rJTfh0pjkV3WYTbAO4d/lUCTcpHBgxYEIVdkfMsK6DMovk9WCsZieJj5eUGN5XA4g sfYvEUD62WuHBXikUCXm6hSN5IhS2SjZlh0QTmFd1HXAhGEYGBIXQBI1kHl16Gar2q5U 5Fqvmzcu/K3uQdKib4+WqVV9VSG8ZBSw0QKtpaPjupK58H3Jz/wrVDC7xDveHOfIZTn5 eyRnPMrV3rZ8J6ZwpDLH8nK3KGDrR8O2SPirVwC1rLOq2lgQ2yEUVMtH7DFmrBPfl3vT uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 38rd9k956j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 10:24:15 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14OE3bJ2135855; Mon, 24 May 2021 10:24:15 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 38rd9k9569-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 10:24:15 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14OEN3Ia018629; Mon, 24 May 2021 14:24:14 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04dal.us.ibm.com with ESMTP id 38psk8ud0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 14:24:14 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14OEODQ416253314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 May 2021 14:24:13 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB169112066; Mon, 24 May 2021 14:24:13 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDF05112064; Mon, 24 May 2021 14:24:10 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.102.1.240]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 24 May 2021 14:24:10 +0000 (GMT) X-Mailer: emacs 28.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Linus Torvalds Cc: Linux-MM , Andrew Morton , Michael Ellerman , linuxppc-dev , Kalesh Singh , Nick Piggin , Joel Fernandes , Christophe Leroy Subject: Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock In-Reply-To: References: <20210422054323.150993-1-aneesh.kumar@linux.ibm.com> <20210422054323.150993-8-aneesh.kumar@linux.ibm.com> <2eafd7df-65fd-1e2c-90b6-d143557a1fdc@linux.ibm.com> <5ea8fa4f-a5a2-7dc4-7958-23df6a2c1f3a@linux.ibm.com> <874kewme7a.fsf@linux.ibm.com> Date: Mon, 24 May 2021 19:54:08 +0530 Message-ID: <87tumsqkfr.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ZwDxmbshmJiKJzduz-Vp-UWowKa_xPbc X-Proofpoint-ORIG-GUID: 1M4bzR3I_tB0C0NzJiVA5C8I5j4CGsjp X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-24_07:2021-05-24,2021-05-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105240086 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=GRkEB4xL; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.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: 27D0A20007FD X-Stat-Signature: bfrz379yqhsarkihhiqjfqn4gn6cr1zi X-HE-Tag: 1621866260-949072 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: Linus Torvalds writes: > On Fri, May 21, 2021 at 3:04 AM Aneesh Kumar K.V > wrote: >> >> We could do MOVE_PMD with something like below? A equivalent MOVE_PUD >> will be costlier which makes me wonder whether we should even support that? > > Well, without USE_SPLIT_PTE_PTLOCKS the pud case would be trivial too. > But everybody uses split pte locks in practice. > > I get the feeling that the rmap code might have to use > pud_lock/pmd_lock. I wonder how painful that would be. > Looking at this further, i guess we need to do the above to close the race window. We do static bool map_pte(struct page_vma_mapped_walk *pvmw) { pvmw->pte = pte_offset_map(pvmw->pmd, pvmw->address); .. pvmw->ptl = pte_lockptr(pvmw->vma->vm_mm, pvmw->pmd); spin_lock(pvmw->ptl); } That is we walk the table without holding the pte ptl. Hence we still can race with the optimized PMD move. -aneesh 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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 22C1FC04FF3 for ; Mon, 24 May 2021 14:25:00 +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 9896A6108E for ; Mon, 24 May 2021 14:24:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9896A6108E 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 4FpfcV0rPPz3bsq for ; Tue, 25 May 2021 00:24:58 +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=GRkEB4xL; 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=mx0a-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=GRkEB4xL; dkim-atps=neutral Received: from mx0a-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 4Fpfby2Ly1z2yQy for ; Tue, 25 May 2021 00:24:29 +1000 (AEST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14OE3OYH134623; Mon, 24 May 2021 10:24:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=pxIaAJ92mI5tFdFim0kxWU+IPTOkELCdDbjv3/nxmg4=; b=GRkEB4xLNhjbhOdT1tLqqERerN85FwNnZigVm+hu271kQQVSwMyIuscV5pdXtIy7sLNC AQ/rJTfh0pjkV3WYTbAO4d/lUCTcpHBgxYEIVdkfMsK6DMovk9WCsZieJj5eUGN5XA4g sfYvEUD62WuHBXikUCXm6hSN5IhS2SjZlh0QTmFd1HXAhGEYGBIXQBI1kHl16Gar2q5U 5Fqvmzcu/K3uQdKib4+WqVV9VSG8ZBSw0QKtpaPjupK58H3Jz/wrVDC7xDveHOfIZTn5 eyRnPMrV3rZ8J6ZwpDLH8nK3KGDrR8O2SPirVwC1rLOq2lgQ2yEUVMtH7DFmrBPfl3vT uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 38rd9k956j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 10:24:15 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14OE3bJ2135855; Mon, 24 May 2021 10:24:15 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 38rd9k9569-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 10:24:15 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14OEN3Ia018629; Mon, 24 May 2021 14:24:14 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04dal.us.ibm.com with ESMTP id 38psk8ud0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 14:24:14 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14OEODQ416253314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 May 2021 14:24:13 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB169112066; Mon, 24 May 2021 14:24:13 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDF05112064; Mon, 24 May 2021 14:24:10 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.102.1.240]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 24 May 2021 14:24:10 +0000 (GMT) X-Mailer: emacs 28.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Linus Torvalds Subject: Re: [PATCH v5 7/9] mm/mremap: Move TLB flush outside page table lock In-Reply-To: References: <20210422054323.150993-1-aneesh.kumar@linux.ibm.com> <20210422054323.150993-8-aneesh.kumar@linux.ibm.com> <2eafd7df-65fd-1e2c-90b6-d143557a1fdc@linux.ibm.com> <5ea8fa4f-a5a2-7dc4-7958-23df6a2c1f3a@linux.ibm.com> <874kewme7a.fsf@linux.ibm.com> Date: Mon, 24 May 2021 19:54:08 +0530 Message-ID: <87tumsqkfr.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ZwDxmbshmJiKJzduz-Vp-UWowKa_xPbc X-Proofpoint-ORIG-GUID: 1M4bzR3I_tB0C0NzJiVA5C8I5j4CGsjp X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-24_07:2021-05-24, 2021-05-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105240086 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: Nick Piggin , Linux-MM , Kalesh Singh , Joel Fernandes , Andrew Morton , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Linus Torvalds writes: > On Fri, May 21, 2021 at 3:04 AM Aneesh Kumar K.V > wrote: >> >> We could do MOVE_PMD with something like below? A equivalent MOVE_PUD >> will be costlier which makes me wonder whether we should even support that? > > Well, without USE_SPLIT_PTE_PTLOCKS the pud case would be trivial too. > But everybody uses split pte locks in practice. > > I get the feeling that the rmap code might have to use > pud_lock/pmd_lock. I wonder how painful that would be. > Looking at this further, i guess we need to do the above to close the race window. We do static bool map_pte(struct page_vma_mapped_walk *pvmw) { pvmw->pte = pte_offset_map(pvmw->pmd, pvmw->address); .. pvmw->ptl = pte_lockptr(pvmw->vma->vm_mm, pvmw->pmd); spin_lock(pvmw->ptl); } That is we walk the table without holding the pte ptl. Hence we still can race with the optimized PMD move. -aneesh