From patchwork Mon Jul 24 18:54:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13325257 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 3461FEB64DD for ; Mon, 24 Jul 2023 18:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD87E6B0071; Mon, 24 Jul 2023 14:54:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A88996B0074; Mon, 24 Jul 2023 14:54:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 950418E0001; Mon, 24 Jul 2023 14:54:19 -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 84DA56B0071 for ; Mon, 24 Jul 2023 14:54:19 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 59F5A1C9AB8 for ; Mon, 24 Jul 2023 18:54:19 +0000 (UTC) X-FDA: 81047405838.08.25F4718 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 0BAC5180017 for ; Mon, 24 Jul 2023 18:54:15 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=n5GXwO6D; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690224856; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2AZT1+3agWdrOE7nqGCVHOcFr0jkcGTHBHWs2FPeDAM=; b=ZD+TiUzLuu+BhC23YEqzlEi/0NLD0maIbfImt8kFG8L9w5qiA3P8ewKhR5tMlFxOoRJkHq 5nehS4f+oua/b+K2XgoEQEGG05TtXn2k5stWRQkoH94/oK79mubXcV/FYW1SFWmpU4cIPF MqYV+8TwEGBCMXHp/JNmqdUDOZXYyx8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690224856; a=rsa-sha256; cv=none; b=ZRcHnJW2CgFtBOTEhl+TnA9LPYMoejBD10Vyh5de1vX4+DPkzkpzYQjDT6LrLZCYViZWts SfbSKhhoAPUzKbRRSf9xT8HIHzoJg40tWxxhi/ej+0h6zNoMNjZBF5l9SqUm3Ljc1Gv5Ql RAqOFwvF+zoirkP2rD2xH7Sf8/NW28Q= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=n5GXwO6D; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=2AZT1+3agWdrOE7nqGCVHOcFr0jkcGTHBHWs2FPeDAM=; b=n5GXwO6Dr8M+Aa3h7HKboWgfbn O6jzDiQok9xwJwtnCZMhuc2dh0YtV6FQJWpLd1iAAgzkjij5vatuLMlggbmcGT/XPMZ5rEC1vbHG+ dIDesgUfaQ31ZEBPWNRwAWCW7XVkC7uAv34PynBov/6Mr3o2ot8lA2yNDCI2J/npI4AdVaRoHR24h msmW+juCmkG/E4EQ2AvmRvbvwxI7rZZVKE+YjdaOaFJRREPwbl1O4kwNhrasi+oMpo2IRxx8u2dYI KNnMexdkEPHhY7srT/Gv6v0BYss34lJgRGAKi58np38ju4aZRpssnyqcmRTW7YggNW3h9jdjWCyBC 98GOUPDQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qO0hA-004iR1-25; Mon, 24 Jul 2023 18:54:12 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Punit Agrawal , Suren Baghdasaryan Subject: [PATCH v3 01/10] mm: Remove CONFIG_PER_VMA_LOCK ifdefs Date: Mon, 24 Jul 2023 19:54:01 +0100 Message-Id: <20230724185410.1124082-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230724185410.1124082-1-willy@infradead.org> References: <20230724185410.1124082-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0BAC5180017 X-Rspam-User: X-Stat-Signature: 9fpp9i6q9mfu853f1oia5hny7ihiud7c X-Rspamd-Server: rspam03 X-HE-Tag: 1690224855-171201 X-HE-Meta: U2FsdGVkX1+F8PvY8QxfLnShXS7pWMDsnoQSMz6vUp/q/zqxrWc/A2frFeHebTyVsbuYasTTM2deXpxFcrxbK8eeFEk16FFkd/ehfIymz/3Y55iqiCAMjWotw4Y510qLBPHUbmXZknOQS6mTxDtzA+Vtkw0+OxW2f2HY9biWQ+HzoBGn5Rdg1HRpxJuhTltpSI0IhGdvzPPa7zPWQ4ACT5+KUV4ckSerJljTeCH1AoWGi2+vzmOoQnmscHmZdRcAQYQzkuJQ8GL7rtYEGD7orcJlaZmSVseAzTOdL17ZXCd317ysIJpfzeo3BwqJ7Po5RFPDw1CDEQuNwi2mxBNQV0qWNMn8SszfMyO6jcqV2LfRb0oaiZWxzh9vQ+y2pEx/KWUhv9641zuFpsbM7yq6FXcrJwaCb8EcHXIOkIwcZRSorkT0yuB8/EvtEytfYb27Fk+F2lfx+WXEm7gqLNrnqSRveo0VS/HB7IiC3Db5hlEYCDpnc8NZI83jaRRrBGrFiEvIBh+VoQS7taDEAYAr4lL2ATkBJVkmurCB/Z4Uh5IVNk3ywGs/sIfMZY9U8kuVLUzVMakWllwO7MNTrLsRaQi19HErUcZarsBzylIyMoZjp25wl1j9w76rTtb8yZ6xD8Lk8vJhdhUwEb0eidTXP8pb70atzdgvl94UgdQdVkQG0l/yqfuI0YXN95RGWwyaP8D2vtX3bKZO6i7JQ2eKwfkcrzT8L5c5i4X/Ow7BbBivmfMcw9rvOqUfMI60s4kwtHjQ7FUFE7mQPESZ74kx17kmU3wZvJirMfbSSO0jg6fhZEL0TaIn1dDhOcskKLA9AKXPF3tJNPHaMejbKnmkRN+3hYZP9EDGyUWeLs7Ogj1z8t0nceBboH8jMNIgkYlWqTf7Lj1sRpQxtk73MrhdRTC2ADQJBJ+56z0yOtfx1UPO7wk61VnR2jo+FT63yRpOWwkxRGPnKFnzmDyUlE2 /PznV8JT jDI642EYgAKP/7Gxg3+gKeIBXkmYPpl9qPEUBGaTuzTHDBQHjApaoZD2yxmLDRq9Rhr4MRmKzuA1sikSk7V6yveg3Hnk2UlcIpLakLG22HFqQYF6nfSIczJjjp0sxk3iUMhNbB/PPpqlUSO1K3exmXlduvg9wrv+psAMJB+94bLgWGdkUpHkG/5Md6lKCx9yI16LEZT7f9NjDHD+lUQYc+HP3pdkP7ojeMYE669uOwGMV4zozsuDHepf+YQ== 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: Provide lock_vma_under_rcu() when CONFIG_PER_VMA_LOCK is not defined to eliminate ifdefs in the users. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Suren Baghdasaryan --- arch/arm64/mm/fault.c | 2 -- arch/powerpc/mm/fault.c | 4 ---- arch/riscv/mm/fault.c | 4 ---- arch/s390/mm/fault.c | 2 -- arch/x86/mm/fault.c | 4 ---- include/linux/mm.h | 6 ++++++ 6 files changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index b8c80f7b8a5f..2e5d1e238af9 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -587,7 +587,6 @@ 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; @@ -616,7 +615,6 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, return 0; } lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ retry: vma = lock_mm_and_find_vma(mm, addr, regs); diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 82954d0e6906..b1723094d464 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -469,7 +469,6 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address, if (is_exec) flags |= FAULT_FLAG_INSTRUCTION; -#ifdef CONFIG_PER_VMA_LOCK if (!(flags & FAULT_FLAG_USER)) goto lock_mmap; @@ -502,7 +501,6 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address, return user_mode(regs) ? 0 : SIGBUS; lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ /* When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in the @@ -552,9 +550,7 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address, mmap_read_unlock(current->mm); -#ifdef CONFIG_PER_VMA_LOCK done: -#endif if (unlikely(fault & VM_FAULT_ERROR)) return mm_fault_error(regs, address, fault); diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 6ea2cce4cc17..046732fcb48c 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -283,7 +283,6 @@ void handle_page_fault(struct pt_regs *regs) flags |= FAULT_FLAG_WRITE; else if (cause == EXC_INST_PAGE_FAULT) flags |= FAULT_FLAG_INSTRUCTION; -#ifdef CONFIG_PER_VMA_LOCK if (!(flags & FAULT_FLAG_USER)) goto lock_mmap; @@ -311,7 +310,6 @@ void handle_page_fault(struct pt_regs *regs) return; } lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ retry: vma = lock_mm_and_find_vma(mm, addr, regs); @@ -368,9 +366,7 @@ void handle_page_fault(struct pt_regs *regs) mmap_read_unlock(mm); -#ifdef CONFIG_PER_VMA_LOCK done: -#endif if (unlikely(fault & VM_FAULT_ERROR)) { tsk->thread.bad_cause = cause; mm_fault_error(regs, addr, fault); diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 2b953625a517..a063774ba584 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -407,7 +407,6 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) access = VM_WRITE; if (access == VM_WRITE) flags |= FAULT_FLAG_WRITE; -#ifdef CONFIG_PER_VMA_LOCK if (!(flags & FAULT_FLAG_USER)) goto lock_mmap; vma = lock_vma_under_rcu(mm, address); @@ -433,7 +432,6 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) goto out; } lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ mmap_read_lock(mm); gmap = NULL; diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 56b4f9faf8c4..2e861b9360c7 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1328,7 +1328,6 @@ void do_user_addr_fault(struct pt_regs *regs, } #endif -#ifdef CONFIG_PER_VMA_LOCK if (!(flags & FAULT_FLAG_USER)) goto lock_mmap; @@ -1359,7 +1358,6 @@ void do_user_addr_fault(struct pt_regs *regs, return; } lock_mmap: -#endif /* CONFIG_PER_VMA_LOCK */ retry: vma = lock_mm_and_find_vma(mm, address, regs); @@ -1419,9 +1417,7 @@ void do_user_addr_fault(struct pt_regs *regs, } mmap_read_unlock(mm); -#ifdef CONFIG_PER_VMA_LOCK done: -#endif if (likely(!(fault & VM_FAULT_ERROR))) return; diff --git a/include/linux/mm.h b/include/linux/mm.h index a5d68baea231..89f80e2c6ed9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -753,6 +753,12 @@ static inline void assert_fault_locked(struct vm_fault *vmf) mmap_assert_locked(vmf->vma->vm_mm); } +static inline struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm, + unsigned long address) +{ + return NULL; +} + #endif /* CONFIG_PER_VMA_LOCK */ /*