From patchwork Tue Feb 20 03:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mawupeng X-Patchwork-Id: 13563360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFB19C48BC3 for ; Tue, 20 Feb 2024 03:48:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B11D36B0085; Mon, 19 Feb 2024 22:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABF518D0003; Mon, 19 Feb 2024 22:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AEA06B0087; Mon, 19 Feb 2024 22:48:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8E0716B007B for ; Mon, 19 Feb 2024 22:48:47 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5413140554 for ; Tue, 20 Feb 2024 03:48:47 +0000 (UTC) X-FDA: 81810800694.21.7A5ECA9 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id BF45640007 for ; Tue, 20 Feb 2024 03:48:44 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708400925; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fr65SOWCv23X2MiY+qvdBo27LS6DAuaxHnQjCbyPxrg=; b=CGyN8vI25imCAxuQ2306712bdUQomZ3dk86TInEVRQNWLvz62zYBmQ4gW+k3qHhgxD3uD4 5IJip6jEO6LNyX3LQGt4+0KlQIFEiihDw1bT5ZD2lnm0cz6fAwB0B1JK6oyhwWJdLkMolH EGAf8EWCaooRGDgj9S9ztczXtM7FJCU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708400925; a=rsa-sha256; cv=none; b=C8YBvCSdRvOwiwfQ/OpB5NrztQyn0S5SRkaUZBh/DXl/msbAzP4yCCbmsFbVNj+WFoyeQ+ u+CHHfssQJs9cTJdTqDFG4SUWVgvvomQE4rtnz+t6TO4k818/jEcHC35VvD5FTmSCT8ZWI ILq9pIIxLJ9pViikEkZP/kE9kEMojB4= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tf4yF70nMz1FKnT; Tue, 20 Feb 2024 11:43:49 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 50EA11402DE; Tue, 20 Feb 2024 11:48:40 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 20 Feb 2024 11:48:39 +0800 From: Wupeng Ma To: , , , , , CC: , , , , , , , Subject: [PATCH v4 1/3] x86/mm/pat: Move follow_phys to pat-related file Date: Tue, 20 Feb 2024 11:48:33 +0800 Message-ID: <20240220034835.507022-2-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240220034835.507022-1-mawupeng1@huawei.com> References: <20240220034835.507022-1-mawupeng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemd200001.china.huawei.com (7.185.36.224) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BF45640007 X-Stat-Signature: pdcuozmhj9ue4srrugewawex6ukz3fnk X-HE-Tag: 1708400924-785263 X-HE-Meta: U2FsdGVkX18XJJshSbgcIl2eqm1mEJmsIBCzbpVzvXbwgHlHAATY1xaXDJSiJIi14yGLPep0pYLFveaGr7/PLQ5JyUNIArnvujCtxKZCLOv6NU6o2RZwnMT3XpBckaas3jq8JaK5ed1UzlzKoUWQUSDSF9gvfLeST3ywmPkbs3n85/MGFLZcdEme/JwblWvXG49jwrOJW4Mu+J2CAFd6VVGqVhA1sIHYX9kys6MM7hPVSFDhdHAwGCTOA/Rrkpavj3456d3OjlAVqKdtgVuJoV/65L9iswy9dC1yO4AhJm3bHbJ245APqdZ3LKso7c1qo+THbxLcRw/8ZPPgtSUYh+vm3vLqp4H4M96pSI3phKkUqVdeNIYNVDdMqsaQs7gyifVFkDix90Ubaprq3+zjD2oID8EKRNc0+zsukHcv9vjCZId0Wv5ZJMuLuNQvm1XtflrE3F1B1pDfyYur2IVVzmHm5/oJ9bh+7OsFRFq5fA7o6Dpe553pW8idfG79N1KDj/oMld0skeoxw7OLfTcbNI6u199DwHqRIleTsrzUIWJdQYOoNyuqyAebXyJdj31B2c1auG9ltgv6cMC4JmmilCSr7FNPlU5mVXl8IpcZjhMi+Z9fuI5Ct3siEcbwQNraGMFB8V0q6TMBmHimyAWyk9ai96EaMmrua/1AGxW6wqpRldGkAPg0ZP5lu3MmfagMobRZPCm9P0sisPS/g9VmSA4NRYcVlI59cMpHbNMwnifQop3dNM2shDJdLlfYzBGKDuq6mIadxTSrBmV9HsBYTxz9W0pJWKdv604VA8NkCnQJewhT5NjgwfoHSXNjU32URW9Yt0+uq7a+PF9+ByGOLs8PFeH7fwZuP+fwO9SpvllhkWo+TiLf1LQMFI079mSkhYUY3sjNru5tagCsHHoFS7tfll9bpUnbuX+XKN7wBfPGYt85Ts8qFjln82h+RHqO46ZITnsSU2h0cqoG+d5 D4cc74hz sqruhdjsEUWc++nQqpjRQjKwOIj7ImklTuSImcjH6bU+uq9LrifbYNRqVFc5VGSX/ko64fEPCmIFwgGa8ZVvJ4ps+UYYn7WadOoRT6D0HYgHd18RGficmAhAklXlvFDUw3PZOsF00jhPp3OyhtlL9IlBf6RgxGBgg46PHY3qVs7h4jhwI6t//2qbZb7F93JztNp/A 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: List-Subscribe: List-Unsubscribe: From: Ma Wupeng Since only PAT in x86 use follow_phys(), move this to from memory.c to memtype.c and make it static. Since config HAVE_IOREMAP_PROT is selected by x86, drop this config macro. Signed-off-by: Ma Wupeng --- arch/x86/mm/pat/memtype.c | 28 ++++++++++++++++++++++++++++ include/linux/mm.h | 2 -- mm/memory.c | 28 ---------------------------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 0904d7e8e126..d8c37aaaf041 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -950,6 +950,34 @@ static void free_pfn_range(u64 paddr, unsigned long size) memtype_free(paddr, paddr + size); } +static int follow_phys(struct vm_area_struct *vma, + unsigned long address, unsigned int flags, + unsigned long *prot, resource_size_t *phys) +{ + int ret = -EINVAL; + pte_t *ptep, pte; + spinlock_t *ptl; + + if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) + goto out; + + if (follow_pte(vma->vm_mm, address, &ptep, &ptl)) + goto out; + pte = ptep_get(ptep); + + if ((flags & FOLL_WRITE) && !pte_write(pte)) + goto unlock; + + *prot = pgprot_val(pte_pgprot(pte)); + *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; + + ret = 0; +unlock: + pte_unmap_unlock(ptep, ptl); +out: + return ret; +} + /* * track_pfn_copy is called when vma that is covering the pfnmap gets * copied through copy_page_range(). diff --git a/include/linux/mm.h b/include/linux/mm.h index f5a97dec5169..75c683f2f5ae 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2375,8 +2375,6 @@ int follow_pte(struct mm_struct *mm, unsigned long address, pte_t **ptepp, spinlock_t **ptlp); int follow_pfn(struct vm_area_struct *vma, unsigned long address, unsigned long *pfn); -int follow_phys(struct vm_area_struct *vma, unsigned long address, - unsigned int flags, unsigned long *prot, resource_size_t *phys); int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, void *buf, int len, int write); diff --git a/mm/memory.c b/mm/memory.c index 15f8b10ea17c..86ad7f1ca3af 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5802,34 +5802,6 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address, EXPORT_SYMBOL(follow_pfn); #ifdef CONFIG_HAVE_IOREMAP_PROT -int follow_phys(struct vm_area_struct *vma, - unsigned long address, unsigned int flags, - unsigned long *prot, resource_size_t *phys) -{ - int ret = -EINVAL; - pte_t *ptep, pte; - spinlock_t *ptl; - - if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) - goto out; - - if (follow_pte(vma->vm_mm, address, &ptep, &ptl)) - goto out; - pte = ptep_get(ptep); - - if ((flags & FOLL_WRITE) && !pte_write(pte)) - goto unlock; - - *prot = pgprot_val(pte_pgprot(pte)); - *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; - - ret = 0; -unlock: - pte_unmap_unlock(ptep, ptl); -out: - return ret; -} - /** * generic_access_phys - generic implementation for iomem mmap access * @vma: the vma to access From patchwork Tue Feb 20 03:48:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mawupeng X-Patchwork-Id: 13563362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13322C48BC3 for ; Tue, 20 Feb 2024 03:48:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ABF26B0087; Mon, 19 Feb 2024 22:48:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E66F6B0088; Mon, 19 Feb 2024 22:48:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 088F28D0003; Mon, 19 Feb 2024 22:48:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E709A6B0087 for ; Mon, 19 Feb 2024 22:48:48 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 63C0112058F for ; Tue, 20 Feb 2024 03:48:48 +0000 (UTC) X-FDA: 81810800736.16.D431942 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf25.hostedemail.com (Postfix) with ESMTP id 56BBBA0003 for ; Tue, 20 Feb 2024 03:48:43 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708400925; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1y5FaYj1i+odH+owYs3noPuKxt5kmgxCeslWrccCwcI=; b=gITR8liGE4LK2KLwptkn+TrGY9exYhM7QCsQ2RnuiIM8ntBdZqLTOl3FSbrLj/QJkjbrUw DZPrRat3W2xSuGn/DzlprNkL6m1Rh6/Lk31HIx56gxpBWyOB6RFt+kLpZjsimkaqDbjBVy Wt6pBjHjFYu6y40QnUWhyud55BzYazc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708400925; a=rsa-sha256; cv=none; b=KjQgtRqHWyr+x9Fd1gen1KoMVscipKfVMaOWsA7T9ULaolgNe26QsiO9acdzFxxi3WQPkz IrPsSGxZbiSgZ7lQdqoYGxiRMLx1PbbRQWsOR/zMg5iqTgegQ9HPA3EyiCYfffccHmQeqB kOljpgIX66RlifvGeR5FB0MaWl6AKmM= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tf51P26KHz2BdDP; Tue, 20 Feb 2024 11:46:33 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 09ADB1402DE; Tue, 20 Feb 2024 11:48:41 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 20 Feb 2024 11:48:40 +0800 From: Wupeng Ma To: , , , , , CC: , , , , , , , Subject: [PATCH v4 2/3] x86/mm/pat: Cleanup unused parameter in follow_phys Date: Tue, 20 Feb 2024 11:48:34 +0800 Message-ID: <20240220034835.507022-3-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240220034835.507022-1-mawupeng1@huawei.com> References: <20240220034835.507022-1-mawupeng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemd200001.china.huawei.com (7.185.36.224) X-Rspamd-Queue-Id: 56BBBA0003 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ihfgro49d1wtwx9ith3fsanpztyo9t5x X-HE-Tag: 1708400923-560609 X-HE-Meta: U2FsdGVkX190vQ+rGI4G30G0mpVCajzGMQwaV9TgGNI4ZMcg7dSzEEJDJjMFD7xJkz4aPpnIhQnUe5+Y1gznoxIEzc7xH8ykaeV5d5LDB5HFV4q1bUmOA2PkVMbuoeggDMckLBxQK9UHLVmjvZhMAMNUD3FspWJPGkVx0wij3+EQlga0afaI3qCNkUpRDwrIO/tXKT+u5d8khA7b53tV04LHgo16TLCF+lFBCON+CleW0CbH1OKiyzIL9yt89QRyrEciBOgMjwDk+HKLNBxxEnJSme8xiLfkyVM0T98+pq8aIwMfGHvQ4z7iC4b/Ap4SJwGbSJlV3OIxwtiYg2PEnoKMTjMW+/eqzI5zMT5RynDF9PdOI3tUXax6AZ01iQ7NGxLGL537zUmyLuKahbAv4jNTWsWV47QR6ZRlQLoIXlbDoS26j7zk7A0M1cpINfsSjuFzWXV4PKPF1L4hdDZxjvbhMiCplkJ26Yaq8M68dsN5woYmdoO+KNBnRZgsKS0h5pOXlUZOgpaVAkozDFEnTH4xsESpTHSVTum82h1O3EwIqcn3ay+MKWvo9XT2O1QH7qZOah3L+fz9Yy/qAoeuPVNG2SyAJbk1mYOMvIyHIC6w4Z+ihTt+X0MGWndrX51CjXi6ckFBashHg4bCI6yEFIQ8W4Vfw4O774QVcRrDFgILWuZHeqZvmmiT+hY5I3r9CYaB8TIINw5DQahWS/LN8cJstPQfUUiImMRt7+g/AkugxYpi1ftCXUhLTkoPvJCiXOOGbcC8/9D45YVL8mamJqQAgEvIHhRV+FPxo197UllsGeLHu17KF9QsneC+5/RaoPKQAocLYJdOJR38UVNBDwVcyCJ0Bu4uF8oCDpQK3CN4pg73KuhQXDIN74u2HQ+QaxXBOcEyR2XFb4UjGdp3HaTBWvpR+0Lvcp25gXlSxqgTB/U8zQYuy6Kkx8qE6oA0xKF9qzOQGuXuUXC8kld +RxRVXDK nVovNc9MZtDaRyRljVePF3gQ7UMVSeuODPJ0v0lEw0RPSFrKcrfNY9u5H3jCBAyERF5gVOouEytkLOggF4RkM+NuZKMM07+BNSnqyDmA52eC1t+H+1vZamUg5A653XUKrcDNiHrd5RQIlRnARdKXh1DZw5NEsG7KisH83S2SX9qoJRZHkoVDRpqnNrwohCEC2kXtg 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: List-Subscribe: List-Unsubscribe: From: Ma Wupeng Parameter flags is always zero in caller untrack_pfn() and track_pfn_copy(). let's drop it. Signed-off-by: Ma Wupeng --- arch/x86/mm/pat/memtype.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index d8c37aaaf041..5b56f08f8ce6 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -950,8 +950,7 @@ static void free_pfn_range(u64 paddr, unsigned long size) memtype_free(paddr, paddr + size); } -static int follow_phys(struct vm_area_struct *vma, - unsigned long address, unsigned int flags, +static int follow_phys(struct vm_area_struct *vma, unsigned long address, unsigned long *prot, resource_size_t *phys) { int ret = -EINVAL; @@ -965,14 +964,10 @@ static int follow_phys(struct vm_area_struct *vma, goto out; pte = ptep_get(ptep); - if ((flags & FOLL_WRITE) && !pte_write(pte)) - goto unlock; - *prot = pgprot_val(pte_pgprot(pte)); *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; ret = 0; -unlock: pte_unmap_unlock(ptep, ptl); out: return ret; @@ -997,7 +992,7 @@ int track_pfn_copy(struct vm_area_struct *vma) * reserve the whole chunk covered by vma. We need the * starting address and protection from pte. */ - if (follow_phys(vma, vma->vm_start, 0, &prot, &paddr)) { + if (follow_phys(vma, vma->vm_start, &prot, &paddr)) { WARN_ON_ONCE(1); return -EINVAL; } @@ -1084,7 +1079,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, /* free the chunk starting from pfn or the whole chunk */ paddr = (resource_size_t)pfn << PAGE_SHIFT; if (!paddr && !size) { - if (follow_phys(vma, vma->vm_start, 0, &prot, &paddr)) { + if (follow_phys(vma, vma->vm_start, &prot, &paddr)) { WARN_ON_ONCE(1); return; } From patchwork Tue Feb 20 03:48:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mawupeng X-Patchwork-Id: 13563361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13F4EC48BC4 for ; Tue, 20 Feb 2024 03:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF7716B007B; Mon, 19 Feb 2024 22:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA5D46B0088; Mon, 19 Feb 2024 22:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0B836B007B; Mon, 19 Feb 2024 22:48:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A21D16B007B for ; Mon, 19 Feb 2024 22:48:47 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 792481A051D for ; Tue, 20 Feb 2024 03:48:47 +0000 (UTC) X-FDA: 81810800694.15.B249788 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf14.hostedemail.com (Postfix) with ESMTP id 727FB100005 for ; Tue, 20 Feb 2024 03:48:45 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708400925; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UBMm2ylMBBUFwI9+Hbt/7fHj5CXw3f0ET8LE1lr09gM=; b=UZpEF8DCIam84Z2uxfDzW1i/wKZs24dbbdWFxBsd9VxJu1mFa+ur03Fe9YPWQ0+KHVAHpU zTctx8VZ5rFhRyHWwdRfzsm81npj/i9rPKv+/eKQ5NQz15+c36rls38x7UQ96Cj48ckapN lfKEGT34wlqq1K9d86F4coB+NIBiswg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708400925; a=rsa-sha256; cv=none; b=tFkyn8u8rd6HLISGbT1fdea3b4d1C4lWDD+goX1FzGVFDJ4gYRv7j/aTA6xmKlzjZ7cUWI 4Ybuf8JR9bjJmwOLk2stFrqetDyXeSTz5Rpah0wtKj+eO8/R+X6F/fWmLarGNgl+a+eJ8x R4Y+EEbFo+7sV8yjXgsECno4/h1n68A= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tf52J35Gtz1xnMy; Tue, 20 Feb 2024 11:47:20 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id A29B0140120; Tue, 20 Feb 2024 11:48:41 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 20 Feb 2024 11:48:40 +0800 From: Wupeng Ma To: , , , , , CC: , , , , , , , Subject: [PATCH v4 3/3] x86/mm/pat: Remove WARN_ON_ONCE if follow_phys fails Date: Tue, 20 Feb 2024 11:48:35 +0800 Message-ID: <20240220034835.507022-4-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240220034835.507022-1-mawupeng1@huawei.com> References: <20240220034835.507022-1-mawupeng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemd200001.china.huawei.com (7.185.36.224) X-Rspamd-Queue-Id: 727FB100005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9ytiejbuspsc4rwdfyjqrjigdxsipwpp X-HE-Tag: 1708400925-946771 X-HE-Meta: U2FsdGVkX1+YKulXnQnQHO+Br6kRvz7oih2NCoXI9iKS0cNtwC7QBGeaHjL9vrLUuLyD/C0Ge+aAcak7NIrR9haGZQc3Ands3Z52wCitwhSEPWkrh9VfLHdfPVsktmlDj2qMi/5F705QSy09Ml39JsB4akhJcaQ7ir7QKXN6jVQiLzDv9zxYN4yTUtf0U+DgNNsH9mtaMHNgV5NFSjg/lQwAqKguRY7Fx+yRt3efWldexJNPkqvTbiJeESgTm4J8dg+65yHuMje4+Ay/y7PvsB6wyatMIIHR+Q7RCqCD7IZHJ6fCkta7NXXJsMUlDBdn/XyyszF/Ru1HNq538dSs1HqaI4tsxyKmTjdqkIha5Pn/zAghgFNa275ddjWGq83x0kEiXnAqXdOu2kubXtZkYQYNMBu0d1YLxk1ooyA32oY8FVVaO2wF15UZmA2W6ubFEt3dCEEYQZjFEgZD3JM1IbRQ5wQgIuID2pQ7Zsn8Bb+ByXxtlDYI7fEa6oYKYwAxrxJpqqd4Pehv4EDX1dO4uaKl/Aq1R/VZ3ZltwaBD7gyZy4fFuJ27elePw6S0v06R5Wf28bwimOoHbLShUTD+9HMb3yYAKjQk6/GHoWlp0yCzJ6XWE716nSakZ81jMvmO/2QuB4vapzAFa1BYFlWxmv3lIX2NabL5xv4u7PrJQoS57UCpwW4uR8SD95HC5vUFdw/V8qoeMf45zToJJt9zv/shOhHfXkWDD75wDHsZyEyHhr8c40N7okWzD2aSFS8/KdG+TUslI5UgRVO69EzR6xFWSm7FCpWKs/IEtzZ6wxvdrWevOPtdziP66USxh1fV21D6tUw4zYVSiBhk/zDodPjbDgXRYL7jpKuBjxfum5E01/xIxEDfAZFG9FTv5PS1+ztf4GhGe37hascALHZWhQ== 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: List-Subscribe: List-Unsubscribe: From: Ma Wupeng Since there is no obvious reason to keep this WARN_ON_ONCE if follow_phys fails in track_pfn_copy/untrack_pfn, Drop it. Signed-off-by: Ma Wupeng --- arch/x86/mm/pat/memtype.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 5b56f08f8ce6..5b3a7a2b21e3 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -992,10 +992,9 @@ int track_pfn_copy(struct vm_area_struct *vma) * reserve the whole chunk covered by vma. We need the * starting address and protection from pte. */ - if (follow_phys(vma, vma->vm_start, &prot, &paddr)) { - WARN_ON_ONCE(1); + if (follow_phys(vma, vma->vm_start, &prot, &paddr)) return -EINVAL; - } + pgprot = __pgprot(prot); return reserve_pfn_range(paddr, vma_size, &pgprot, 1); } @@ -1079,10 +1078,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, /* free the chunk starting from pfn or the whole chunk */ paddr = (resource_size_t)pfn << PAGE_SHIFT; if (!paddr && !size) { - if (follow_phys(vma, vma->vm_start, &prot, &paddr)) { - WARN_ON_ONCE(1); + if (follow_phys(vma, vma->vm_start, &prot, &paddr)) return; - } size = vma->vm_end - vma->vm_start; }