From patchwork Tue Jul 11 20:20:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13309336 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 E931CC001B0 for ; Tue, 11 Jul 2023 20:20:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A9F36B0071; Tue, 11 Jul 2023 16:20:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25AAA6B0072; Tue, 11 Jul 2023 16:20:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 122AA6B0075; Tue, 11 Jul 2023 16:20:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 024A26B0071 for ; Tue, 11 Jul 2023 16:20:58 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AA2901203B2 for ; Tue, 11 Jul 2023 20:20:57 +0000 (UTC) X-FDA: 81000449754.22.33FE311 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 1A693160005 for ; Tue, 11 Jul 2023 20:20:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TzHT2edh; dmarc=none; spf=none (imf08.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=1689106855; 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=v94Ubxfh0lfpoM1pvfa/PhiO08lrJc9bG/pAuDnDu5E=; b=wCRbo+ztPmLZssH1uDCJPI01O9I07ImdJ4SJj82p01FjtboeCHF7Jp364eqZ8z3wFA3u5N UcqIn6Pz5OaXXePkQ9kaPpi87iuK6JH8YQE3Ak3SebmMtc1vtqbJqye0PA8AGWDSIvMnai aka9Qk6F/y5li3n6s4z0kuDyIG2QPAE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TzHT2edh; dmarc=none; spf=none (imf08.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=1689106855; a=rsa-sha256; cv=none; b=VvNwdxgCFxplVKhsWvRX7SeE8uglvfHhPD97n6AS84rhSDa6h296Wd1BN0rC9la2IEauq9 GYKw0qBqJJWvZbe+I7twUfbuXjCwqlQyFabaAgX2QvEF5VLHnXMSsqH94eFNasaau7rl6u RU0SOlcFjZeaMXGTF+haoXfdfYZoPXI= 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=v94Ubxfh0lfpoM1pvfa/PhiO08lrJc9bG/pAuDnDu5E=; b=TzHT2edho2+AoBnEaZG6rSN+Xz HqdS52OSxRjhfnGl0GcPjNDDaW+puGj9MFK6PDZdT0nHLkUZZHVZia6dFjj4fCyS/krNwe1XiBJ5W fG8eF6uJHrHh/n19hVXzIQE2sFtiQSswSN30D3B9vOlrHmVQ5q51J7cxkBk0/VfmnHySgMxOdbGO5 lPK6MQnwfgOKQrrf+YXuHBuIkBte0N1ZLRiCRnpASNkDN1JdOSpcNqw2mwsAfZ7OuF9U6HU9PLIZ/ YsAHUMECuSPk8nMWNQYQyiCeg/QspuKbmiWuO24oJQwEh5tQaIjAA63lIhKQPa68IinpMHnL73dW7 q4aTheXA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qJJqs-00G1QJ-7t; Tue, 11 Jul 2023 20:20:50 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Arjun Roy , Eric Dumazet , Suren Baghdasaryan , linux-fsdevel@vger.kernel.org, Punit Agrawal Subject: [PATCH v2 7/9] mm: Run the fault-around code under the VMA lock Date: Tue, 11 Jul 2023 21:20:45 +0100 Message-Id: <20230711202047.3818697-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230711202047.3818697-1-willy@infradead.org> References: <20230711202047.3818697-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1A693160005 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: orjqq1yaifctph6ff15wrebccqieexi3 X-HE-Tag: 1689106854-7263 X-HE-Meta: U2FsdGVkX1+FCoGl9z4+ksixBGhue70Y0pZ20GAnPxaGCud1RwvPqELTkkOyaqZ1uQlfIsyanVeBdafj/oo9+zC8qfbkOn33TuW+U/9O+B5rIWjza+dD8csQCBmzqXIAC1U+rYxWkbQSvnWT4rnPJMAQVJ6BmcG+7696t/yMz6J5tmYgnTTGnx7cSC6zuRSi4NvKSHKNffdfmTHE8FUEmI+S40OYk1YcbdSajgqP/HjhzC/46DiPiZcvwgDJJXCeIm+Gik3IRX2aYuyeZIHujX9EQ7qaD6X8rf20DCbvgGcl9+GPx0ke/kvrCN9Zhe2Ns13WtsabF/oiAKGGtTLVoqhhWaK7OXX0N8kafEAIZCAbvGvPqVX1GyQ7HtzNHsTtZ4umDg33Yad7AK8XkQvXG18UAoyJ5EjFRMFjwJpFp6ZBCz+PkewfYCiY8QDgRwkFOjopOAHw5iAn5VezYkeY3WsV/d76yEtaZHeIHHWyLAa8LKnlIMM8O/Oe3waoFGJmI5L1zY1vYrBQjUbEAYjsgQ3hD100NRyJDi7XTa4yDU/7u6tREFi6YShFTjdqGEeVOoImhge07M+qUDLSN0l3/U+269x17Pd5qVc8xahzcKImhKEqWZ8tK2rlB8EUA2Xv+L7qQBQAooXmZmN0HOk1qzcoHgdD6t2DJ1mKjE6/SPO9ZNWisE8isWZxeBRtB2hGtrgZSuEB4FYdVGWOsnTztxBtfjVA4wO4kK7b/6pUZBa73iMoG8G0zYT7wskO8yXrkTtW8s/L7GgHA9R0St9KpB1zIFdHI+Df+zl+e5JGitJjwvpKH8T76SBfkWq772l3hhxs5dfRJyaifj8tzOGP9FEIe1p6+5L0fD1Dhix0aj3FXyPloOsJywvUT1TeowSEFwy2PV6NG+cYk8hoXB6iSul+sLtBXDcZaIL2Jln6HUrljQDTq/ux+17V6cbIMg7rCAELB+40Jb4ri1CwIcT mNPj+q3G fgAJFTrpu/T5b5uV8G3J+N1qGyGUxrVbhh2pIchxWGqRK17hCg0GMOwCpubQzghbZXKOzFrQQhQG6puMr7sI9wfD2dUmgb1dwSbs0N1bAzsMIf0G0YFV2Y2g8doihBokMkc1DB17KE5YuxuOxXDkgDwOm/1+8bHWsbjBVK1SmYceJVKjirM29OHyBBg== 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: The map_pages fs method should be safe to run under the VMA lock instead of the mmap lock. This should have a measurable reduction in contention on the mmap lock. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Suren Baghdasaryan --- mm/memory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 709bffee8aa2..0a4e363b0605 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4547,11 +4547,6 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) vm_fault_t ret = 0; struct folio *folio; - if (vmf->flags & FAULT_FLAG_VMA_LOCK) { - vma_end_read(vmf->vma); - 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 @@ -4563,6 +4558,11 @@ 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 = __do_fault(vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret;