From patchwork Fri Oct 6 19:53:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13411937 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 623AAE94104 for ; Fri, 6 Oct 2023 19:53:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9543780010; Fri, 6 Oct 2023 15:53:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DE3780008; Fri, 6 Oct 2023 15:53:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A52480010; Fri, 6 Oct 2023 15:53:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6FE1680008 for ; Fri, 6 Oct 2023 15:53:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 41F0716023E for ; Fri, 6 Oct 2023 19:53:28 +0000 (UTC) X-FDA: 81316086096.02.4897938 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 9BF542002C for ; Fri, 6 Oct 2023 19:53:26 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G0jTXjL1; spf=none (imf13.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=1696622006; a=rsa-sha256; cv=none; b=KX3Ad38W+bfOs0vRmryXV7VHTgkjDXlFl35HcJtozY4Mo5vkiKLwGF0QZ/uUxLAMfNwZ0N XTPG/kPXZqj1WSgOE/Q0uJQFGYXggu3CmSunafEdY97JvcFY721DcmacII9fSktyd7mMkI GFKqDyJ0rO9WvyJeSIwzpDcFdjBXuH0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G0jTXjL1; spf=none (imf13.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=1696622006; 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=UpRDXMSzxyp/GNQDY2qwHZRYaAmdpdmZ06xcONGxKuGGKNReJVngUPqKb9c8JGmdAnzeF5 z4BnUzlHSmSwK10kki1B8H9KIQn4ioPWIzPM7sT5Qe8j9fIT7X9jw5fqXYiQ/9KFmvVU86 NYYv5Q4IlGT7HI+NvQYKQY6wCrdNpi4= 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=G0jTXjL1c6LMjaqYnahWKeF0jZ dS4UZQjFIGJaobWM6x2L5lg6IU7Q8rbAZAmE6pj6oe+UlcFNjEaM5+rAoACm9N4j8UFoIAA5K0UJ4 GzRFfR7lczEorH3MJI/Uk54ux9XRSVpBS7Ny1RaNA82OTpR7hbhCeFURiJ7Wb7EhHb0jAqUJqUwnQ SzA+GG7dMCTyaAeJR+GbkL/6uD9We3EfChbKldlYtCTO+wH5Xa9UfPfO++WH2roaZZFoRB/9SfiWQ ttqDJU13zRXCzmOGBgOvgTsR5lGf07q2zSdKGVT3yEmqpnWKkSjv4sG9zvk/vta2qiuzwHzpjONTe rID602TQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qoqsy-00H9GS-H3; Fri, 06 Oct 2023 19:53:20 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Suren Baghdasaryan Subject: [PATCH v2 1/6] mm: Make lock_folio_maybe_drop_mmap() VMA lock aware Date: Fri, 6 Oct 2023 20:53:13 +0100 Message-Id: <20231006195318.4087158-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231006195318.4087158-1-willy@infradead.org> References: <20231006195318.4087158-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9BF542002C X-Stat-Signature: 68z53qpemekwy68w7e4m8m4nsp7un1nb X-Rspam-User: X-HE-Tag: 1696622006-725452 X-HE-Meta: U2FsdGVkX18ezSBgFaBeVxgZn02auT5dRkJGFFCjJN2FPsy+poy48A3G+PHwpyoElOUIleWmEd+tI5lhnJwR0MVTipf2qKfN+A854lwkDrb/2zOS7p8HVQiFGUnw/e4DvT1tpqQFzFUhe8noY0BzJR7ruKiInywu4uTpFdXezf3BDSKb6R75w86QMjiigITz1VGXt5bueMCstsje0VX0gKYKvpBVXiNIP3aC+wrmXZ6uzcxloNjfptZK3fz3uHIqOOHbvpyo7279NWNIIilLehJeYxmU6IphGO4OGurlRkT7raV2AjRmo3afobkJ8B7gaXDWmXlhBHcARtfYzQiJMGoqkmdilS2S380jB9TOEiaijn1IVpFv/B886bGukH9NYpXlEDcZ9hyaw943wXa+8MmTSAl4BOQHvbUKkDmER9G7L8/cwCw8iUhMB/kUiT0Bxuz+qZsQ7Juo/1zzjp0bdb6ucg+rPNSA7LzV08nySW9umJqBXA1Rh0q6J4gctidOXKXEDeT6iydrkjYK8WxI788WtY5JunmgsL5TJVTo8DPo2O5fq7SQOfBEXw2ypLw4YrQT7IRz0jORparjZw7U7LbgFyHIJnW+6MX0kVo3oP3BH9GFyN5sX+7vmoOI9hIemATkOFppBqzw5DShbHPZvCKi7PyS4VIyRb2scj958eFrYgRIa8dWU0gRonQ69DyNEEza5Fb3otkWdBnkQkQpt2XvK2egcU6d0WqxDNVTk+MHr8wVchJB+r2NFvkNkl6ocVQv2SD+4G79nb34JnMsvQZcF4kS5QquOP3E8183lWwE5LvaN68FcknmHNsa9Z2hEYerlXZOdHXK9txEXINI2VkzAqlDeyFo3TgKitofgZUGtd0PqAfnibUG3Fy8XsW2LIYQcjsKGi8W1dVmv0C6q0Q4nqfVdaxIllMeeM0X1iBp4h/rEJv+cMm44yZ3otSksfZMjx2oI9HOX+Qp2j8 ubcctchF oiv71wZqyJZ/oqWJSAm0FSRqOLlLM6RkHoLAGvJzS1DDV8pjP65SFNy7KzM8Oqloe3tCdG8R5lMKELMFUFRyTLrWv4cgMgrMv8+FjNh7DgTNzVNFWGoiZCahW1pS8C7Z40/+Yq7xVCOpFzF5mNKVV3tZEF5gTEeDNKEtTewFGm7zNFWpO1HMH1GcQvJ20N6pkmNODtVGlWdyi1/oaKYaWcjGwSODQFRVeiDIH 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) Reviewed-by: Suren Baghdasaryan --- 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