From patchwork Fri Oct 6 19:53:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13411936 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 56FB6E94107 for ; Fri, 6 Oct 2023 19:53:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E2648000F; Fri, 6 Oct 2023 15:53:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 692FE80008; Fri, 6 Oct 2023 15:53:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 581218000F; Fri, 6 Oct 2023 15:53:26 -0400 (EDT) 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 48E8080008 for ; Fri, 6 Oct 2023 15:53:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1CFF216023E for ; Fri, 6 Oct 2023 19:53:26 +0000 (UTC) X-FDA: 81316086012.28.C5765B7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id C581FC0029 for ; Fri, 6 Oct 2023 19:53:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=saME0q+j; spf=none (imf22.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=1696622004; 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=KGw4Os6nnxvFPBRCSbndQ6uNf8PmBQJxLw366sMUW34=; b=MNM/uaiErutAPcaCUupbOFelmXEj2J7Ds3COnMfKMnnMggOuz17vX6CkvSHiA5SF19ripU B2EXTIDxoBl/jQwajnRkQVsqwPoS/scVOyx7Wgc2FKqiGTSMlSu4FDFPt2OCZQ5WJby6+w 3MatLhKUGzN3GQdlRlpMjr+xSwQBkoI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696622004; a=rsa-sha256; cv=none; b=eisREseUGIH9m+Sf1rRSbXMXQlNj9KdVfKCAzLOpoKmQwhsEy60Ol9pV7dpiqQEp9yNTAw JQsBbkrLY5++fJ0LbM93X2Cgk08RRLVovfpRGJN9daWzJf2bZ/WSenXBuyRy/R/SSCCQau gieUw9Z2PKy4DjjtJ+jQcRFrn+vZLnc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=saME0q+j; spf=none (imf22.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=KGw4Os6nnxvFPBRCSbndQ6uNf8PmBQJxLw366sMUW34=; b=saME0q+jjAQaNw8vi6kTdgrnxx vKQOnRzPU0ZyodLmCTmaLVdUOfCPWoDnM0PuVWgJUPh6yt960B+8HjRrR0Mg7MAjVGCPw7AbzUNVD HIjihQx7Ct+JYW5UDw4v8JAWjC26pAVRhnT3pL1oPapO8XhDxEqB+lA/k4RYS+iflD7zxnupV60g0 X4N8sV0RIo5KWgSDqOCHotgH6IqEn9a9hWlA/rX+mR9wQhAB5zJUogek7N8n2OSBjxnInY2zsNs7o XyYNOPc2XC8W80G7VCHb3fVAJK2FRSPTZ4L7UvzizkhQPbqVznwfFoiozPS13186xBsCWUIay0aam rJLZ3Mvg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qoqsy-00H9Gj-SA; Fri, 06 Oct 2023 19:53:20 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Suren Baghdasaryan Subject: [PATCH v2 5/6] mm: Handle read faults under the VMA lock Date: Fri, 6 Oct 2023 20:53:17 +0100 Message-Id: <20231006195318.4087158-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231006195318.4087158-1-willy@infradead.org> References: <20231006195318.4087158-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C581FC0029 X-Rspam-User: X-Stat-Signature: 5s4yj4z8xibppjfetc8rruc7q1kw1ipm X-Rspamd-Server: rspam03 X-HE-Tag: 1696622003-411671 X-HE-Meta: U2FsdGVkX18XZVhicxh9lP/hd0O1v5efm7KjQ5kfl2zFtb10sDFtT+x5yi7CbWG59uyJ8mDGBfrORcxKEejvm7HlBlaFYBqm5arhZjYV1AyvauemqCGw0XUdW0GNdIe7i7varnok5n7HUUyHSKwb9n961u6wtIhbQBQXGtPaxFYaDRIxw9nUm6bTICjYe5O8sR7abK6g+xlblO3EkCYKZXfpqSG8xF240zh7Ph1E7MpV+D7hXPKCaSM02K8KXh2TJ9d2JJ2hLoB6Jn4bpb0J5AjH5xuRzxJJb4+UoO7sM/kNiwjIjswrhZs3mQy6zKJPEa6g4h2ZMYmSNIVYt1bExp5ooSdcvOgn25Jc4u94r1MtXha5+dlm7tOWJM7f0RCysJlM2fkvfiOiekzmHkuYfIf53c9tpW90eI2WBQOHpe1tidgakGZEAfALorHHTplTkFNVFZ3oZqJGt0aVM7qugtnyziKaMIHJJPKOjc1cbe63ovCAaVqnV8cyO5e0Q5MUKhY46beM1xivzUAXudsI6csP8BdKe4wyA2BCdnqSIC3Y22DPFgQRXVSJf+QCzhP9FmwUdeHF/J8SlK0ARHVtXX/hKUpSPvfZE+gdB3pj8BsFw9xejEeJyRu5+SOprafEA7nbJYa9wcXW+M0ZK4XL9KJdmEpzxr/DM9eOsv7lIYb+HR/mdxGwJDfnsUzHqtnpLbT6rqSeQsUn9AyMoR3q0eFqVl6gyXfsBB7ZPdGrnCyH2fPclgxhpgy64ziSVnHxiOpRmEnQxC4amJZJiNHP25NfykZAaOVvM1dL91ytn4fEgpiAggldwIzgeh/VwRy89Uv+gfovKbByx15uclzBffJUOSOmqLiD4ZWAfkPHkO/AeqnWwxcDqypdzg9PrFOk+K3kG7MMD7KhfulTDkx5NHe5VD7sNRuMWigTOys0VOb+UWesSm+MWxgBQf+SoI8XfOdZzn6FJixUb2DnQzZ TTjyWIhW fZrhPlDg8DOgC50e5yJGqVec3oZh2r/l15Qw1ohoaZHeQlgb/z7nH9xkAAFsWwU1IC1mliyO6knwZDosdw8HU7Mrm0hVuTdakB5ED6gwdeWV+4ZXYjL0aUAq+Hfdrexkui2LmO03DI7/D5V+5okm6DRqgX/lpDXMvJhk76wPo1EFTHUazjDm1lyl/xQ== 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: Most file-backed faults are already handled through ->map_pages(), but if we need to do I/O we'll come this way. Since filemap_fault() is now safe to be called under the VMA lock, we can handle these faults under the VMA lock now. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Suren Baghdasaryan --- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 938f481df0ab..e615afd28db2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4617,10 +4617,9 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) return ret; } - if (vmf->flags & FAULT_FLAG_VMA_LOCK) { - vma_end_read(vmf->vma); - return VM_FAULT_RETRY; - } + ret = vmf_can_call_fault(vmf); + if (ret) + return ret; ret = __do_fault(vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))