From patchwork Mon Aug 21 12:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359377 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 31CC1EE4996 for ; Mon, 21 Aug 2023 12:31:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFA728D0013; Mon, 21 Aug 2023 08:31:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA7CF8D0002; Mon, 21 Aug 2023 08:31:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD35E8D0013; Mon, 21 Aug 2023 08:31:30 -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 9C7258D0002 for ; Mon, 21 Aug 2023 08:31:30 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 724ABC0BA8 for ; Mon, 21 Aug 2023 12:31:30 +0000 (UTC) X-FDA: 81148047540.17.43CFE21 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf26.hostedemail.com (Postfix) with ESMTP id 380D014001C for ; Mon, 21 Aug 2023 12:31:18 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692621088; 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: references; bh=TsWdloBr9yoz8tQt+2nUHC5+f9iUSJxmgQf2lbTF394=; b=M3wFpjOFSd8S+7UYxcWG899YXo8kQdcp1Ul1bLrPki0ZFZEGvRHpY8FA2mnJ1vG0Wlz8Bq BHEX+Q+RkNZ27sRcs0xNodClkwBz46T2jfjZ7NxJGMmYTlnRYcqmasLjJ1FSAc6iZZRhhP 7EL9Cg7RXduwDKGlx+WFgIGgrsaiN9s= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692621088; a=rsa-sha256; cv=none; b=BinDyX2AGrOlnrRdc+ho4g1+j9lUFURpqI1LS2vCUuUkfVcmX+LuLCBEHfLx7TbooVG4Iq r632e7MkDFRQDGK0jCgKiZWPnPPBVkn40f2ZSuGNyGw/PwlESR4j/mthC4gj2IcCN350G8 sGPbsRgO8jsvG9+I8zesDCy7h4Oendw= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RTsHY0pyfzrSqg; Mon, 21 Aug 2023 20:29:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 21 Aug 2023 20:31:11 +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 , , "H . Peter Anvin" , , , , , , , Kefeng Wang Subject: [PATCH rfc -next v2 00/10] mm: convert to generic VMA lock-based page fault Date: Mon, 21 Aug 2023 20:30:46 +0800 Message-ID: <20230821123056.2109942-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 380D014001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bg8sisqbqz7c5y11weaxun3uhbo9xxfc X-HE-Tag: 1692621078-72546 X-HE-Meta: U2FsdGVkX18fXKcgcsatKNbeZ4mRNDvWrIEJGRqbTQGPiFyootD+UBnyo/bnxvQg20ZfDYzOBkJehjrF7cJ8LuuwB++l6G+D5/m//eE2O7cK7GoYjYvSk83gtYS86dbxHvE0Kcujj1c2Ogt1PU3fFHiHkxbxlR12LuyqWAsZVExTbTSEhfhzg0jxaC44V9at0emfRT60SV5GXbE7kOYIVJ50c0OyziqChxBrrthDdVlQq3OnjI3vm4+menjUrsYMK887Bk5mITGaj2jTVVo7uwPJN1P4FI69YZw7owVXUU9BbPOQQqIWjr3HK9DglGsrVoDMaUADW1FDAiG8Tzb7jkvdg6SBxqzuKG050n9OfMcfYNqTW4GrpBua9W67/NVWCYKRo+gv4DjyirBJDWFFca3ziwMjVnHr/6m+ngBHfaD6XuzuNVljOoaxOVPvRQErqFp55QtM1kUgHHXZIRcu16ck10GUtAb/21IcBsR6SO9fjs8EqH/UYT82VVeKnvLwZsLCp+4Tqcq3L0fc+BYJ3WjYAdH2neSYmBy07d2VUmhpAxAhiQ8fv085zTXSOwblVVwf0KVlwv2ZpYSHVQGK97DAYqdTi3Rulfw0QL6qk6F7PczjskBocHA9xWJJAgfEcQzeF8exW82zD4Q7lZYtyhfDpuFWgIkcU1KQCkxgFWznupdGmWVB04NkamwkJ9BZWp4ySoPCjoggZSry8S8H/gdY5wjfLK8WhF3kyBozI5kf/pCoe/nVeNuTJnCQgwmg5VEljqZ9WSgU3/mplaBes/qZlSk7NnD1cRFmW5wpZMqkPQa71pfSQ0CKZD4Ahdt190QQipylaF9xI8TXF/GdoMhSBHhM4fNemmY2aZJ/Z3k1pkPRGpuCKlXGF4sGUpcaQS2+jIH/0MdqmnXELKi7jpA/b01H0gQFozF1NJhF4MBoSV7Vk3ElYdLNNRuqkbuiG8w/DTLzcJ0suQOHsk5 Bpx0Tz4+ Jrfb3uo1iRSqg0mz2xvxz68aQZgnBmeylb3BQRU4G5yVLDCnLbZ9XzIFwjmtjGt6Mq2LOW32h879dMVnwjTEbmzj7BTc+q5xQtasrv9b+9lu8FeimAIYcSYcCVw== 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: Add a generic VMA lock-based page fault handler in mm core, and convert architectures to use it, which eliminate architectures's duplicated codes. With it, we can avoid multiple changes in architectures's code if we add new feature or bugfix, in the end, enable this feature on ARM32 and Loongarch. This is based on next-20230817, only built test. v2: - convert "int arch_vma_check_access()" to "bool arch_vma_access_error()" still use __weak function for arch_vma_access_error(), which avoid to declare access_error() in architecture's(x86/powerpc/riscv/loongarch) headfile. - re-use struct vm_fault instead of adding new struct vm_locked_fault, per Matthew Wilcox, add necessary pt_regs/fault error code/vm flags into vm_fault since they could be used in arch_vma_access_error() - add special VM_FAULT_NONE and make try_vma_locked_page_fault() to return vm_fault_t Kefeng Wang (10): mm: add a generic VMA lock-based page fault handler arm64: mm: use try_vma_locked_page_fault() x86: mm: use try_vma_locked_page_fault() s390: mm: use try_vma_locked_page_fault() powerpc: mm: use try_vma_locked_page_fault() riscv: mm: use try_vma_locked_page_fault() ARM: mm: try VMA lock-based page fault handling first loongarch: mm: cleanup __do_page_fault() loongarch: mm: add access_error() helper loongarch: mm: try VMA lock-based page fault handling first arch/arm/Kconfig | 1 + arch/arm/mm/fault.c | 35 ++++++++---- arch/arm64/mm/fault.c | 60 ++++++++------------- arch/loongarch/Kconfig | 1 + arch/loongarch/mm/fault.c | 111 ++++++++++++++++++++++---------------- arch/powerpc/mm/fault.c | 66 +++++++++++------------ arch/riscv/mm/fault.c | 58 +++++++++----------- arch/s390/mm/fault.c | 66 ++++++++++------------- arch/x86/mm/fault.c | 55 ++++++++----------- include/linux/mm.h | 17 ++++++ include/linux/mm_types.h | 2 + mm/memory.c | 39 ++++++++++++++ 12 files changed, 278 insertions(+), 233 deletions(-)