From patchwork Wed Sep 27 05:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13399937 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 141FCE80A88 for ; Wed, 27 Sep 2023 05:25:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1A128D007E; Wed, 27 Sep 2023 01:25:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA698D0002; Wed, 27 Sep 2023 01:25:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BA5B8D007E; Wed, 27 Sep 2023 01:25:25 -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 75A918D0002 for ; Wed, 27 Sep 2023 01:25:25 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4546A1CACB3 for ; Wed, 27 Sep 2023 05:25:25 +0000 (UTC) X-FDA: 81281239410.05.ED8B8B5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 9F31714002B for ; Wed, 27 Sep 2023 05:25:23 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nx5z+q+Y; dmarc=none; spf=none (imf09.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=1695792323; 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=NX7G4kfRjH/776I2tCnKq/UfkE/87x2ty/BZzBX3VcM=; b=0vVBMEmGnUyhfJIqnLPFQxqvSDkL6+2dQO7CCvwpcHW0uBx/jRrbcV4ECgPG4N0T29A8bH 80Y+TyBtKPzYpbqjdIufQ3vyWmG7L5HXsyCCn4E57dQcQ/OKtrQjHr1Ulxx/yZWhyfvxNu gYvXk8qTVIrTmvxniq/BYJUyS7c1FwQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nx5z+q+Y; dmarc=none; spf=none (imf09.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=1695792323; a=rsa-sha256; cv=none; b=RQycAaEqGBwACT7j2Z8w4A4wE3qKPpDKyny7HSGRTBbl4wiz2Y35iJaa1hVi1aeYeNUp1g 06JmJUNx9cjvB6aJtH8XwAp/eNUFxb5ibuU1iC2y1aUyvTV/ZxDszEGGwlMclS5QdCF0R9 Bfb/c4zKXSAsL+Uq6nDxqyTP9ZhGc1I= 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=NX7G4kfRjH/776I2tCnKq/UfkE/87x2ty/BZzBX3VcM=; b=nx5z+q+Y5mfZUz97Yc0HLl2p+M GAmlRaw+SiyWfHH7+r2ydgo7PU4geTcapQ9XeQGVbyRUAv6Ok3MlipWmbne4y4ylD7JphFzLo3jze /r/xSTeRRPHvhmuvUN0AOfayn8ioX/VLzlwgCtcqCgiKuXT/g119JqyoE2dqaCshzkiwxPlnB4vxm CoOscPBWBDX3YL6OogbmBDOrA3eZ/tYhKdQPTMOU1ELQsqn2M4JR3hMk7K2cvH4qvmgBn+o8nZ48d 7I9pZnL/IrL8ysWWofIOQQwLoo2OJPRPm3wYNAq2JekXzGvhe4Uny5dtyTlJFsVhm/0AsmBVdP1UT nTKAjZNw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qlN2o-00Bywo-GQ; Wed, 27 Sep 2023 05:25:06 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Suren Baghdasaryan Subject: [PATCH 1/6] mm: Make lock_folio_maybe_drop_mmap() VMA lock aware Date: Wed, 27 Sep 2023 06:24:59 +0100 Message-Id: <20230927052505.2855872-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230927052505.2855872-1-willy@infradead.org> References: <20230927052505.2855872-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9F31714002B X-Stat-Signature: ez6d55mzfhoi4ash9cb9zacdning5kfu X-HE-Tag: 1695792323-876536 X-HE-Meta: U2FsdGVkX18Lu1KIB/fuqyj4iKHFmUTuVa4aUTDShC8eycAjBrP+n9FYb6Tlf0XqjcjYZPdxlZ6cq6HT99K2TEz9RNlkw8CPn8lJSiLdf9EuWKkM5Pqhpr/mMBxe1bKKPknFGj3VyAMaIFdL6bMwAZGMijK9ihvi/1weRr1XGvmbJmxATNKsmxVigqhGyPqOjM0Eurk9up13wXMS1FoBW++GkT8NPOEy+OMW80C3+mPRmfQ9foAPyswY/gTvFnpsnwPLL3M9b/Gl6PqlnFNSwe74QQbtval3HjplLbq8Q38iOnc3AZQvjfZwsdB2/3NAtNPTK70wQQvDm61jj1fJdK0ifUqlOkbyaYCDYJvh6QvERxkfrJwKiKhykKdEMcRtVgp2vY4rXvLprJrRfpZxtZkxd+udGDjoBg7DdnLnTSZQLKuYpKtOsoQQN/IZHS31wV7vVI7NeIHk2HJui9H1vs1B/OwcuzDXA0Vp8Bib3083zEAfvbvae+BmvJDdsEZF3SMhpesdW0u0xiBqMtGK8EaR7g1fWWGXtjb3V/y/GV3BPejmNb+rpLxNolDR4sf/pXuIm7l+N4Ycdt9GXCjvWGEg7dr4jcNPaoSHKGgIWMCQs43OLRuitgG1e89R8nnQ2oCTH2mZzHHn/3eAWPqY8zeaps8j/ZtUoKG3oIsIT9rhkpmHV28bxefhiGLHVPWZsM6xPFNBW/knTYZzEiX5snFK8H22g6fSw6B1rwpP+shwwRBKcL99zCAPLbncZHdixph/cC/2128bm2PLiPXW1NF3v84gJ6oWaoNbCYjbCqMfnHziHQzBujMBYTnFOd6TYcfldqE6bOzz8upFQYqpN+5GLUmSu2u/whMf+M7CTwHvOmKgfoeJiYGZCVYcluiyl1eAB0bxfwW6IhW1+wQiFTvYIY6dbSeJrere7jHntHM4kZLtWSyBjtwc30rpZW4aSOF+mKydCWdOvecKWoz KP+WmvId 1bImJzm98gd17229ogjjB5kFi8XEzQZA5nNoCJh5+KZ7W+f24h9gaV4L/OpWel5OeKqiP2ctIZIABX54P6sJLZIJGN+moAQ+Xzdnv4yvR9GyJ+VsE5zAbaRjM3LmiFg8Z1SDieoxbZAafQ+A87d/SuitZwgyLrH+CqXvIneSI4/RNQKbVKtIVn35spgV1Zmzf3MRAWQ058IYPF7CzpdgilvXqSjB/2A48UPZa 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: Drop the VMA lock instead of the mmap_lock if that's the one which is held. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 9481ffaf24e6..a598872d62cc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3104,7 +3104,7 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, /* * NOTE! This will make us return with VM_FAULT_RETRY, but with - * the mmap_lock still held. That's how FAULT_FLAG_RETRY_NOWAIT + * the fault lock still held. That's how FAULT_FLAG_RETRY_NOWAIT * is supposed to work. We have way too many special cases.. */ if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) @@ -3114,13 +3114,14 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, if (vmf->flags & FAULT_FLAG_KILLABLE) { if (__folio_lock_killable(folio)) { /* - * We didn't have the right flags to drop the mmap_lock, - * but all fault_handlers only check for fatal signals - * if we return VM_FAULT_RETRY, so we need to drop the - * mmap_lock here and return 0 if we don't have a fpin. + * We didn't have the right flags to drop the + * fault lock, but all fault_handlers only check + * for fatal signals if we return VM_FAULT_RETRY, + * so we need to drop the fault lock here and + * return 0 if we don't have a fpin. */ if (*fpin == NULL) - mmap_read_unlock(vmf->vma->vm_mm); + release_fault_lock(vmf); return 0; } } else