From patchwork Thu Jul 13 09:53:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13311662 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 DECB2C0015E for ; Thu, 13 Jul 2023 09:40:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BEF08D0001; Thu, 13 Jul 2023 05:40:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 244D98D0008; Thu, 13 Jul 2023 05:40:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10F278D0001; Thu, 13 Jul 2023 05:40:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E74F78D0008 for ; Thu, 13 Jul 2023 05:40:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C2C34B0020 for ; Thu, 13 Jul 2023 09:40:35 +0000 (UTC) X-FDA: 81006093630.09.A7ED5B9 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 681F84001A for ; Thu, 13 Jul 2023 09:40:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@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=1689241233; 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=AtOkhhiw09TdDExhZx6wTJwpnMZwYVrrYxu7zFjNWQw=; b=5DZmmXbyQywAe9vOK35feat7Resyf19N3yarj5x5jerupP1nGDYPtfEkI2GqQQUTdDlez3 5R0dtWimiPLoQWV3NrDh79QT2Bm/N5e8mWEjuwjAya4AylD61TpDDXsvMQVuVZAwReHkfg abPcGpwe1VO0hNaRS6c4CWItIXjzjxM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689241233; a=rsa-sha256; cv=none; b=ZTKWpYoZfBFnUbioFMl1dyGvjcxgoEuvAG49duGdv5R44v4zmEIHS7vk64G4DWSQz+DJ82 pihIT4hddkj2WbSCcw9lDeOmFjSl/MdXjs1z+a78P6a+eNq0OgGmT1A8EnCtPhUl+M82Ko KqcQkO35oCh3lCwXx1YiFLP/cQWmmTw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R1qJk00S7ztRVh; Thu, 13 Jul 2023 17:37:25 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 13 Jul 2023 17:40:25 +0800 From: Kefeng Wang To: , Andrew Morton , CC: Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , , , , , , , , Kefeng Wang Subject: [PATCH rfc -next 03/10] arm64: mm: use try_vma_locked_page_fault() Date: Thu, 13 Jul 2023 17:53:31 +0800 Message-ID: <20230713095339.189715-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713095339.189715-1-wangkefeng.wang@huawei.com> References: <20230713095339.189715-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 681F84001A X-Rspam-User: X-Stat-Signature: wx5d5fo8pqiik9iwnuw7zy4oxwcm4gii X-Rspamd-Server: rspam03 X-HE-Tag: 1689241231-844163 X-HE-Meta: U2FsdGVkX18utWEpInfD9FC7qPNAYYFGLZUVaR0fHcwskN+4j8v1yhbLqgekgSIwzxvENAsvQsxPAgyt0HNpW7inFAiyMEBOy3vIRjaoLPwqg1qG1mp1vCvFdKxJ/Gol8b9nfA4PLAUObkDGvAqqGitJghDs2vWE8StkK74REVAdNCT9oaLDTifUT2YD5IYkpuw8eYrQdNIZ60o2t5XMia/ccLjtr9bCXYFi5TzkLEtMQGATWOEB2GNP7yhA90WC/Wzdqma5c/8m92Z5nXxdfA8FSKf4188P/DZEGAVcxfmuszfPr9N0mIYnFltnr7pDh7grGJal6+Q1S/AybdnHhug1ebc/pofRJXJssJYKrWzLypYEXDMjpICobplXS8rdqgq3RdTJ9CGB56urpUpEOdkuqwSCyrAX29ANzh0FuXYGqc0hYqiDb+NiaJG855QNIvXT749N7baVqDUJmcS+ZMh7LZkyW7AZrOeuumnAM37t68c3ZIfRk9jiaUVXxF88M7pYb1YFoz5k38wjtF/lRuhpo5rxh6ZQE8EqKnLGZEYCnPaBGWZBcHHO5FP5yqXwrOy8DZlBgmJC74F1LuNTMuBzWH3K8slpurjc9SCRN9u46rK9mInvwAEr7dInvKllXPi1EXV6sbAoQC+nqzXmfG5uGtVmKGw2MaK5y7fQubSUJpwYllTDMRwHEFnaGGyaZg3qnGfzA0knJhw8QYNEt1Y7cVAuvizQBrSj8yhBZh0OgDs41S5oD2IvSqijHqgfL5v0JIjgTHhHlCT4DML5/I+qvR3GjzQs9azKderDY+EzQwq2uyOKjzaKLSsAi9CcWsHTwkv/LZ55X8m1SzLhI6fHJHgkCfHY0EC3eyCiYUAjWZ0H/k7yN0StUzKR54w37Z5H3vVWlaVZnWTHjApWqFTKvzCZq9m5Htvj1R+Tt5svn6vzGrkjUbr0292DFGEp0tkF4zTgWME1c1xeTb7 sfwykqkN x4jR2k3rPozv8rz8Ggk75sZhbBdviXqC/5mwDXWyRhpREqwCvQ5nOUZ7f8xraE5ARnphy84yRLlsNRdWYKloLJHJnWtdk8Z7d3PQpMPxpEjYPRjgNsxNPamgS/beUr6vPYxoSWJK3p0DiduOiTQ3abU6hisLQ4gqAPIj3pCTlAApoWlOzTicfShuygnz/zIW2/KsQxYXsc14v+GE= 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: Use new try_vma_locked_page_fault() helper to simplify code. No functional change intended. Signed-off-by: Kefeng Wang --- arch/arm64/mm/fault.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index b8c80f7b8a5f..614bb53fc1bc 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -537,6 +537,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, unsigned int mm_flags = FAULT_FLAG_DEFAULT; unsigned long addr = untagged_addr(far); struct vm_area_struct *vma; + struct vm_locked_fault vmlf; if (kprobe_page_fault(regs, esr)) return 0; @@ -587,27 +588,11 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); -#ifdef CONFIG_PER_VMA_LOCK - if (!(mm_flags & FAULT_FLAG_USER)) - goto lock_mmap; - - vma = lock_vma_under_rcu(mm, addr); - if (!vma) - goto lock_mmap; - - if (!(vma->vm_flags & vm_flags)) { - vma_end_read(vma); - goto lock_mmap; - } - fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); - if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED))) - vma_end_read(vma); - - if (!(fault & VM_FAULT_RETRY)) { - count_vm_vma_lock_event(VMA_LOCK_SUCCESS); + VM_LOCKED_FAULT_INIT(vmlf, mm, addr, mm_flags, vm_flags, regs, esr); + if (try_vma_locked_page_fault(&vmlf, &fault)) + goto retry; + else if (!(fault | VM_FAULT_RETRY)) goto done; - } - count_vm_vma_lock_event(VMA_LOCK_RETRY); /* Quick path to respond to signals */ if (fault_signal_pending(fault, regs)) { @@ -615,9 +600,6 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, goto no_context; return 0; } -lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ - retry: vma = lock_mm_and_find_vma(mm, addr, regs); if (unlikely(!vma)) {