From patchwork Mon Jul 24 18:54:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13325258 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 1176CC001DF for ; Mon, 24 Jul 2023 18:54:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B9DF6B0074; Mon, 24 Jul 2023 14:54:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66A206B0075; Mon, 24 Jul 2023 14:54:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50AF18E0001; Mon, 24 Jul 2023 14:54:20 -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 4319C6B0074 for ; Mon, 24 Jul 2023 14:54:20 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1A03C1409D2 for ; Mon, 24 Jul 2023 18:54:20 +0000 (UTC) X-FDA: 81047405880.03.248077A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 761C5180018 for ; Mon, 24 Jul 2023 18:54:18 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dTwfpe4C; dmarc=none; spf=none (imf06.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=1690224858; 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=v1353Pyv++o8NWvrrZQCLEMMSP1M9ywuP5OB+aDM0kw=; b=nWmW1mc1HVAVzPQETFtsBsgqcbvdVLvblo869hB6311sWndSX3VRzUUbiAxsCuNyVQM8Cc gCiH0cfOVq7DoDdkJhwbTJQ4H+bXDf7gI0czI29frUmaxYzhzaHmAxzzcZsyEaU7kcTyCR pvWVGn/sC1zTqOk+byV5ory/Yd/Svgk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dTwfpe4C; dmarc=none; spf=none (imf06.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=1690224858; a=rsa-sha256; cv=none; b=heVnopMbfSg2dWAwz95oStbQ0YAPcNUKDfEBwICZWFNtRz4bdV5lI4WnC3lvT9XkgvxlYR dKcsduEg2ENK1Eja+LSOOe4zFeFhdwMmWxkalHX75KMaagL9fkUgVuZ56oJElkVDvO7z15 yd4rTZyCLcHvJbHNEn/75vn+kdUeeBQ= 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=v1353Pyv++o8NWvrrZQCLEMMSP1M9ywuP5OB+aDM0kw=; b=dTwfpe4CSf/wNXWMmkRXZpVHoZ vKf5kVMS43ZWZIFpaRKalQSU56M1zPmuvT0cTfRjsHG1ms+id4W5sGxNd+sE6EVlBjAaiNoNxDr1h Xonm4QEVzdVvQOSZTzKKLOlWi/7AHgQcxw+xBTzLLDTPshsCp14Xt1CAf3E711aCMTCmiUsbsyKRJ E7epN1PqMGdDThFGqBD/6NTEaQk9H9FaPMFkL5DFJJwMjPDD9zI0zKEXyQrh4HK4MTkWSaztP6OC+ hH67f752GSEuWd8RT90APXA9Co/fW4lHowfXBqJRfeXhMgCMSq4BVozxlTuI59Y7oVIbvi1uR9rCv csAytTjg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qO0hA-004iRF-Mf; 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 08/10] mm: Run the fault-around code under the VMA lock Date: Mon, 24 Jul 2023 19:54:08 +0100 Message-Id: <20230724185410.1124082-9-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-Rspam-User: X-Stat-Signature: 478jcjhb6fbmres4r4n48rxwwg5hbsi3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 761C5180018 X-HE-Tag: 1690224858-379604 X-HE-Meta: U2FsdGVkX18xKaOEnswsdy4HNugj53ID1KrVhZsHxaasHP7vE02D1kD+l53TJaouAb2OD7u+GF2w1H9bhYmy3YoHTVym5itMnuFEnTmvYZj6eT/HXNEei3dXcafVXDZIX3tK0l4gBU/mdHmd//a4+VuiM9B97cMjnu/kBTGUffIxfR8GWyF4K6JDoHLPRNaBlBrrauKwe7dpufNgHXZ+Ek68KQyj/JUHCMJoOo1/xCy9ffHbJg4WsXs15IGmNibxMjiBgKE+AZgoHUmFCNDNZENZQVSbcWyUo1+Yyfkt1XEsdUmZbC99kZE72PA/SuD5zkO/OF3zcTinv7UG/ahEcrc2YmIbzR6tPGiumkFe6H6ACG8aL2rVRDVZ9TiudaHtOwbQJy5l/RpXWRFI4s8xhIjAhtHCfPqr4vPp0u91outzJKXC52Hw4qSlwD5QzJp7KWO4MuOCdNqCmAQWMkDPIZcI7Kq6PxL267kblEVYRCrwlbH5kTz/udnj7JvmFLnOF0dJBajkEQnrc/2MSIFhACvWwuhmWkJDBgGoqDLLUNlqyAbEE1V5AunRgW2iIS3rfM2qpyHEY0TzAEMMhqmzqR0u4LGSPTyKT1qhNc3dWitUUoasSEo+tpZmuxZXgLQ48MCAUd/GWfdZN83Q1GAiCwGWgQUc6Ahg/gWXZz0af4S46LuBNb5xIGIc2MM3ZCM2mJJMG09SNjxtPHiEjLGRDzUy1i8Nm5eQFQgh7r1L6sA62iL63BOhXkR2w7yZ6D1GKI3ZZQwybghVmiqK5wk+hDnYr1FEc97xhtLmhL3rZxO1QCrhB9EJ0BvCZRz/bQoNiI8ib1SOm34LQnVJDE+D66ls1Qhkv3YXaOwIb0/aWfQyk0MkYisSw25d/XvFlVS11bXP9o0griTCeC3QRErGIxp4Di/F9mM3IkkOUDPUQE2Xcf9nFRAI8WD4fMC631yzpjVAzGWxLPsxSUcUWgS 5sxKtpJO BsTuQYfwQL+SfaJziY0Gj2iEqUMYLAAPBadGLA05PGtooi11QLtDRE0wJeCYWT9As9gn2+K3XVFs0FlA6QSB81Eu2LKJkwD20QzECjYrwAOLPfpia1NVfPvzfYp5w0zm8+pg0hkfDewjRSHK+B8fP/dcEf0n2n5HcH8V+Ww52CiBLvdVO6BP+6zFbvfdU48o1RDdlmO0cjRgDPZg= 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 627a2abb969b..cf28afe7a416 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4661,11 +4661,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 @@ -4677,6 +4672,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;