From patchwork Tue Apr 4 13:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13200241 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 945CFC6FD1D for ; Tue, 4 Apr 2023 13:59:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E2C7900006; Tue, 4 Apr 2023 09:59:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2924E900003; Tue, 4 Apr 2023 09:59:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15A9A900006; Tue, 4 Apr 2023 09:59:13 -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 034BB900003 for ; Tue, 4 Apr 2023 09:59:13 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C61E3140F35 for ; Tue, 4 Apr 2023 13:59:12 +0000 (UTC) X-FDA: 80643865344.30.DF65AEB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 1CAA74001B for ; Tue, 4 Apr 2023 13:59:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hkP38WXd; spf=none (imf04.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=1680616751; 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=IgHYdieXRfLvREO+xFvQYpyGVelRpE2byQDY/NWcPVw=; b=lkAF4Je7ADfgo5IRHiilTiBqFg61ecH64P+169iQsleDBPim78QwFZP3L57AbBxxS5GCtc eDXx6jgRdrM3wu8YI4zKdcbKxd7q5T29CcWURT2XsWmBiKzdvfTxgo5OzZMvg/UK4m7Bf8 59pNGwJkzHl0zSZfFMSBUSxsna2FRbs= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hkP38WXd; spf=none (imf04.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680616751; a=rsa-sha256; cv=none; b=cRjY6s/m2sfr8KW+KsRM9Hpxh2j/F8Iay7pIEy7JO7LP63ABupTUBEtO41hyNGDWyDdNZk e/c6U8VteQEnFmGBobS9ovJRc9bRI5mxEJdJyP93nhWg1q+AKxa4Yworqb6bSDwWUF7u2d tmxo2mz6QKFqzI2XuySJMusoqasOK8Q= 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=IgHYdieXRfLvREO+xFvQYpyGVelRpE2byQDY/NWcPVw=; b=hkP38WXdxSRQI9qE4hdjSm+MIG dGsRyyxfG7qIxgAkpnHEL3nMtKCJK4cfzXA9camTfntUJN/qZyyI05FnwSdTv3jzAMZ++uIFUj/FG tYeiw5hX2sPahC/yykQOSeiOs+w/+wq3p8d4lI22HJqr5aieEKPQMBDF1fNeYy1Urdg+lUreny2qZ MqaF+0qam1AhUsPqvAkKcxeR7LF2tjcYHY99iYM92L2Bh42AKNUQH87AxBJA8cBViykfIvlUhGxuV +mMA05WyJsgPlB/21C4fBDOd/E8TGta1WocWkCzcVFFpXqODYKZbzvCJXfV0KOAQQsMOSvPPmElnQ AR/B9/MA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pjhBU-00FPcp-II; 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 6/6] mm: Run the fault-around code under the VMA lock Date: Tue, 4 Apr 2023 14:58:50 +0100 Message-Id: <20230404135850.3673404-7-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1CAA74001B X-Rspam-User: X-Stat-Signature: nmap343daanuzogi3oa4z6xo3a7uon5u X-HE-Tag: 1680616750-570363 X-HE-Meta: U2FsdGVkX1/6V4G1AX12KvuI3RGypL5HCb1uYWblL/Fr4VgWQR+ObhgteWpOsn5y15lZJIyO+/GX5hXpOzGlQygBXO29Tyc9rxycX0hBU2gd15QY88+zkAlmqUPTvlM7Uc5Rnsl+jItMptsktZym7dzUp2qlYJUyP9CMynxQCPk3CpJ07JGaOpohC2E20A7It7JDqNDYXfQxkOWD93O//2Ky4pRNPB2xvMBG4dgX6Icn91RNqWlALZyGxuYbFZwcE8XZB3do09f/x59c3BeI495eXYdfY9XA4zzI+85YpPR+fN4h7hG8yuixeibBI7R3ZNPy/+HvGGp2DfeY4n9JSmIJJY+6Cbhr+gd3g7ngDZsj3tckE6n3yt72JqJ9NENu/NVNfr3cw+co8dUvcXZPXTD2dmuh7wa+GdQ5rmx4vOlFXFIq8qTTcnXqpWu7B5VFVwEQ4qotCGjhiGAn4DN7a0wGQXw089f78pDqK0YRypfSWVwc4Af/vTa1v//EeES5buHJerKck61EAr+VdnTY33MUF5z/0TSnVjWKC6O+DupT+ZMIn0OZfYntbo6NJt1vyuWjx4KmdGiBZQ4HzwX/Q+DGcO/vs8hcYpoxvzP89Fy80fL394R74UCm/yxfRtMgX2rMJsNq3dehKCGQNp6q1e1OjDBqGjZdLT0v++w/TGb816gqGjesfiGk+nR+Yt3Zas1/dHFlt9NJuTGS4zpKGHsTM9sv3sXKWm6so6Oklvc66oAO5vMm5aJpiUZELWpwfumGCANBTSzXgGY/RCGXFSzVVD8Vcef/SXoU/FhDHJwhQupsZSCGeCXDJGuBM7uTvZPzV8YHVieRqAMVGctwBfcDhrmP8Ld0azr+t0MFM0I70/FZtgL5ghFboN10w7u/+i6DhdnnDqCiquGNm9qhulIoL+EUSLIxvomrOz8wFAWxTi+Oq7COWWNqmfj7irhKiWIajEfm4epaycTRdW5 RFK+w17P JQM/lgqxy2fdZLQAD7ZAYNdgl+WY2/rAO+6KaGcwqZOIa+OA6Pv97Gg3YcjnvfF1rDfxyQjdOJZhWxsRMZJss09pT7HU7KkOvWiXV/Zr3NOYw0lO+KX3eyvfMWmlYkHGvvJRMWcJNRU0RzHqi9UPN3D3Lv6vUJHRLxq1EikhLcEo8mtyUCod2G5XNr4mdyTRUjTTH 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) --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 9952bebd25b4..590ccaf6f7fb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4521,8 +4521,6 @@ 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 @@ -4534,6 +4532,8 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) return ret; } + 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;