From patchwork Tue Apr 4 13:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13200242 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 EC34CC77B62 for ; Tue, 4 Apr 2023 13:59:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D5D8280001; Tue, 4 Apr 2023 09:59:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85F1A900003; Tue, 4 Apr 2023 09:59:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 726A5280001; Tue, 4 Apr 2023 09:59:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6086E900003 for ; Tue, 4 Apr 2023 09:59:15 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2A3CCABD49 for ; Tue, 4 Apr 2023 13:59:15 +0000 (UTC) X-FDA: 80643865470.06.354CC45 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 7F68014000B for ; Tue, 4 Apr 2023 13:59:13 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=it1WBTzC; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680616753; 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=NLYKRwFNq+8FLihqhRGQQaNAsp7ufPwRcv+8u3H1cA4=; b=4Ilpp+lttTSIZIvfyyCXb0c7dLpO/of3lZhs0H7w7kdp6ofT8EylGfLwoqZu9vRccEIfhN xYBM62YFqPpd57L4Shz3viD2K9HNww42f5SU7fBqo3cWsOnES5mAAApvkfUFmO/iHErgT/ e9+PG9gEHOp2MLrHqpS99QZyphpYUps= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=it1WBTzC; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680616753; a=rsa-sha256; cv=none; b=IkoNUlpzSbAcmrvOsWdJOu3tO34HUg6JpRuhl/Ln5fHT7qmCDk8t11Xy6gsaD5DzUmvc6f OPrTcDu+HpaVXcLwV63oJSVlk40bjM5wpwHP2jaAzo4QzWzWyMyC2W5JNE6sc/Dn7K8vEt 2dDQFbLbkvKj/+KexmsRukifX4Ticyw= 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=NLYKRwFNq+8FLihqhRGQQaNAsp7ufPwRcv+8u3H1cA4=; b=it1WBTzCbBaRNto+t074tt0Ush V1CMwLewtl1Ml7qU5ah8lyoolevYZpl6ajFurNLcf3LgTOT5eRim6LguAdfOxqGY5KEmjEvFKc9f/ +wvpgAB26L2MfoJtXNLnOKrezsaXjg6iGehplYusPKYuFCqJdzS+yQpirPEX3VaC45ImCMI4OkdGP wRk3ZC+AnxvMeyglwYxclUIi1BDH0vOhR1425jfurrFBzJJFYBfKMttWXuXOr9KIPAHI8kX8pNfA/ ciGWPILcbwdfVQwL0k+Z/SoXgBLlOW889RFA/2HwuHRfWOIw942qXzIBiuPRQq1jgZ9GFnnrlZBoU X1ZgHIag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pjhBU-00FPcn-FW; Tue, 04 Apr 2023 13:58:52 +0000 From: "Matthew Wilcox (Oracle)" To: Suren Baghdasaryan Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Punit Agrawal Subject: [PATCH 5/6] mm: Move the FAULT_FLAG_VMA_LOCK check down from do_pte_missing() Date: Tue, 4 Apr 2023 14:58:49 +0100 Message-Id: <20230404135850.3673404-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230404135850.3673404-1-willy@infradead.org> References: <20230404135850.3673404-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7F68014000B X-Stat-Signature: c8xx4otb48mxnaxhyqi551gcufnccqbq X-HE-Tag: 1680616753-633140 X-HE-Meta: U2FsdGVkX1+csjZXDFDFBIaPgKfi2fB1fQ0Ey6NgxmbwDN/u70V8syueehrzKmJjg5vxdSfYM3OTuSCUhVHbz0Me8qohJcr80/l6qxLE+aMrvPB5bon6ABMt8hCD8LHgXDxv/ViL7SinusCUJkMjZQxcQ+3OKS61gI0a8ybGU+vU/bs7SirTaUOXkwttjHNHqNSijn65Tkro1r0lWgnvwK8Euq2Leal95l9iWsIVjMH/8wUXoOIHg2VHUqz0om55BlosZ0DxnETXg+6q7pCKKAv0sa4X6UCkJkTBFivuMHShNRW0eLfgTJ4ovhlUkTCIt6WulsO2HYmRjaNhXqhmO2P+DwZbVXu2/Qkf+mPin9raqLPxY+sLzeijNvMsLSLcVlQbIBAGZMwCyJG4I+/CPbAQWgRPmcvkUjr93ZRLkBUpVfHK7gafq6ezMLJ4QZP9wuiYBsM6AWBhN+CO/uxeOKgWFlpTZjhgc5v+48slFaB0wHMldAV0kLfPUhhO0FIQoqFxqKdWi783OH54S2zcu57QoIZA/48F1l2AfIsp/b7WGKt5JjhKRmtx0VCDshHrUDYpMciMoVGFXh792ifSztFAEfkn7p6jMRkWu4ah1FOluyJOnVwXqqMTA4XI2j1bqk7mGBJzw61OET7nRk4KBHm3f4i7dnfLSs9GXISxv1ENiUKoI0IbZl3rhUsXn/617mcB3ahGZhV3bBGFYoYV70tIlgz+pKEzex5VplMcD4+cRszQINFfxo4ThaiieN5NrPnupvkOoRSYym5GCdF0CCkC9dx8gyo4IfkHOiDCH0IN9wPBEZlNtR+dq+QSzJw5clbicbok+983XyNRjEcAy9iBeBSma3O9eU0YavTwr7EZL0gT43hmH90BMe9jiKQDXuD8nZlFaxSF9SYwaS9/3ZRYRqrAhUllgHba21uPqga9I5uxLCPhzuuiX2YuyHNU48wALOvKHJ6httD6Vho NMb6HN+h lOOpri7z72FsyvOQDJm37ZcEtIsJJ5uRomPb+6MBxyxnmlC3YRjlbzF/S7vjlGW9jgXJYaiPjZ5seNLJZKSF/PUFwdYFNGK6OopXeBh0Ks+kRKNHriL0Z3dTJ93J9n8Box7g195dno0XA2lEGl6PJF0tdXYjpfLtR3bAVpftR1KrVWFxqSddfRNVGTq/AOVK5Wg1jtjaDjPrfdfByqEeVB4EMQ8gfs6ueVAxOh24H627lVQfUamZchImXZA== 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: Perform the check at the start of do_read_fault(), do_cow_fault() and do_shared_fault() instead. Should be no performance change from the last commit. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index dc2baddc6040..9952bebd25b4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3647,8 +3647,6 @@ static vm_fault_t do_pte_missing(struct vm_fault *vmf) { if (vma_is_anonymous(vmf->vma)) return do_anonymous_page(vmf); - else if (vmf->flags & FAULT_FLAG_VMA_LOCK) - return VM_FAULT_RETRY; else return do_fault(vmf); } @@ -4523,6 +4521,8 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) { vm_fault_t ret = 0; + if (vmf->flags & FAULT_FLAG_VMA_LOCK) + return VM_FAULT_RETRY; /* * Let's call ->map_pages() first and use ->fault() as fallback * if page by the offset is not ready to be mapped (cold cache or @@ -4550,6 +4550,9 @@ static vm_fault_t do_cow_fault(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; vm_fault_t ret; + if (vmf->flags & FAULT_FLAG_VMA_LOCK) + return VM_FAULT_RETRY; + if (unlikely(anon_vma_prepare(vma))) return VM_FAULT_OOM; @@ -4589,6 +4592,9 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; vm_fault_t ret, tmp; + if (vmf->flags & FAULT_FLAG_VMA_LOCK) + return VM_FAULT_RETRY; + ret = __do_fault(vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret;